100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Python Exam 1 questions with answers graded A+(19)

Rating
-
Sold
-
Pages
19
Grade
A+
Uploaded on
17-10-2024
Written in
2024/2025

Python Exam 1 questions with answers graded A+(19)

Institution
Python
Course
Python










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Python
Course
Python

Document information

Uploaded on
October 17, 2024
Number of pages
19
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Python Exam 1 questions with answers
graded A+(19)

Finish the following code example with the print statement that will return a value of True.

a=5

b = 5.5

c=7

d = 7.5

print( Choose One...

print(a == int(b) and c != int(d))

print(a != int(b) and c != int(d))

print(a != int(b) and c == int(d))

print (a == int(b) and c == int(d)) ) - correct answer ✔✔print(a == int(b) and c == int(d))



print(5 == int(5.5) and 7 == int(7.5))



The following code example needs to print, for five weeks, the # of minutes per day to walk, starting with
10 minutes a day in week 1 and ending 50 minutes a day in week 5 choose the correct line of code to
start this iteration and finish this code example.

Choose One...

a) for week in range(1,5)

b) for week in range(5)

c) for week in range(1,6)

d) while week < 5

print("You should walk for ", week * 10, " minutes in ", week) - correct answer ✔✔for week in range(1,6)



Look at the following code and then indicate, for each question, a yes or no based on whether the
statement is true or false.

,a=5

b=3

b=a



a == b yes or no

a is b yes or no

b == 3 yes or no - correct answer ✔✔a == b yes

a is b yes

b == 3 no



Open the shirts file in a mode to where it cannot be written to

Read the contents of the entire file

Print the contents of the entire file

Not every line of code is used:

shirtFile = open("shirts.txt","a)

shirtFileContents = shirtFile.read()

for shirtLines = range(shirtFile):

print(shirtFileContents)

shirtFile = open("shirts.txt","r") - correct answer ✔✔LINE 1: shirtFile = open("shirts.txt", "r")

LINE 2:

shirtFileContents = shirtFile.read()



LINE 3: print(shirtFileContents)



How many syntax errors are there in the following code?

if totalSales>= 700000:

print("Gold Customer")

elif totalSales >= 400000:

print("Silver Customer")

, elif totalSales >= 100000 and newCustomer:

print("Bronze Customer and first-time prize winner")

elif totalSales >= 100000

print("Bronze Customer")

prnit("Thank you for your business") - correct answer ✔✔3



The goal with this is to show the nearest integer above and below the # (above for the upperBound
variable and below for the lowerBound variable) given and have it work when a different number is
present.

Choose One...

import math

use math

sys.math

sampleNumber = 77.4

upperBound = Choose One...

math.ceil

math.ceiling

math.round

math.floor (sampleNumber)

lowerBound = Choose One...

math.ceil

math.ceiling

math.round

math.floor (sampleNumber)

print(upperBound)

print(lowerBound) - correct answer ✔✔As the math built-in module is being used, the module needs to
be imported. That is done on the first line of code. The math.ceil function takes a floating number up to
the next whole number. The math.floor function lowers a floating number to its base whole number. A
round function would not be efficient here as it would not guarantee the upper and lower integers from
the floating number and returned

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
StuviaExamHub Havard School
View profile
Follow You need to be logged in order to follow users or courses
Sold
458
Member since
3 year
Number of followers
355
Documents
16965
Last sold
4 days ago
EXAM HUB (LATEST UPDATE)

QUALITY WORK OF ALL KIND OF QUIZ or EXAM WITH GUARANTEE OF AN A+ latest updates Im an expert on major courses especially; psychology,Nursing, Human resource Management &amp; Project writing. Assisting students with quality work is my first priority. I ensure scholarly standards in my documents . I assure a GOOD GRADE if you will use my work. Feel free to purchase n recommend others for 100% pass EXAMS!

3.7

85 reviews

5
39
4
10
3
17
2
6
1
13

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions