Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 17 pages
Exam (elaborations)

Python Coding Exam Questions and Answers

Document preview thumbnail
Preview 3 out of 17 pages

Python Coding Exam Questions and Answers print () - Answer-(Chapter 6) How would you print out the following variable in all upper case in Python? greet = 'Hello Bob' twist() - Answer-(Chapter 6) Which of the following is not a valid string method in Python? .ma - Answer-(Chapter 6) What will the following Python code print out? data = 'From Sat Jan 5 09:14:16 2008' pos = ('.') print data[pos:pos+3] strip() - Answer-(Chapter 6) Which of the following string methods removes whitespace from both the beginning and end of a string? Collection variables can store multiple values in a single variable - Answer-(Chapter 8) How are "collection" variables different from normal variables? print len(data) - Answer-(Chapter 8) Which of the following Python statements would print out the length of a list stored in the variable data? A list of integers - Answer-(Chapter 8) What type of data is produced when you call the range() function? x = range(5) append() - Answer-(Chapter 8) What list method adds a new item to the end of an existing list? for / in - Answer-(Chapter 8) What are the Python keywords used to construct a loop to iterate through a list? print friends[2] - Answer-(Chapter 8) For the following list, how would you print out 'Sally'? friends = [ 'Joseph', 'Glenn', 'Sally' ]

Content preview

Python Coding Exam Questions and
Answers

print greet.upper() - Answer-(Chapter 6) How would you print out the following variable
in all upper case in Python?
greet = 'Hello Bob'

twist() - Answer-(Chapter 6) Which of the following is not a valid string method in
Python?

.ma - Answer-(Chapter 6)
What will the following Python code print out?
data = 'From Sat Jan 5 09:14:16 2008'

pos = data.find('.')

print data[pos:pos+3]

strip() - Answer-(Chapter 6) Which of the following string methods removes whitespace
from both the beginning and end of a string?

Collection variables can store multiple values in a single variable - Answer-(Chapter 8)
How are "collection" variables different from normal variables?

print len(data) - Answer-(Chapter 8) Which of the following Python statements would
print out the length of a list stored in the variable data?

A list of integers - Answer-(Chapter 8) What type of data is produced when you call the
range() function?
x = range(5)

append() - Answer-(Chapter 8) What list method adds a new item to the end of an
existing list?

for / in - Answer-(Chapter 8) What are the Python keywords used to construct a loop to
iterate through a list?

print friends[2] - Answer-(Chapter 8) For the following list, how would you print out
'Sally'?
friends = [ 'Joseph', 'Glenn', 'Sally' ]

6 - Answer-(Chapter 8) What does the following Python code print out?

,a = [1, 2, 3]

b = [4, 5, 6]

c=a+b

print len(c)

Glenn - Answer-(Chapter 8)
What will the following Python code print out?
friends = [ 'Joseph', 'Glenn', 'Sally' ]

friends.sort()

print friends[0]

t[2:4] - Answer-(Chapter 8) Which of the following slicing operations will produce the list
[12, 3]?
t = [9, 41, 12, 3, 74, 15]

Nothing would print - the program fails with a traceback - Answer-(Chapter 8) What
would the following Python code print out?
fruit = 'Banana'

fruit[0] = 'b'

print fruit

Zap
ABC
Zap - Answer-(Midterm) What will the following Python program print out:

What Python statement would you like me to run? - Answer-(Chapter 1) When Python is
running in the interactive mode and displaying the chevron prompt (>>>) - what question
is Python asking you?

20 - Answer-(Chapter 1) What will the following program print out:

>>> x = 15
>>> x = x + 5
>>> print x

.py - Answer-(Chapter 1) Python scripts (files) have names that end with:

for - Answer-(Chapter 1) Which of these words is a reserved word in Python ?

, quit() - Answer-(Chapter 1) What is the proper way to say "good-bye" to Python?

Central Processing Unit - Answer-(Chapter 1) Which of the parts of a computer actually
execute the program instructions?

A sequence of instructions in a programming language - Answer-(Chapter 1) What is
"code" in the context of this course?

Secondary Memory - Answer-(Chapter 1) A USB memory stick is an example of which
of the following components of computer architecture?

The computer did not understand the statement that you entered - Answer-(Chapter 1)
What is the best way to think about a "Syntax Error" while programming?

Random steps - Answer-(Chapter 1) Which of the following is not one of the
programming patterns covered in Chapter 1?

# This is a test - Answer-(Chapter 2) Which of the following is a comment in Python?

123abc - Answer-(Chapter 2) What does the following code print out?

hours - Answer-(Chapter 2) Which of the following variables is the "most mnemonic"?

stop - Answer-(Chapter 2) Which of the following variables is the "most mnemonic"?

Retrieve the current value for x, add two to it and put the sum back into x - Answer-
(Chapter 2) What does the following statement do? x = x + 2

Parenthesis () - Answer-(Chapter 2) Which of the following elements of a mathematical
expression in Python is evaluated first?

2 - Answer-(Chapter 2) What is the value of the following expression? 42 % 10

5 - Answer-(Chapter 2) What is the value in x after the following statement executes: x =
1+2*3-8/4

98 - Answer-(Chapter 2) What value be in the variable x when the following statement is
executed?
x = int(98.6)

Pause the program and read data from the user - Answer-(Chapter 2) What does the
Python raw_input() function do?

Indent the line below the if statement - Answer-(Chapter 3)
What do we do to a Python statement that is immediately after an if statement to
indicate that the statement is to be executed only when the if statement is true?

Document information

Uploaded on
August 12, 2024
Number of pages
17
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$13.29

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.
Perfectscorer
3.6
(75)
Sold
501
Followers
355
Items
9421
Last sold
3 weeks 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