• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 19 pages
Exam (elaborations)

Python Exam 1 Questions with Correct Answers Graded A+

Document preview thumbnail
Preview 3 out of 19 pages

Python Exam 1 Questions with Correct Answers Graded A+ What is the output of: 11.0//2 - Answers 5.0 Floor division to the nearest whole number Returns a float What is the output of: 11//2 - Answers 5 Return an int What is the output of: 11/2 - Answers 5.5 Returns a float What is the output of: 11/2.0 - Answers 5.0 What is the output of: 20%2 - Answers 0 What is the output of: 21%2 - Answers 1 What is the output of: 11%3 - Answers 2 x = 'Texas A&M University' x [-3] = ? - Answers i x = 'Texas A&M University' x [3] = ? - Answers a x = 'Texas A&M University' len(x) = ? - Answers 20 x = 'Texas A&M University' x [0:5:2] = ? - Answers Txs It starts at 0 and ends at 5, incremented by 2 x = 'Texas A&M University' x [4:] = ? - Answers s A&M University x = 'Texas A&M University' x [:4] = ? - Answers Texa x = 'Texas A&M University' 'A' in x = ? - Answers True Acts as a Boolean, determines if it is in the string x = 'Texas A&M University' 't' in x = ? - Answers True x = 'Texas A&M University' 'A&M' in x = ? - Answers True x = 'Texas A&M University' ' ' in x = ? - Answers True x = 'Texas A&M University' ' ' in x = ? - Answers False 2**1+1 - Answers 3 3* 1**3 - Answers 3 2*(3+1) - Answers 4 6+4/2 - Answers 8.0 Returns a float due to the division

Content preview

Python Exam 1 Questions with Correct Answers Graded A+

What is the output of: 11.0//2 - Answers 5.0

Floor division to the nearest whole number

Returns a float

What is the output of: 11//2 - Answers 5

Return an int

What is the output of: 11/2 - Answers 5.5

Returns a float

What is the output of: 11/2.0 - Answers 5.0

What is the output of: 20%2 - Answers 0

What is the output of: 21%2 - Answers 1

What is the output of: 11%3 - Answers 2

x = 'Texas A&M University'

x [-3] = ? - Answers i

x = 'Texas A&M University'

x [3] = ? - Answers a

x = 'Texas A&M University'

len(x) = ? - Answers 20

x = 'Texas A&M University'

x [0:5:2] = ? - Answers Txs

It starts at 0 and ends at 5, incremented by 2

x = 'Texas A&M University'

x [4:] = ? - Answers s A&M University

x = 'Texas A&M University'

x [:4] = ? - Answers Texa

,x = 'Texas A&M University'

'A' in x = ? - Answers True

Acts as a Boolean, determines if it is in the string

x = 'Texas A&M University'

't' in x = ? - Answers True

x = 'Texas A&M University'

'A&M' in x = ? - Answers True

x = 'Texas A&M University'

' ' in x = ? - Answers True

x = 'Texas A&M University'

' ' in x = ? - Answers False

2**1+1 - Answers 3

3* 1**3 - Answers 3

2*(3+1) - Answers 4

6+4/2 - Answers 8.0

Returns a float due to the division

len('Hello world') = ? - Answers 11

Be sure to count the spaces as values

int(-2.3) = ? - Answers -2

float(32) = ? - Answers 32.0

str(3.14159) = ? - Answers 3.14159

[0] * 4 = ? - Answers [0, 0, 0, 0]

[1, 2, 3] * 3 = ? - Answers [ 1, 2, 3, 1, 2, 3, 1, 2, 3]

x=1

y=0

, x >= 2 and (x/y) >2 = ? - Answers False

x=6

y=2

x >= 2 and (x/y) >2 = ? - Answers True

x=1

y=0

x >= 2 and y != 0 and (x/y) >2 = ? - Answers False

What is the purpose of the "def" keyword in Python? - Answers It indicates that start of a function

It indicates that the follow indented section of code id to be stored for later

What will the following Python program print out?



def fred():

-> print ("Zap")

def jane():

-> print ("ABC")



jane()

fred()

jane() - Answers ABC Zap ABC

What will the following Python program print out?



count = 0



for number in [3, 41, 12, 9, 74, 15]:

-> count = count + 1

Document information

Uploaded on
April 10, 2025
Number of pages
19
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$10.89

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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.
TutorJosh
3.5
(77)
Sold
508
Followers
16
Items
33081
Last sold
4 days ago




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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions