Programming Test 3

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is the operator for not equal to?

!=

Given x=9, which line of code will evaluate false

x<3

What is the output for the above line of code: year="2001" if year.isdigit(): print(year,"is all digit.") else: pass

"2001 is all digits"

What is the output for the above line of code: id=3556 if id>2999: print(id,"is a new student") else: print(id,"is an existing student")

"3556 is a new student"

What is the output for the following code: day = "Monday" is day.capitalize()=="Monday": print("Start the week!") else: pass

Start the week!

What is the output for the above line of code: hot_plate = true if hot_plate: print("Be careful, hotplate!") else: print("The plate is ready")

"Be careful, hot plate!"

What is the output of the following code? size_num = "8 9 10" size = "8" #user input if size.isdigit()==False print("Invalid: sie should only use digits") elif int(size)<8 print("size is too low") elif size in size_num: print("size is recorded") else: print("size is too high")

"size is recorded"

What is the output for the above line of code: vehicle_type = "Truck" if vehicle_type.upper().startswith("P"): print(vehicle_type, 'starts with "P"') else: print(vehicle_type, 'does not start with "P"')

'Truck does not start with "P"'

What is the best estimate for the output of the above code?

1.0

What is the best estimate for the output of the above code? x=3 y=4 calculation=x*y print(calculation)

12

What is the best estimate for the output fo the above line of code? calculation= 5+15/5+3*2-1 print(calculation)

13.0

What is the operator that compares the values of both the operands and checks for value equality?

==

What is the output for the above line of code: asignment=25 if assignment=25: print('use"=" to assign values') else: pass

Syntax Error

Like else, the elif can execute only when the previous if conditional evaluates False (shown in the below code sample): if response == 3: return "Correct" elif response <=0: return "Correct" else: return"Incorrect"

True

True and False are boolean keywords in python

True

In Python, string comparisons, lowercase "a" is less than uppercase "A"

false

What is the minimum code to mathematically add num_1 to num_2?

num_1+int(num_2)

For the code: x=3+9*2, the value of x i 21 when applying order of operations.

true

The double equals sign (==) is used to compare values

true


Ensembles d'études connexes

Florida statues, rules, and regulations common to all lines

View Set

Chapter 46: Caring for Clients with disorders of the lower GI tract

View Set

Economics 151 questions for 1st exam

View Set

funds chap..skin integrity, P.U.

View Set

NHA CCMA COMMUNICATION AND CUSTOMER SERVICE

View Set

Operations Management Exam 3 (Chapter 9)

View Set

Management: Motivating Employees

View Set

Biology 122 - Semester 2 - Week 1 Quiz

View Set

Personal Finance- Chapter 5 (Exam 2)

View Set