You are on page 1of 2

Assignment #6 [2%]

Chapter 7: Arrays: Lists and Tables


Other Instructions will be provided by the instructor
Question 1: Draw flowchart and write a program
Create a program that allows the user to input a list of first names into one array and last names
into a parallel array. Input should be terminated when the user enters a sentinel character. The
output should be a list of email addresses where the address is of the following form:
first.last@mycollege.edu
Answer: a=[]
b=[]
c=[]
t=0
i=0
while t !="*":
f=str(input("enter the first name :"))
l=str(input("enter the last name :"))
a.append(f)
b.append(l)
c.append(a[i]+"."+b[i]+"@mycollege.edu")
t=input("Enter * to abort")
i+=1
i=i-1
print("The generated email id \n")
while i>=0:
print(c[i])
i=i-1

Question 2: Write program


Write a program that allows a small business owner to input, in parallel arrays, the type of item,
its cost, and the number in stock. The program should output this information in the form of a
table. You can assume that columns will be correctly formatted at later time. The output will
look something like this:

Answer: item_name = []
cost = []
number_in_stock = []
check = 'Y'
item = input("Enter the Item name:\n")
price = input("Enter the cost of item:\n")
stock = input("Enter the Number in stock:\n")
item_name.append(item)
cost.append(price)
number_in_stock.append(stock)
check = input("Want to add more press 'Y' else 'N':")
while check == 'Y' or check == 'y':
item = input("Enter the Item name:\n")
price = input("Enter the cost of item:\n")
stock = input("Enter the Number in stock:\n")
item_name.append( item)
cost.append(price)
number_in_stock.append(stock)
check = input("Want to add more press 'Y' else 'N':")
print("Item Name Cost Number in stocks")
for i in range(len(item_name)):
print(item_name[i]," ",cost[i]," ",number_in_stock[i])

You might also like