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

COSC 1436 FINAL UPDATED ACTUAL Exam Questions and CORRECT Answers

Rating
-
Sold
-
Pages
73
Grade
A+
Uploaded on
15-12-2024
Written in
2024/2025

COSC 1436 FINAL UPDATED ACTUAL Exam Questions and CORRECT Answers [SHORT ANSWER] Assume the string variables firstName and userID are assigned with values. use string slicing and concatenation to create a username based on the first two letters of the firstName, concatenated with the last four digits of the userID as shown in the example below. For Example: Suppose firstName = "Mary" and userID = "W" then, the username

Show more Read less
Institution
Cosc
Course
Cosc











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

Written for

Institution
Cosc
Course
Cosc

Document information

Uploaded on
December 15, 2024
Number of pages
73
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

COSC 1436 FINAL UPDATED ACTUAL
Exam Questions and CORRECT Answers
[SHORT ANSWER] Assume the string variables firstName and userID are assigned with values.
use string slicing and concatenation to create a username based on the first two letters of the
firstName, concatenated with the last four digits of the userID as shown in the example below.


For Example: Suppose firstName = "Mary" and userID = "W12345678" then, the username
should be:
[SHORT ANSWER] Assume the string variables firstName and userID are assigned with values.
use string slicing and concatenation to create a username based on the first two letters of the
firstName, concatenated with the last four digits of the userID as shown in the example below.


For Example: Suppose firstName = "Mary" and userID = "W12345678" then, the username
should be:


Ma5678 - CORRECT ANSWER - username = firstName[:2] + userID[-4:]


SHORT ANSWER Assume variable gpa has already been assigned a value. Write python code
that displays invalid GPA if the value associated with variable gpa is not in the range [0,4] -
CORRECT ANSWER - if gpa < 0 or gpa > 4:
print("Invalid GPA")


Which type of error prevents the program from running?


human
syntax
grammatical

logical - CORRECT ANSWER - syntax


The smallest storage location in a computer's memory is known as a

,switch
byte
ketter

bit - CORRECT ANSWER - bit


A Python line comment begins with ________.
a. /*
b. $$
c. //

d. # - CORRECT ANSWER - d. #


Which of the following are valid camel case identifier naming styles (Choose all that apply)?
(a) dollar_amount
(b) dollarAmount
(c) dollar$Amount
(d) amtDollar
(e) dollarAmt$
(f) dollarAmt
(g) amountDollar

(h) Dollar_Amount - CORRECT ANSWER - (b) dollarAmount
(d) amtDollar
(f) dollarAmt
(g) amountDollar


Assume the following:


val = 99

,val += 1


Match the code with its output:
a. print('The value is', 'val')
b. print('The value is', val)
print("The value is:", 'val')


The value is val
The value is 100

The value is: val - CORRECT ANSWER - (a) The value is val
(b) The value is 100
(c) The value is: val


Match the relational operators with its meaning:
a. >
b. <
c. >=
d. <=
e. ==

f. != - CORRECT ANSWER - a. Greater than
b. less than
c. Greater than or equal to
d. Less than or equal to
e. Equal to (equality operator)
f. Not equal to


Which of the following will assign a random integer in the range of 1 through 50 to the variable
number?

, (a) number = random(range(1, 50))
(b) random(1, 50) = number
c) number = random.randint(1, 50)

(d) randint(1, 50) = number - CORRECT ANSWER - c) number = random.randint(1, 50)


x < y or z > x What is the result of the following Boolean expression, given that x = 5, y = 3, and
z= 8?


not (x < y or z > x) and y < z


(a) 5
(b) False
(c) 8

(d) True - CORRECT ANSWER - (b) False


What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8?


x < y or z > x


(a) False
(b) 8
(c) True

(d) 5 - CORRECT ANSWER - (c) True


Consider the following statements. If the input is 85, the output of the following code will be:


score=0

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.
MGRADES Stanford University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1123
Member since
2 year
Number of followers
104
Documents
68962
Last sold
5 hours ago
MGRADES (Stanford Top Brains)

Welcome to MGRADES Exams, practices and Study materials Just think of me as the plug you will refer to your friends Me and my team will always make sure you get the best value from the exams markets. I offer the best study and exam materials for a wide range of courses and units. Make your study sessions more efficient and effective. Dive in and discover all you need to excel in your academic journey!

3.8

178 reviews

5
76
4
31
3
47
2
9
1
15

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