Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

17. What will be displayed by the following code? Print("A", end = ' ') Print("B", end = ' ')

AB

1.11 Computer can execute the code in ____________. A. machine language B. assembly language C. high-level language D. none of the above

a

2.1 What function do you use to read a string? A. input("Enter a string") B. eval(input("Enter a string")) C. enter("Enter a string") D. eval(enter("Enter a string"))

a

3.2 What is min(3, 5, 1, 7, 4)? A. 1 B. 3 C. 5 D. 7 E. 4

a

3.28 To format a number x to 3 digits after the decimal point, use _______. A. format(x, "5.3f") B. format("5.3f", x) C. format(x, "5.4f") D. format("5.3f", x)

a

4.27 What will be displayed by the following code? ch = 'F' if ch >= 'A' and ch <= 'Z': print(ch) A. F B. f C. nothing D. F f

a

7.2 _______ is a template, blueprint, or contract that defines objects of the same type. A. A class B. An object C. A method D. A data field

a

1.17 ________ is an object-oriented programming language. A. Java B. C++ C. C D. C# E. Python

abde

(2**3***2)evaluates to. A. 36 B. 18 C. 12 D. 81

b

1.4 Why do computers use zeros and ones? A. because combinations of zeros and ones can represent any numbers and characters. B. because digital devices have two stable states and it is natural to use one state for 0 and the other for 1. C. because binary numbers are simplest. D. because binary numbers are the bases upon which all other number systems are built.

b

2.23 2 ** 3 evaluates to __________. A. 9 B. 8 C. 9.0 D. 8.0

b

2.3 If you enter 1 2 3 in three separate lines, when you run this program, what will be displayed? print( "Enter three numbers: " ) numbēr = eval(input()) numbér = eval(input()) numběr = eval(input()) # Compute average average = (numbēr + numbér + numběr) / 3 # Display result print(average) A. 1.0 B. 2.0 C. 3.0 D. 4.0

b

3.29 Suppose x is 345.3546, what is format(x, "10.3f")? (note b represents a blank space) A. bb345.355 B. bbb345.355 C. bbbb345.355 D. bbb345.354 E. bbbb345.354

b

4.1 The "less than or equal to" comparison operator is __________. A. < B. <= C. =< D. << E. !=

b

4.30 What will be displayed by the following code? isCorrect = False print("Correct" if isCorrect else "Incorrect") A. Correct B. Incorrect C. nothing D. Correct Incorrect

b

4.8 What is the output of the following code? x = 0 if x < 4: x = x + 1 print("x is", x) A. x is 0 B. x is 1 C. x is 2 D. x is 3 E. x is 4

b

5.12 The following loop displays _______________. for i in range(1, 11): print(i, end = " ") A. 1 2 3 4 5 6 7 8 9 B. 1 2 3 4 5 6 7 8 9 10 C. 1 2 3 4 5 D. 1 3 5 7 9 E. 2 4 6 8 10

b

6.11 Given the following function def nPrint(message, n): while n > 0: print(message) n -= 1 What will be displayed by the call nPrint('a', 4)? A. aaaaa B. aaaa C. aaa D. invalid call E. infinite loop

b

6.15 When you invoke a function with a parameter, the value of the argument is passed to the parameter. This is referred to as _________. A. function invocation B. pass by value C. pass by reference D. pass by name

b

6.2 The header of a function consists of ____________. A. function name B. function name and parameter list C. parameter list

b

7.1 __________ represents an entity in the real world that can be distinctly identified. A. A class B. An object C. A method D. A data field

b

7.3 An object is an instance of a __________. A. program B. class C. method D. data

b

8.12 Given a string s = "Welcome", what is s.count('e')? A. 1 B. 2 C. 3 D. 4

b

8.4 What is "Programming is fun"[4: 6]? A. ram B. ra C. r D. pr E. pro

b

5.9 Which of the following function returns a sequence 0, 1, 2, 3? A. range(0, 3) B. range(0, 4) C. range(3) D. range(4)

bd

2.9 Which of the following is a valid identifier? A. $343 B. final1 C. 9X D. 8mile E.___max_radius F. mile 1 G. MILE

befg

1.23 A Python line comment begins with ________. A. // B. /* C. # D. $$

c

1.25 A ___________ error does not cause the program to abort, but produces incorrect results. A. syntax B. runtime C. logic

c

3.31 What will be displayed by the following code? ? (note ? represents a blank space) print(format("Welcome", ">10s"), end = '#') print(format(111, "<4d"), end = '#') print(format(924.656, ">10.2f")) A. ???Welcome#?111#924.66 B. ???Welcome#?111#????924.66 C. ???Welcome#111?#????924.66 D. Welcome???#111?#????924.66

