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 2 CORRECT 100%

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

The Range(1,10,3) produces the values A. 1,4,7,10 B. 1,4,7 C. 1,3,5,7,9 D. 1,10,3 - ANSWERB. 1,4,7 How many asterisks would be printed by these two code fragments? A. 12 in both cases B. 6 in both cases C. 12 in the one on the left; 6 in the one of the right D. 6 in the one on the left; 4 in the one on the right - ANSWERC. 12 in the one on the left; 6 in the one of the right If is_prime is a function that identifies whether its argument was prime, what would this short function return? A. The value 2 only B. The value 7 only C. All of the small primes in a list: [2,3,5,7] D. One small prime, and a different one each time it is called. - ANSWERA. The value 2 only I wish to catch invalid input values outside the range of 1 to 5, inclusive. The test to identify a bad input would be: A. value < 1 and value > 5 B. value < 1 or value > 5 C. 1 > value > 5

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
2
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

  • cmpsc 101 stuvia 2025

Content preview

CMPSC 101 MIDTERM 2 CORRECT
100%
The Range(1,10,3) produces the values

A. 1,4,7,10
B. 1,4,7
C. 1,3,5,7,9
D. 1,10,3 - ANSWERB. 1,4,7

How many asterisks would be printed by these two code fragments?

A. 12 in both cases
B. 6 in both cases
C. 12 in the one on the left; 6 in the one of the right
D. 6 in the one on the left; 4 in the one on the right - ANSWERC. 12 in the one on
the left; 6 in the one of the right

If is_prime is a function that identifies whether its argument was prime, what would
this short function return?

A. The value 2 only
B. The value 7 only
C. All of the small primes in a list: [2,3,5,7]
D. One small prime, and a different one each time it is called. - ANSWERA. The
value 2 only


I wish to catch invalid input values outside the range of 1 to 5, inclusive. The test to
identify a bad input would be:

A. value < 1 and value > 5
B. value < 1 or value > 5
C. 1 > value > 5
D. value < 1 and > 5 - ANSWERB. value < 1 or value > 5

A series of inputs will arrive at the keyboard, ending with an empty line. Assuming all
of these inputs are whole numbers, compute their sum. - ANSWERtotal = 0
line = input()
while line != '':
total = total + int(total)
line = input()

Given a list of integers in nums display the first value greater than 60 and its position
in that list. - ANSWERposition = 0
while nums[position] <= 60:
position = position + 1

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
View profile
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 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