KEMBAR78
Python Quiz 1 (ANS) | PDF | Python (Programming Language) | Computer Science
0% found this document useful (0 votes)
40 views3 pages

Python Quiz 1 (ANS)

Uploaded by

charlottelauyee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views3 pages

Python Quiz 1 (ANS)

Uploaded by

charlottelauyee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Quiz 1 (open-book, you can use computer and paper materials) 7. If you want to display 4.

. If you want to display 4.4 in Python, with which method you CANNOT achieve the
From the options, please choose the best one: goal?
1. When you execute the following code in Python, what will be the result on the A. print (4.4) B. print ("4.4") C. print (8.8/2) D. print ("8.8/2")
screen? 8. Which option cannot correctly display 3.14?
print ("Hello, World!") A. print (3.14) B. print ("3.14") C. print (6.28 / 2) D. print (314 // 100)

A. "Hello, World!" B. Hello, World! C. (Hello, world!) D. ("Hello, World!") 9. Which type of data can be stored and processed using Python?
A. Number B. Boolean C. String D. All of the above
2. If you want to calculate the result of 123+456, what should you execute in Python?
A. print ("123+456") B. print (123+456) C. input ("123+456") D. input (123+456) 10. What function is for transferring data from the user to the computer in Python?
A. print() B. type () C. input () D. if else
3. If you want to type I love you with Python, what can you execute in Python? 11. If you type Harry Potter in the terminal when run following program, what’s the
A. print (I love you) B. print ("I"+ " love", "you") result?
C. print ("I+love+you") D. print (f"[I], [love], [you]") kk = ""
kk = input ("Please enter your name:")
print ("Good morning, " + kk + "!")
4. When you execute the following code in Python, what will be the result on the
A. Good morning, Harry Potter! B. "Good morning, "Harry Potter"!"
screen?
C. "Good morning, Harry Potter!" D. Good morning, + Harry Potter + !
f = "City"
k = "University"
print (f,k) 12. If you want to convert data type from string to number in order to calculate, what
function will help you?
A. "City", "University" B. "City" "University" C. City University D. City+University A. int () B. str () C. type () D. input ()

5. If you set f=1000 and want to know the result of 1000*5, what can you execute in 13. If you are 19 years old and your big brother is 25 years old now, what result do you
Python? get after performing the following program?
A. print ("f * 5") B. print (f * 5) C. print (5f) D. print ("f" * 5) kk = input ("Please enter your age: ")
tt = input ("Please enter your big brother's age: ")
ss = int(tt) - int(kk)
6. What will be the output after executing the following code? print ("So your brother is ", ss, "years older than you.")
x = "Hello" A. "So your brother is 6 years older than you."
y=3
B. So your brother is 6 years older than you.
print(x * y)
C. "So your brother is" 6 "years older than you." D. 6
A. HelloHelloHello B. Hello3 C. Error D. "Hello"*3
14. What will be the output when the following code is executed, if the input is `15`? you!”

age = input ("Enter your age: ")


print ("Your age is:", age + 5) 19. If you do not know the type of a data is a number or a text in Python, which of the
following functions can help you?
A. Your age is: 20 B. Your age is: 155 C. Error D. Your age is: 15 5 A. int () B. str () C. print (type ()) D. input ()
15. Which sign CANNOT be used to make judgments?
A. >= B. <= C. != D. = 20. If you score the service as 68 in this program, what result will you get eventually?
score = input("Please score this service (1-100):")
16. Which symbol is used to check if two values are equal? score = int(score)
if score >= 75:
A. = B. == C. != D. >= print ("A")
else:
if score >= 60:
17. If your name is Ron and you input your name in the terminal when run following print ("B")
program, what result will you get? else:
if score >= 50:
Name = input ("input your name: ") print ("C")
if Name == "Harry" or Name == "harry": else:
print ("Hello, " + Name + "! Please come in.") if score >= 40:
else: print ("D")
print ("Sorry, " + Name + "! I am not waiting for you!") else:
print ("Fail")
A. Hello, Ron! Please come in. B. "Hello, "Ron"! Please come in." A. A B. B C. C D. D
C. Sorry, Ron! I am not waiting for you! D. "Sorry, "Ron"! I am not waiting for you! "
Please fill in:
18. If your name is Hermione and you input your name in the terminal when run 21. what is the result of this block of code: result: 1
2
following program, what result will you get? number = 1
3
Name = input ("input your name: ") while number <= 3:
if Name == "Harry": print(number)
print ("Hello, "+ Name + "! Please come in.") number = number + 1
else:
if Name == "Ron": 5
print ("Hello, " + Name + "! Please wait for a moment.") 7
22. what is the result of this block of code: result:
else: [3, 4, 5]
print ("Sorry, "+ Name + "! I am not waiting for you!") for x in [5,7,[3,4,5],5.6]: 5.6
print(x)

A. Hello, Hermione! Please come in. B. Hello, Hermione! Please wait for a moment.
23. Please complete the following block of code, suppose you are going to define a
C. Sorry, Hermione! I am not waiting for you! D. “Sorry, Hermione! I am not waiting for
function to calculate a certain number’s square, and then use this function.
def sq( aa ):
b=aa*aa
return b

c= sq( 4 ) + sq( 5 ) # calculate 4's square plus 5's square


print(c) # display the result
Student Number: Student Name:
Date:

You might also like