Uploaded by dayanafonseca0616

Copy of Summer 2020 COP 2500 Midterm Exam Part A

advertisement
Summer 2020 COP 2500 Midterm Exam Part A
Date: 10/8/2020
Time Given: 2:00 pm
Time Due: 3:00 pm
Late Due Time: 3:10 pm
Directions: Please use your course notes and a calculator as aids for this exam.
Please type your answers directly in the provided .docx file, or type your answers in your
own text file or .docx file. The accepted file types for submission will be .doc, .docx, .txt
and .pdf. It's recommended that you stop working at the due time and start uploading at
that time. Anything turned in before the late due time will be accepted for full credit.
Anything that doesn't make it in by the late due time will earn a 0. A 10 minute buffer is
provided after both due times. Please don't take advantage of these buffers as it's an
unnecessary risk.
1) Provide 3 different ways to produce the following output: [3 points]
charge
on
#1 print (”charge”,end=“\n”)
print(“on”)
#2print(“charge”,”on”,sep=”\n”)
#3print(“charge\n on”)
Each method should have one or two print commands. (Hint: make use of end, sep and
escape sequences.)
2) In Orange County, Florida we have a 6.5% tax added to all purchases of items. This
6.5% is in addition to the purchase price of the item. Write a program that reads in the
cost of the item (before tax) in cents as an integer number and prints out the total cost
with the value added tax added. For example, if the user enters 520, your program
should print out 553 or 554 (rounding doesn’t matter. Both solutions are correct).
[4 points]
P
#ask the user how much does the item cost
num=int(input(“Enter cost of item:”)
#calculating the total price of the item after tax
total_cost=num+(num*6.5)//100
print(“Total cost is: ”,total_cost)
3) David has X amount of dollars saved for going to UCF sporting events. He has factored
that each event costs him 25 dollars. In his program, he writes the expressions X//25
and x%25. What do those two expressions represent? [2 points]
a) X // 25
gives the number of UCF sporting event David can go with his savings
b) X % 25
Gives the amount remaining after David factored x dollars to all the UCF sporting
Download