0% found this document useful (0 votes)
330 views2 pages

First - Last@mycollege - Edu: Assignment #6 (2%)

This document contains instructions for Assignment #6, which involves two questions about arrays. Question 1 asks students to create a program that takes first and last names as input in parallel arrays and outputs email addresses combining the names. Question 2 asks students to create a program that takes item names, costs, and stock numbers as input in parallel arrays and outputs the data in a table format. Sample code is provided as an answer for each question.

Uploaded by

dfgdfg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
330 views2 pages

First - Last@mycollege - Edu: Assignment #6 (2%)

This document contains instructions for Assignment #6, which involves two questions about arrays. Question 1 asks students to create a program that takes first and last names as input in parallel arrays and outputs email addresses combining the names. Question 2 asks students to create a program that takes item names, costs, and stock numbers as input in parallel arrays and outputs the data in a table format. Sample code is provided as an answer for each question.

Uploaded by

dfgdfg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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:
[email protected]
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