1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vika [28.1K]
3 years ago
8

Write a program that asks for 'name' from the user and then asks for a number and stores the two in a dictionary (called 'the_di

ct') as key-value pair. The program then asks if the user wants to enter more data (More data (y/n)? ) and depending on user choice, either asks for another name-number pair or exits and stores the dictionary key, values in a list of tuples and prints the list. Note: Ignore the case where the name is already in the dictionary. Example: Name: pranshu Number: 517-244-2426 More data (y/n)? y Name: rich Number: 517-842-5425 More data (y/n)? y Name: alireza Number: 517-432-5224 More data (y/n)? n [('alireza', '517-432-5224'), ('pranshu', '517-244-2426'), ('rich', '517-842-5425')]
Computers and Technology
1 answer:
babymother [125]3 years ago
5 0

Answer:

Okay. I am doing it with Python. Hope it'll help you to understand the concept.

Code:

the_dict={}   #Creating a dictonary

def dat():    # Creating a function named dat()

   

   name = input('Your Name: ')   # Data from user

   ph = input('Phone Number: ')

   for i in range(1):  #Creating loop

       the_dict[name]=ph   # Placing the value in dictonary

   more = input('More Data (y/n): ')   # Asking for More data

   if more == 'y':   # if more is y then run the function dat()

       dat()   # calling dat()

   elif more == 'n':   # if more is n then print the dictonary named 'the_dict'

       print(the_dict)

   else:

       print('Wrong Input')  # if wrong input print the message and run dat() again

       dat()

dat()  # calling the function

   

Result:

Your Name: PyMan

Phone Number: 9814579063

More Data (y/n): y

Your Name: PyMman2

Phone Number: 451513262026

More Data (y/n): y

Your Name: C#Man

Phone Number: 7798822222

More Data (y/n): n

{'PyMan': '9814579063', 'PyMman2': '451513262026', 'C#Man': '7798822222'}

You might be interested in
Write the following numbers in binary. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25
AfilCa [17]
0 1 10 11
Explanaition:
4 0
3 years ago
Select the correct answer.
Vedmedyk [2.9K]
D because of the sun
6 0
3 years ago
Is the core of an operating system that controls its basic functions.
WINSTONCH [101]

Answer:

Explanation:

Tweaker

5 0
4 years ago
Which part of the computer stores and processes data?
lilavasa [31]

it is A the hardware im pretty sure but dont put my answer in im not completley sure

3 0
3 years ago
What's the difference between natural systems and man made systems <br>​
Aneli [31]

Answer:

Natural systems are already in place while man made systems were created by humans manipulating things in some way.

Explanation:

man made: human created

natural systems: existed without interference

5 0
3 years ago
Other questions:
  • Please look at picture
    10·2 answers
  • A computer that delivers requested webpages to your computer or mobile device is a(n) _________.
    9·1 answer
  • Which measure should you take for the periodic maintenance of your computer? You need to invest in a for_______________ the peri
    15·2 answers
  • Which of the following describes the function of a web browser?
    11·1 answer
  • A school principal trying to find out if parents will help buy new playground equipment shows digital leadership by.
    8·2 answers
  • Which of the following is productivity strategy for collaboration?
    6·1 answer
  • Self-confidence, blank, and communication are key factors to building positive relationships. Fill in the blank with a 13 letter
    5·1 answer
  • What were the social, political, cultural, or economic context in which the was invention made?
    14·1 answer
  • Which system provides an easier way for people to communicate with a computer than a graphical user interface (GUI)
    6·1 answer
  • How would you explain how a password generator program works
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!