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

Python Exam Chapters 1-5 Questions & Answers

Rating
-
Sold
-
Pages
15
Grade
A+
Uploaded on
15-11-2025
Written in
2025/2026

Python Exam Chapters 1-5 Questions & Answers What should the following two expressions evaluate to ? 'spam' + 'spamspam' 'spam' * 3 - ANSWERS-Both expressions evaluate to the string 'spamspamspam'. Why is egg a valid variable name while 100 is invalid ? - ANSWERS-Variable names cannot begin with a number. What three functions can be used to get the integer, floating-point number, or string version of a value ? - ANSWERS-The int(), float(), and str() functions will evaluate to the integer, floating-point number, and string versions of the value passed to them. Why does this expression cause an error ? How can you fix it ? 'I have eaten' + 99 + 'burritos' . - ANSWERS-The expression causes an error because 99 is an integer, and only strings can be concatenated to other strings with the + operator. The correct way is i have eaten ' + str(99) + ' burritos '. What are the two values of the Boolean data type? How do you write them? - ANSWERS-True and False, using capital T and F, with the rest of the word in lowercase. What are the three Boolean operators? - ANSWERS-and, or, and not. Write out the truth tables of each Boolean operator (that is, every possible combination of Boolean values for the operator and what they evaluate to). - ANSWERS-True and True is True. True and False is False.

Show more Read less
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
November 15, 2025
Number of pages
15
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Python Exam Chapters 1-5 Questions
& Answers15

What should the following two expressions evaluate to ?

'spam' + 'spamspam'

'spam' * 3 - ANSWERS-Both expressions evaluate to the string 'spamspamspam'.



Why is egg a valid variable name while 100 is invalid ? - ANSWERS-Variable names cannot begin
with a number.



What three functions can be used to get the integer, floating-point number, or string version of
a value ? - ANSWERS-The int(), float(), and str() functions will evaluate to the integer, floating-
point number, and string versions of the value passed to them.



Why does this expression cause an error ? How can you fix it ?

'I have eaten' + 99 + 'burritos' . - ANSWERS-The expression causes an error because 99 is an
integer, and only strings can be concatenated to other strings with the + operator. The correct
way is i have eaten ' + str(99) + ' burritos '.



What are the two values of the Boolean data type? How do you write them? - ANSWERS-True
and False, using capital T and F, with the rest of the word in lowercase.



What are the three Boolean operators? - ANSWERS-and, or, and not.



Write out the truth tables of each Boolean operator (that is, every possible combination of
Boolean values for the operator and what they evaluate to). - ANSWERS-True and True is True.

True and False is False.

, False and True is False.

False and False is False.

True or True is True.

True or False is True.

False or True is True.

False or False is False.

not True is False.

not False is True.



What do the following expressions evaluate to ?

(5 > 4) and (3 == 5)

not (5 >4)

(5 > 4) or (3 == 5)

not ((5 > 4) or (3 == 5))

(True and True) and (True == False)

(not False) or (not True) - ANSWERS-False

False

True

False

False

True



What are the six comparison operators ? - ANSWERS-==, !=, <,>,<=,and >=



What is the difference between the equal to operator and the assignment operator ? -
ANSWERS-== is the equal operator to operator that compares two values and evaluates to a
Boolean, while = is the assignment operator that stores a value in a variable.

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.
Bensuda Oxford University
View profile
Follow You need to be logged in order to follow users or courses
Sold
829
Member since
3 year
Number of followers
445
Documents
20738
Last sold
15 hours ago
ECONOMICS,NURSING,BIOLOGY AND ALL REVISION MATERIALS

DEDICATED TO PROVIDE YOU WITH THE BEST LEARNING MATERIALS THAT WILL IMPROVE YOUR GRADES ,WELCOME TO ALIZGRADES AND LETS DO IT TOGETHER!!! GOODLUCK!!!!!!!

3.7

156 reviews

5
72
4
24
3
25
2
11
1
24

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