Python Midterm PDF

Title Python Midterm
Course Intro to Comp Scie with Python
Institution University of Ontario Institute of Technology
Pages 5
File Size 379.9 KB
File Type PDF
Total Downloads 62
Total Views 134

Summary

2020 Python Midterm...


Description

Faculty of Business and Information Technology Course: Instructor: Semester: Course component: Total mark: Duration:

INFR 1101: Intro to Programming for IT (Python) – Networking & IT Security Samaneh Mazaheri Fall 2020 Midterm Test 15 marks (+ 1 extra mark) 170 minutes (from 5:10 pm to 8 pm)

From 15.1 of your academic calendar: Academic misconduct includes, but is not limited to: 1. Unreasonable infringement on the freedom of other members of the academic community (e.g., disrupting classes or examinations, harassing, intimidating, or threatening others). 2. Violation of safety regulations in a laboratory or other setting. 3. Cheating on examinations, assignments, reports, or other work used to evaluate student performance. Cheating includes, among other things, copying from another student’s work or allowing one’s own work to be copied, submitting another person’s work as one’s own, fabrication of data, consultation with an unauthorized person during an examination, use of unauthorized aids, or submitting work prepared in collaboration with other member(s) of a class, when collaborative work on a project has not been authorized by the instructor. 4. Impersonating another student or allowing oneself to be impersonated for purposes of taking examinations, or carrying out laboratory or other assignments. 5. Plagiarism, which is the act of presenting the ideas, words, or other intellectual property of another as one’s own, including images, designs, processes, computer software, digital, audio and video files, Internet resources and other works without appropriate attribution or credit. The use of other people’s work must be properly acknowledged and referenced in all written material. 6. Obtaining by improper means examination papers, tests, or similar materials; use or distribution of such materials to others. 7. Falsifying academic records, including tests and examinations, or submitting false credentials for purpose of gaining admission to a program or course, or for any other purpose. 8. Misrepresentation of facts, whether written or oral, which may have an effect on academic evaluation. This includes making fraudulent health claims, obtaining medical or other certificates under false pretences, or altering certificates for the purpose of misrepresentation. 9. Submission of work when a major portion has been previously submitted or is being submitted for another course, without the expressed permission of all instructors involved.

Page 1 of 5

Instructions: ▪ ▪ ▪ ▪

There are 7 questions; select ONLY 4 questions and submit your solutions in Canvas. You are allowed to upload multiple files. (The latest version for each question will be graded.) For each question, you need to submit one file (only .py file) in canvas to the designated drop box. Name your submissions as Q1, Q5, Bonus, etc. On top of your solution you should comment your name, you student ID, and the question number (For example, "Question 3”)



Since this test is open book, you can use resources that you find helpful; for example, your textbook, course lecture notes, previously saved source code on your laptop, help section of your IDE, etc. o You are not allowed to use: ▪ Emails/Text messaging/Chat programs (or any communications software) to connect with your peers for any communication of any type (except your TA and your instructor) ▪ Failure to follow any of these rules will be viewed as academic dishonesty.



If during the midterm, you have any question/issue, contact your TA or me: • TA’s email: [email protected] • My email: [email protected]



If for any reason, you faced difficulty to upload/submit your files, email your solutions to me and your TA immediately. Please remember late submissions will not be graded.



Remember you need to answer ONLY 4 questions (out of 7 questions). Question 7 has a bonus part too (1 marks extra will be added to 15 marks).

Page 2 of 5

Question 0 (Required) Copy the following statement on top of one of your submissions (not all 4 submissions) and sign it by writing your name and student number. Statement of Commitment to Academic Integrity As a member of the Ontario Tech University community, I share our community’s commitment to the highest standards of academic integrity and excellence in all dimensions of our work. I therefore promise that I will not lie, cheat, or use any unauthorized aids or assistance to complete any of my essays, assignments, and exams. I further promise that I will not offer any unauthorized assistance to any of my fellow students, and I promise that I will not ask any of my fellow students for unauthorized assistance. I promise that the work I submit is my own and that where I have drawn on the work of others, I have included proper attribution for my sources. Student name and student number:

Question 1 (3.75 marks) Write two functions that calculate volume and surface area of the following container using these formulas:

𝑉 =

1 𝜋𝑏(𝑅12 + 𝑅22 + 𝑅1 𝑅2 ) 3

𝑆 = 𝜋(𝑅1 + 𝑅2 )√(𝑅2 − 𝑅1 )2 + 𝑏 2 + 𝜋𝑅12

Page 3 of 5

Question 2 (3.75 marks) Write a function that implements the following formula to calculates the amount of financial assistance for families in need: • • •

If the annual family income is between $30,000 and $40,000 and the family has at least 3 children, the assistance amount will be $1,000 per child. If the annual family income is between $20,000 and $30,000 and the family has at least 2 children, the assistance amount will be $1,500 per child. If the annual family income is less than $20,000, the assistance amount will be $1,000 per child.

Write a program that asks for the family income and their number of children, then prints the amount of assistance that your function returns. Use -10, as a sentinel value for the input.

Question 3 (3.75 marks) Write the following functions in your program that asks the user to key in 5 test marks, then shows a letter grade for each mark as well as average test mark. •

calc_average: This function accepts 5 test marks as inputs and returns the average of the marks.



determine_grade: This function accepts a test mark as an input and returns a letter grade for the mark.

Use the following grading scale to realize the letter grade:

90–100 80–89 70–79 60–69 Below 60

A B C D F

Question 4 (3.75 marks) There are 3 seating types in a theater hall. Class A seats cost $25, Class B seats cost $20, and Class C seats cost $15. Write a program that asks how many tickets for each seats class have been sold, then shows the amount of income produced from all sales.

Page 4 of 5

Question 5 (3.75 marks) Assume the client has a certain amount of money in a saving account that accumulates compound interest; you want to calculate the amount that they will have after a specific number of years. Write a function that calculates the balance of a bank account with a given initial balance and interest rate, after a number of years (given). Consider the interest is yearly compounded. In your program, you should prompt user to key in the account’s initial value, interest rate in percent, and the number of years that the money will be left in the account. The program should pass these values to a function that returns the future value of the account, after the specified number of years. The program should display the account’s future value. 𝐹𝑉 = 𝐼𝑉 ∗ (1 + • • • •

𝑟 𝑦 ) 100

FV is the future value of the account after some years IV is the initial value r is the interest rate y is the number of years

Question 6 (3.75 marks) Write a function that generates 99 random numbers and counts how many of those numbers are even, and how many of them are odd. Write a main() function to test your function.

Question 7 (3.75 marks) Write a program that generates a random number in the range of 1 through 100, and asks user to guess what the number is. If the user’s guess is higher than the random number, the program should show “The guess is too high, try again!” If the user’s guess is lower than the random number, the program should show “It is too low, try again!” If the user guesses the number, the program should congratulate the user and generate a new random number so the game can start again.

Question 7 Bonus (1 mark extra) Improve the game so it keeps count of the number of guesses that user makes. When the user correctly guesses the random number, the program should display the number of guesses.

Page 5 of 5...


Similar Free PDFs