Class 10 Exam  >  Class 10 Questions  >  Write a Python program to enter the the numbe... Start Learning for Free
Write a Python program to enter the the number of family members and their age and store this information in dictionary?
Most Upvoted Answer
Write a Python program to enter the the number of family members and t...
**Python program to enter the number of family members and their age and store this information in dictionary**

To write a Python program to enter the number of family members and their age and store this information in a dictionary, we can follow the below steps:

1. Take input from the user for the number of family members.
2. Create an empty dictionary to store the family members' information.
3. Use a for loop to iterate over the range of number of family members entered by the user.
4. For each iteration, take input from the user for the family member's name and age.
5. Store the family member's information in the dictionary with their name as the key and age as the value.

Here is the complete Python program that implements the above steps:

```python
# take input from the user for the number of family members
num_members = int(input("Enter the number of family members: "))

# create an empty dictionary to store the family members' information
family = {}

# use a for loop to iterate over the range of number of family members
for i in range(num_members):
# take input from the user for the family member's name and age
name = input("Enter family member's name: ")
age = int(input("Enter family member's age: "))

# store the family member's information in the dictionary
family[name] = age

# print the dictionary containing the family members' information
print(family)
```

**Explanation:**

Let's go through the program step by step to understand how it works.

1. We start by taking input from the user for the number of family members using the `input()` function. We convert the input to an integer using the `int()` function and store it in the variable `num_members`.

```python
num_members = int(input("Enter the number of family members: "))
```

2. Next, we create an empty dictionary called `family` to store the family members' information.

```python
family = {}
```

3. We use a for loop to iterate over the range of number of family members entered by the user. The range function generates a sequence of numbers from 0 to `num_members - 1`.

```python
for i in range(num_members):
```

4. For each iteration of the for loop, we take input from the user for the family member's name and age using the `input()` function. We store the name in the variable `name` and the age as an integer in the variable `age`.

```python
name = input("Enter family member's name: ")
age = int(input("Enter family member's age: "))
```

5. Finally, we store the family member's information in the dictionary `family` using the family member's name as the key and their age as the value.

```python
family[name] = age
```

6. After all the family members' information has been entered and stored in the dictionary, we print the dictionary using the `print()` function.

```python
print(family)
```

This will output the dictionary containing the family members' information.
Community Answer
Write a Python program to enter the the number of family members and t...
#Program to create a dictionary which stores name of family members and their age
#entering the number of family members from user
num=int(input("Enter the the number of family members:"))
count=1
family=dict()      #Creating an empty dictionary
while count<=num:
    name=input("Enter the name of family member:")
    age=int(input("Enter age:"))
    family[name]=age
    count+=1
print("\n\nfamily_member\tage")
for k in family:
 print(k,'\t\t',family[k])
Output:

Attention Class 10 Students!
To make sure you are not studying endlessly, EduRev has designed Class 10 study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Class 10.
Explore Courses for Class 10 exam

Similar Class 10 Doubts

Unfortunately, I cannot provide a detailed answer to this question as it appears to be a request for a specific customer care helpline number for a service called "3 Patti Orc." However, I can provide some general information on customer care helpline numbers and their importance.Customer care helpline numbers are dedicated phone lines that allow customers to contact a company or service provider for assistance with their products or services. These helpline numbers are typically toll-free, meaning that customers can reach out for support without incurring any charges.Importance of Customer Care Helpline Numbers:1. Accessibility: Customer care helpline numbers ensure that customers have easy access to assistance whenever they encounter any issues or have queries regarding a product or service. It provides a direct line of communication between the customer and the company.2. Efficiency: Helpline numbers allow companies to efficiently address customer concerns. Trained customer care representatives can provide prompt and accurate solutions, helping to resolve issues in a timely manner.3. Customer Satisfaction: Customer care helpline numbers play a crucial role in enhancing customer satisfaction. By providing a dedicated support channel, companies demonstrate their commitment to addressing customer needs and concerns, thereby improving overall customer experience.4. Feedback and Improvement: These helpline numbers also serve as a valuable feedback mechanism for companies. Customers can provide feedback on their experiences, allowing companies to identify areas for improvement and make necessary changes to enhance their products or services.Conclusion:Customer care helpline numbers are essential for providing effective support to customers. They ensure accessibility, efficiency, and customer satisfaction. If you are specifically looking for the customer care helpline number for "3 Patti Orc," it is recommended to contact the company directly or visit their official website for the correct and up-to-date information.

Top Courses for Class 10

Write a Python program to enter the the number of family members and their age and store this information in dictionary?
Question Description
Write a Python program to enter the the number of family members and their age and store this information in dictionary? for Class 10 2024 is part of Class 10 preparation. The Question and answers have been prepared according to the Class 10 exam syllabus. Information about Write a Python program to enter the the number of family members and their age and store this information in dictionary? covers all topics & solutions for Class 10 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Write a Python program to enter the the number of family members and their age and store this information in dictionary?.
Solutions for Write a Python program to enter the the number of family members and their age and store this information in dictionary? in English & in Hindi are available as part of our courses for Class 10. Download more important topics, notes, lectures and mock test series for Class 10 Exam by signing up for free.
Here you can find the meaning of Write a Python program to enter the the number of family members and their age and store this information in dictionary? defined & explained in the simplest way possible. Besides giving the explanation of Write a Python program to enter the the number of family members and their age and store this information in dictionary?, a detailed solution for Write a Python program to enter the the number of family members and their age and store this information in dictionary? has been provided alongside types of Write a Python program to enter the the number of family members and their age and store this information in dictionary? theory, EduRev gives you an ample number of questions to practice Write a Python program to enter the the number of family members and their age and store this information in dictionary? tests, examples and also practice Class 10 tests.
Explore Courses for Class 10 exam

Top Courses for Class 10

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev