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
Veronika [31]
3 years ago
12

Create a Python program that: Allows the user to enter a person's first name and last name. The user should be able to enter as

many names as they desire. Create a function that takes the first name and last name, puts them together with the last name first, followed by the first name; with the names separated by commas. Take the result from the function, and place the resulting name in a list. Once the user finishes entering names, sort the contents of the list. Write the sorted names from a list into a text file. When you create the text file, allow the user to enter a name for the file to be created. After you finish writing names to the file, close the file and end the program.
Computers and Technology
1 answer:
KIM [24]3 years ago
7 0

Answer:

#main function start

def main():

#list to store names entered by user

name_list=[]

#variable to take input from user to keep rotating the loop and take input from user again and again

ch='y'

fname=""

lname=""

while ch=='y' or ch=='Y':#keep the loop taking input from user till user do not want to enter more

#take input from user

name=[]

fname=input("Enter first name: ")

lname=input("Enter last name: ")

name.append(fname)

name.append(lname)

 

#append the previously input first and last name in main list

name_list.append(name)

ch=input("Do you want to continue: (y/Y for yes)")

#main function end

#get file name from user

filename=input("Enter output file name")

#open file in write mode

file=open(filename,"w")

#keep loop add data in file till main list 'name_list' have

for i in name_list:

#Write data in file

file.write("%s, %s\r\n" % (i[0],i[1]))

#close the file

file.close()

#call main function

main()

Explanation:

input the above code and see output

You might be interested in
The columns of a spreadsheet data source are A. form letters. B. the mailing list. C. data points. D. fields.
mojhsa [17]

I believe it is C, I'm so sorry if im incorrect.

8 0
3 years ago
Convert (520)10 into base 16​
kakasveta [241]
The base-10 value of 52010 is equal to base-16 value of 20816.
3 0
3 years ago
Read 2 more answers
What is the output?
Pepsi [2]

Answer:

The answer is false

Explanation:

The string isalpha() returns True if all the characters are letters and the string has at least one character.

7 0
3 years ago
What is iteration?????
maksim [4K]

Answer:

Iteration is a program repeated untill a condition is met

Explanation:

4 0
4 years ago
Read 2 more answers
Which of the following is NOT a team based technique? 1. Joint application development 2. Rapid application development 3. Agile
Aleonysh [2.5K]

Answer: Option (4) is correct.

Explanation:

Object-oriented analysis is referred to as an approach in technical world which is popular for analyzing and also designing an app, system, or organization by applying OOPs or object-oriented programming, also making use of visual modeling in order to cater better stakeholder communication and commodity quality.

7 0
3 years ago
Other questions:
  • Which of the following information would best be displayed throughout the use of a time line
    5·2 answers
  • John just opened a savings account and wants to maximize the account of interest you earn which of the following actions would e
    13·1 answer
  • Universal Containers (UC) has decided to build a new, highly sensitive application on the Force platform. The security team at U
    11·1 answer
  • Question 15 of 28 (1 point) Jump to Question: Among many other responsibilities, a competent person is responsible for: A. All o
    6·1 answer
  • Someone posing as an IT tech requests information about your computer configuration. What kind of attack is this
    9·1 answer
  • 2. Voltage is:
    13·1 answer
  • Who tryna play among us
    8·2 answers
  • To see the formula in a cell, look at the___
    5·1 answer
  • As marketing manager, you need to have ( blank) skills and (blank) skills.
    11·1 answer
  • Imagine that you work for a company directly related to your major. Your company is preparing for expansion and your boss, Ms. S
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!