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

CMPSC 101 MIDTERM EXAM 1 QUESTIONS & ANSWERS(RATED A+)

Rating
-
Sold
-
Pages
5
Grade
A+
Uploaded on
26-02-2025
Written in
2024/2025

What command should you type in the interpreter to check your Python installation? - ANSWERpython What do you call a saved file containing Python instructions? - ANSWERA module How can you write the expression "n = n * 2" using short-hand operators? - ANSWERn *= 2 Which string function do you call when you want to convert the first letter in the string to uppercase? - ANSWERalize() Which function do you call to check the number of items in a list? - ANSWERlen() Which operator is used to concatenate two lists? - ANSWER+ (plus) Which function do you call when you want to append an element at the end of a list? - ANSWERd() What is the name of the output you get when an error occurs in your program? - ANSWERStack trace or traceback What is the output of running the following script? >>> print(5*4) - ANSWER20 What are variables? - ANSWERThey refer to values in a memory Which function can be used to convert strings to integers? - ANSWERint() What is the syntax for assigning a variable, x, to the value 8? - ANSWERx = 8 What type of value is returned by the input function? - ANSWERString

Show more Read less
Institution
CMPSC 101
Course
CMPSC 101









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
CMPSC 101
Course
CMPSC 101

Document information

Uploaded on
February 26, 2025
Number of pages
5
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

CMPSC 101 MIDTERM EXAM 1
QUESTIONS & ANSWERS(RATED A+)
What command should you type in the interpreter to check your Python installation?
- ANSWERpython

What do you call a saved file containing Python instructions? - ANSWERA module

How can you write the expression "n = n * 2" using short-hand operators? -
ANSWERn *= 2

Which string function do you call when you want to convert the first letter in the string
to uppercase? - ANSWERstr.capitalize()

Which function do you call to check the number of items in a list? - ANSWERlen()

Which operator is used to concatenate two lists? - ANSWER+ (plus)

Which function do you call when you want to append an element at the end of a list?
- ANSWERlist.append()

What is the name of the output you get when an error occurs in your program? -
ANSWERStack trace or traceback

What is the output of running the following script?
>>> print(5*4) - ANSWER20

What are variables? - ANSWERThey refer to values in a memory

Which function can be used to convert strings to integers? - ANSWERint()

What is the syntax for assigning a variable, x, to the value 8? - ANSWERx = 8

What type of value is returned by the input function? - ANSWERString

How do you write an inline comment in Python? - ANSWER>>>print(ans) # this is
answer

What is the output of the following script?
>>> a, b, c = 1, 2, 3
>>> print(a)
>>> print(b)
>>> print(c) - ANSWER1
2
3

, Which function should you use to convert an integer into a binary number? -
ANSWERbin()


What is the order of operations while evaluating an expression? -
ANSWERPEMDAS

What is the output of the following script?
>>> string = "championship"
>>> print(string[0:5]) - ANSWERchamp

What is the output of the following script?
>>> fruits = ["apples", "bananas", "strawberries", "mangoes", "pears"]
>>>print(fruits[3]) - ANSWERmangoes

How many values do Boolean data types contain? - ANSWER2

Which of the following best describes a software engineering process used by most
successful programmers? - ANSWERDesign a solution carefully; document the
design; then code accordingly

Everyone can figure out that 90 minutes after 2:15 PM is 3:45 PM. We know the
value 45 is correct because - ANSWER(15 + 90) % 60 = 45

The primary difference between / and // in Python 3 is that - ANSWER// always
results in an integer; / may result in fractions or decimals

When is it appropriate to get an input with "int(input___))" instead of merely
"input(___)"? - ANSWERWhen the input should be a number and not a string

To get the first item from a list named 'names', use - ANSWERnames[0]

What would be displayed by the following code sequence?
a = [1, 2, 3]
b =a
a.append(4)
b.append(4)
print(b) - ANSWER[1, 2, 3, 4, 4]

If one wishes to use square brackets to access elements in a dictionary, within the
square brackets one must put - ANSWERa key value to search for

Which of these is not automatically available for lists in Python? -
ANSWERaverage(list) -- compute the average of values

_+1
_+2
_+3
R232,15
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached


Document also available in package deal

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.
papersbyjol West Virginia
Follow You need to be logged in order to follow users or courses
Sold
421
Member since
2 year
Number of followers
253
Documents
13986
Last sold
2 weeks ago

3,8

72 reviews

5
27
4
18
3
17
2
2
1
8

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 exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT 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