Question

In: Computer Science

This task is solved in Python 3. Develop a program that lets the user add new...

This task is solved in Python 3.

Develop a program that lets the user add new people to the file phone.txt

Add name and number, end with <enter>

Name and number: Robin 94567402

Name and number: Jessica 99468283

Name and number:

>>>

Phone.txt

Expanded to ------>

Phone.txt

Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick 99455443 Susan 98122134 Jill 99655732

Bob 98787896

Mary 98654321

June 99776655

Chris 99112233

Viv 98554455

John 99776612

Joe 97888776

Rick 99455443 Susan 98122134 Jill 99655732

Bob 98787896

Robin 94567402 Jessica 99468283

Solutions

Expert Solution

CODE:-

temp = input("Name and number: ") # TAKING THE USER INPUT
file = open("Phone.txt","a")  # selecting the append mode

while temp:  # THEN iterating until the user has entered something 
    value = list(map(str,temp.split())) # then splitting the input and storing it into list 
    file.write(value[0]+"\n")  # then appending it into the file 
    file.write(value[1]+"\n") # both name and number
    temp = input("Name and number: ") #  again taking the input
file.close()  # finally closing the file 

FILE BEFORE:-

FILE AFTER:-

FOR ANY OTHER QUERY PLEASE COMMENT


Related Solutions

This task is solved in Python 3. Develop a program that can change the phone number...
This task is solved in Python 3. Develop a program that can change the phone number of a person in phone.txt (hint: the easiest thing is probably to make a new version of the file, and then delete the old one before the new is renamed to phone.txt) Name: John Old phone number: 99776612 New number: 99889999 >>> phone.txt Replaced by ------> phone.txt Mary 98654321 June 99776655 Chris 99112233 Viv 98554455 John 99776612 Joe 97888776 Rick 99455443 Susan 98122134 Jill...
This task is solved in Python 3. Develop a program that can, among other things, manage...
This task is solved in Python 3. Develop a program that can, among other things, manage your courses and course results. It must also be able to calculate the average grade, for all grades or for a selection of grades limited to a certain subject area and / or course level (100, 200 or 300 level). NB! All courses are worth the same amount of credits. The program should have two global collections Courses is a list that contains the...
This task is solved in Python 3. Develop a function which counts the number of vowels...
This task is solved in Python 3. Develop a function which counts the number of vowels in a text. >>> numberofVowels ("There is a cat outside the house") 13
In Python: Design a program that lets the user enter the total rainfall for each of...
In Python: Design a program that lets the user enter the total rainfall for each of the 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, the months with the highest and lowest amounts. However, to start, do not ask the user for input. Instead, hard code the monthly rainfalls as a list in your program, and then use the list to determine how to conduct the processing...
Design a Python program with a While loop that lets the user enter a number. The...
Design a Python program with a While loop that lets the user enter a number. The number should be multiplied by 10 and the result stored in a variable named "product". The loop should repeat as long as the product variable < 10. Anything not completely obvious to a newbie should be commented on as in line comments. Should be modulated and repeatable as well as there should be an invocation of the main routine at the end of the...
This task is about classes and objects, and is solved in Python 3. We will look...
This task is about classes and objects, and is solved in Python 3. We will look at two different ways to represent a succession of monarchs, e.g. the series of Norwegian kings from Haakon VII to Harald V, and print it out like this: King Haakon VII of Norway, accession: 1905 King Olav V of Norway, accession: 1957 King Harald V of Norway, accession: 1991 >>> Make a class Monarch with three attributes: the name of the monarch, the nation...
In python please design a program that lets the user enter the total rainfall for each...
In python please design a program that lets the user enter the total rainfall for each of the last 10 years into an array. The program should calculate and display the total rainfall for the decade, the average yearly rainfall, and the years with the highest and lowest amounts. Should have Indentation Comments Good Variables initializations Good questions asking for the parameters of the code Output display with explanation Screenshot
In python design a simple program that lets the user enter the total rainfall for each...
In python design a simple program that lets the user enter the total rainfall for each of the last 10 years into an array. The program should calculate and display the total rainfall for the decade, the average yearly rainfall, and the years with the highest and lowest amounts. Have screenshot with indentation and output display with explantion.Include comments
Create a PYTHON program that lets a user guess a number from 1 to 1,000: -i...
Create a PYTHON program that lets a user guess a number from 1 to 1,000: -i used random.randint(1,1000) -must give hints like (pick a lower/higher number) which i already did -tell the user when he has repeated a number (help) -the game only ends when you guess the number (help) -you loose $50 every failed attempt (done) ****I did it as a while loop -
PYTHON BEGINNER Problem Create a program that lets the user play a simplified game of Blackjack,...
PYTHON BEGINNER Problem Create a program that lets the user play a simplified game of Blackjack, which is played between the user and an automated dealer as follows. The dealer shuffles a standard deck of 52 cards, draws two cards, and gives them to the user. The user can then choose to request another card from the dealer, adding it to their hand. The user can continue to request cards or choose to stop at any time. After each time...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT