CSCI 131: Introduction to Programming with Python
CSCI 131: Introduction to Programming with Python
Quiz 2
NAME:
Date: Friday, October 14, 2005, Home Quiz
Quiz 2 submission due day is Monday, October 17
Quiz 2 consists of Two Parts
Part I - 60 points - 4 short questions, each question requires final answer only, each question 15 points
Part II - 40 points - 2 questions, each question requires to write a short program, each question 20 points
Part I (60 points)
Question 1 (15 points):
What is the output of the following program? What will be the values of each variable at the end of the program?
a, b, c = 1, 3, 5
result = a**b – (a//c)*(a+c)
print a, b, c, result
a, c = 0, 0
Write your final answer here:
Output:
a=
b=
c=
Question 2 (15 points):
What is the output of the following program? What will be the values of each variable at the end of the program?
num = 45
digit = num % 10
result = (num + digit)//100
print result, digit
digit = num //10
Write your final answer here:
Output:
digit =
num =
Question 3 (15 points):
Which of the following Python statements are valid and which are not. Check the appropriate column and give a short explanation for non-valid statements.
|Statement |Valid |Non Valid |Explanation |
|test = ( 5 + 7 ) * ( 16 % 4 ) | | | |
|6 + 5*7 = num | | | |
|test = 5 % (25//50) | | | |
|print “yana” | | | |
|test = 25 ** (25 % 5) | | | |
Question 4 (15 points):
What is the output of the following program? What will be the value of the variable num at the end of the program?
num = 1234
digit1 = num % 10
digit2 = (num//10) % 10
digit3 = (num//100) % 10
digit4 = (num//1000) % 10
print digit1, digit2, digit3, digit4
num = 0
Write your final answer here:
Output:
num =
Part II (40 points)
Question 1 (20 points):
Write a Python program that calculates the amount of money in the saving account after one year, if the initial deposit was 1000 dollars and the year interest is 2%.
Your program should print the values of the deposit, interest and the final amount with appropriate messages. You can write only short comments.
Write your program here:
Question 2 (20 points):
The person goes to vacation. The airplane ticket costs 215 dollars before tax and the tax on the ticket is 8%. One night at the hotel costs 119 dollar before tax and the hotel tax is 11%. The person stays at the hotel 3 nights. The ground transportation costs 35 dollar to the hotel and 30 dollars to the airport.
Write a Python program that calculates the total cost of the vacation.
Write your program here:
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- proposed prototype syntax university of arizona
- informatics practices new 065 class xii
- printing patterns tom kleen
- cbse board sample questions cbse papers cbse result cbse
- pandas groupby in action assumption university
- csci 131 introduction to programming with python
- python class room diary be easy in my python class
- avinash maurya full stack web developer
Related searches
- introduction to java programming pdf
- introduction to java programming and data structures
- introduction to java programming 10th
- introduction to java programming liang
- introduction to java programming ppt
- sql programming with python
- introduction to python pdf
- programming with java pdf
- introduction to java programming liang pdf
- introduction to r programming pdf
- hands on programming with r pdf
- introduction to python programming pdf