Question

In: Computer Science

Problem 2 (Save and Get Info) : Write a program that asks for the user's name,...

Problem 2 (Save and Get Info) : Write a program that asks for the user's name, phone number, and address. The program then saves all information in a data file (each information in one line) named list.txt. Finally, the program reads the information from the file and displays it on the screen  in the following format:

Name: User's Name  
Phone Number: User's Phone Number  
Address: User's Street Address
User's City, State, and Zip Code

Solutions

Expert Solution

Note=> As it is not written in which programming langauage I am suposed to do it. So, I am solving it in python.

Code:

## This cell will add the data in a dictionoray and then store that dictionary in file
import pickle
dict1={}
name=input("Enter Name: ")
phone=input("Enter Phone No: ")
address=input("Enter Address: ")
dict1['Name']=name
dict1['Phone Number']=phone
dict1['Address']=address
with open('/content/drive/My Drive/list.txt','wb' )as fp: #Addin the path where we want to store the file as list1
  pickle.dump(dict1,fp)

## Loading a data from file
with open('/content/drive/My Drive/list.txt','rb') as fp: ## Reading a file from same location
dict1= pickle.load(fp)
for i in dict1.keys() : # iterationg over each key of ditionary
  print(i, " : ",dict1[i] )

Screenshots of code and output :

Storing a data into a file list1.txt.

Reading a data from file:


Related Solutions

C++ Language Problem 2 (Save and Get Info) : Write a program that asks for the...
C++ Language Problem 2 (Save and Get Info) : Write a program that asks for the user's name, phone number, and address. The program then saves all information in a data file (each information in one line) named list.txt. Finally, the program reads the information from the file and displays it on the screen  in the following format: Name: User's Name   Phone Number: User's Phone Number   Address: User's Street Address User's City, State, and Zip Code
Write a Python program that has the user enter their name.   Using the user's name calculate...
Write a Python program that has the user enter their name.   Using the user's name calculate the following: 1. How many letters are in the user's name? 2. Print the user's name in REVERSE both in capital letters and lowercase letters 3. Print the ASCII value for each letter of the user's name. 4. Print the SUM of all of the letters of the user's name (add each letter from #3)
C++ : Write a program that creates a login name for a user, given the user's...
C++ : Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login name, which is made up of the first five letters of the last name, followed by the first letter of the first name, and then the last two digits of the number (use the % operator). If the last name has less than five letters, then use all letters of the...
Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
Write a program that asks the user to enter the name of a file, and then...
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad or another text editor to create a sample file that can be used to test the program. Sample Run java FileLetterCounter Enter file name: wc4↵ Enter character to count: 0↵ The character '0' appears in the file...
Write a program in java that asks the name of the buyer and the number of...
Write a program in java that asks the name of the buyer and the number of shares bought. Your program must then calculate and display the following. sold stock/shares to the general public at the rate of $24.89 per share. Theres a 2 percent (2%) commission for the transaction. Outputs need Amount paid for buying the stock ($) Amount paid for the commission ($) Total amount ($)
Tail of a File, C++ Program. write a program that asks the user for the name...
Tail of a File, C++ Program. write a program that asks the user for the name of a text file. The program should display the last 10 lines, or all lines if less than 10. The program should do this using seekg Here is what I have so far. #include<iostream> #include<fstream> #include<string> using namespace std; class File { private:    fstream file;    string name; public:    int countlines();    void printlines(); }; int File::countlines() {    int total =...
Write a C++ program that asks for the name and age of three people.   The program...
Write a C++ program that asks for the name and age of three people.   The program should then print out the name and age of each person on a separate line from youngest to oldest. Hint: Start with a program that just asks for the names and ages then prints them out in the same order they are entered. Then modify the program so it prints out the list of names in every possible order.    Note that one of...
Create a program that asks the user for two positive integers. If the user's input for...
Create a program that asks the user for two positive integers. If the user's input for either integer is not positive (less than or equal to 0), re-prompt the user until a positive integer is input. You may assume that all inputs will be integers. Print out a list, ascending from 1, of all divisors common to both integers. Then, print out a message stating whether or not the numbers are "relatively prime" numbers. Two positive integers are considered relatively...
Develop a program Grades.java that collects the user's (students) name, course name, and the score for...
Develop a program Grades.java that collects the user's (students) name, course name, and the score for three quizzes. You are supposed to read this data from the keyboard using the Scanner class. Calculate the total score and the average score. Further, using the grading scale below, based on the average score computed above, your program should calculate and output a letter grade. and the range boundaries should be configured properly (i.e.: exactly 90 and above is an A, and anything...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT