100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Python Exam 1 questions with answers graded A+(19) $18.49   Add to cart

Exam (elaborations)

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

 4 views  0 purchase
  • Course
  • Python
  • Institution
  • Python

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

Preview 3 out of 19  pages

  • October 17, 2024
  • 19
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • Python
  • Python
avatar-seller
Sakayobako30
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

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Sakayobako30. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $18.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

83249 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$18.49
  • (0)
  Add to cart