c

4.13 The following code displays ___________. temperature = 50 if temperature >= 100: print("too hot") elif temperature <= 40: print("too cold") else: print("just right") A. too hot B. too cold C. just right D. too hot too cold just right

c

4.2 The equal comparison operator is __________. A. <> B. != C. == D. =

c

4.9 Suppose isPrime is a boolean variable, which of the following is the correct and best statement for testing if isPrime is true. A. if isPrime = True: B. if isPrime == True: C. if isPrime: D. if not isPrime = False: E. if not isPrime == False:

c

5.1 How many times will the following code print "Welcome to Python"? count = 0 while count < 10: print("Welcome to Python") count += 1 A. 8 B. 9 C. 10 D. 11 E. 0

c

7.4 The keyword __________ is required to define a class. A. def B. return C. class D. All of the above.

c

8.3 What is min("Programming is fun")? A. P B. r C. a blank space character D. u E. n

c

2.12 What will be displayed by the following code? x = 1 x = 2 * x + 1 print(x) A. 0 B. 1 C. 2 D. 3 E. 4

d

2.13 What will be displayed by the following code? x = 1 x = x + 2.5 print(x) A. 1 B. 2 C. 3 D. 3.5 E. The statements are illegal

d

2.14 What will be displayed by the following code? x, y = 1, 2 x, y = y, x print(x, y) A. 1 1 B. 2 2 C. 1 2 D. 2 1

d

2.22 24 % 5 is _____ A. 1 B. 2 C. 3 D. 4 E. 0

d

2.24 2 ** 3.0 evaluates to __________. A. 9 B. 8 C. 9.0 D. 8.0

d

2.29 What is the result of evaluating 2 + 2 ** 3 / 2? A. 4 B. 6 C. 4.0 D. 6.0

d

2.39 Which of the following functions return 4. A. int(3.4) B. int(3.9) C. round(3.4) D. round(3.9)

d

3.1 What is max(3, 5, 1, 7, 4)? A. 1 B. 3 C. 5 D. 7 E. 4

d

3.30 What will be displayed by the following code? ? (note ? represents a blank space) print(format("Welcome", "10s"), end = '#') print(format(111, "4d"), end = '#') print(format(924.656, "3.2f")) A. ???Welcome#?111#924.66 B. Welcome#111#924.66 C. Welcome#111#.66 D. Welcome???#?111#924.66

d

4.14 Analyze the following code: Code 1: if number % 2 == 0: even = True else: even = False Code 2: even = number % 2 == 0 A. Code 1 has compile errors. B. Code 2 has compile errors. C. Both Code 1 and Code 2 have compile errors. D. Both Code 1 and Code 2 are correct, but Code 2 is better.

d

6.24 What will be displayed by the following code? def f1(x = 1, y = 2): x = x + y y += 1 print(x, y) f1(2, 1) A. 1 3 B. 2 3 C. The program has a runtime error because x and y are not defined. D. 3 2 E. 3 3

d

8.1 What is len("Good")? A. 1 B. 2 C. 3 D. 4 E. -1

d

8.13 Given a string s = "Programming is fun", what is s.find('ram')? A. 1 B. 2 C. 3 D. 4 E. -1

d

8.2 What is max("Programming is fun")? A. P B. r C. a blank space character D. u E. n

d

8.5 What is "Programming is fun"[-1]? A. Pr B. P C. fun D. n E. un

d

8.6 What is "Programming is fun"[1:1]? A. P B. r C. Pr D. '' E. incorrect expression

d

1.7 A computer?s _______ is volatile; that is, any information stored in it is lost when the system?s power is turned off. A. floppy disk B. hard disk C. flash stick D. CD-ROM E. memory

e

2.21 25 % 1 is _____ A. 1 B. 2 C. 3 D. 4 E. 0

e

5.4 How many times will the following code print "Welcome to Python"? count = 0 while count < 10: print("Welcome to Python") A. 8 B. 9 C. 10 D. 11 E. infinite number of times

e

8.14 Given a string s = "Programming is fun", what is s.find('rom')? A. 1 B. 2 C. 3 D. 4 E. -1

e

8.7 What is "Programming is fun"[-3:-1]? A. Pr B. P C. fun D. n E. un

e


संबंधित स्टडी सेट्स

Lesson 18: Personality Disorders Multiple Choice

View Set

Unit 4: Medical Language; Urology, Male Reproductive System, & Gynecology and Obstetrics

View Set

personality psych exam 1 (ch 1-4, 6, 7)

View Set

Global Perspectives Checkpoint #1

View Set

COMPTIA A+ 220-1001: LAPTOPS FEATURES AND MOBILE DEVICE TYPES

View Set