0% found this document useful (0 votes)
15 views3 pages

Python Programming Quiz Questions

The document contains a series of multiple-choice, fill-in-the-blank, and coding questions related to computer science and programming concepts, particularly focusing on Python. It covers topics such as data types, control structures, operators, and error types. The document is structured into three parts: multiple choice questions, fill-in-the-blank questions, and coding questions requiring Python statements.

Uploaded by

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

Python Programming Quiz Questions

The document contains a series of multiple-choice, fill-in-the-blank, and coding questions related to computer science and programming concepts, particularly focusing on Python. It covers topics such as data types, control structures, operators, and error types. The document is structured into three parts: multiple choice questions, fill-in-the-blank questions, and coding questions requiring Python statements.

Uploaded by

alper26onder
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Page 1

PART A: [ ] Storage
MULTIPLE CHOICE (Mark only one choice) [X] All the above

QA1) Computational problem solving involves QA8) A storage device is volatile if,
the following except [X] It loses its contents when the power if off
[ ] representation [ ] It does not lose its contents when the power is
[ ] algorithm off
[X] compilation [ ] Its contents cannot be changed
[ ] Its contents can be changed
QA2) What is wrong with this Python loop:
n = 5 QA9) A definite loop is one
while n > 0:
print(n) [ ] That never terminates
print('All done') [X] For which the number of iterations is known
[X] This loop will run forever in advance
[ ] There should be no colon on the while [ ] For which the number of iterations is not
statement known in advance
[ ] The print('All done') statement should be [ ] Executes at least once
indented four spaces
[ ] while is not a Python reserved word QA10) In operator precedence, the smallest order
is given to
QA3) Which of the followings are all input [ ] Arithmetic operators
devices? [ ] Relational operators
[X] Mouse, touchscreen, keyboard, microphone [X] Boolean operators
[ ] Mouse, printer, keyboard, speakers [ ] None of the above
[ ] Monitor, printer, mouse, microphone
[ ] Microphone, mouse, keyboard, speakers QA11) In Python, structural program blocks are
identified by
QA4) Which of the followings are all output [ ] begin - end headers
devices? [ ] left - right braces
[ ] Mouse, touchscreen, printer, keyboard [X] Indentation
[X] Touchscreen, speakers, monitor, printer [ ] All of the above
[ ] USB flashdisk, monitor, keyboard, mouse
[ ] Touchscreen, monitor, printer, mouse, QA12) A while statement is a
[ ] Selective structure
QA5) Which of the followings are all non-
[ ] Sequential structure
volatile devices?
[ ] Multiway structure
[ ] RAM, harddisk, USB-flash-disk, CD-R disk.
[X] Iterative structure
[X] USB-flash-disk, harddisk, Solid-State-drive
[ ] USB-flash-disk, RAM, Solid-State-drive
QA13) Which of the following items is an
[ ] USB-flash-disk, harddisk, RAM
example of dynamic variable typing:
QA6) Which among the following has highest [ ] after assigning i=10, print(i) displays it,
speed? [X] after assigning i=10, i=i/2 makes it integer.
[X] CPU [X] after assigning i=10, i=i/4 makes it float.
[ ] Main memory [ ] all of the above items
[ ] Input/output devices
[ ] All have same speed QA14) Which of the following items is an
example of symantic error?
QA7) What are the basic operations which are [ ] print('Square of', N, 'is', N*N )
performed by a computer? [X] print('Cube of', N, 'is', N*3 )
[ ] Arithmetic operation [ ] print['Square of', N, 'is', N**2 ]
[ ] Logical operation [ ] print('Sum of', N, and, M 'is', N+M )
Page 2

PART B: FILL IN BLANKS QUESTIONS


QB13) Python input function returns a ??? .
Write answers only into the answering box. Answer ???:
string
QB1) 10010 is a binary number. Its value in the
QB14) The ??? function is used to determine
decimal system is ???.
Answer ???:
whether a string contains a substring.
18 Answer ???:
in
QB2) An ??? is a combination of values,
QB15) A string consisting of only a pair of
variables, and operators.
Answer ???:
matching quotes with nothing in between is
expression called the ???.
expression Answer ???:

QB3) The ??? statement is used for decision empty string


making.
QB16) The ??? function gives the character for a
Answer ???:
if, control, selection
if , control given encoding value.
Answer ???:

QB4) ??? allows sections of code to be executed chr or format


repeatedly under some condition.
Answer ???:
looping, while, iteration
PART C: CODING QUESTIONS
QB5) Given that 30/7=4.28571428, Write answers only into the answering box.
print(format(30/7, '.1f')) displays ???
Answer ???: QC1) Write a Python statement to print the
4.3 following mathematical expression.
QB6) print( not 5>4 or 3!=2 and -2<1) 𝑦1.4
𝐷= 3 −2
displays ??? 𝑟 𝑧
Answer ???: Answer:
D=3*y**1.4/(r*z)-2
True or D=3*y**1.4/r/z-2
QB7) print( (3 + 2 * 7)//5 ) displays ??? QC2) The following program is prepared to
Answer ???:
3 compute the factorial
N! =N(N-1)(N-2) ... 2˟1,
QB8) String is a sequence of ??? where N is a nonnegative integer number that
Answer ???:
is entered from the keyboard. What should be
characterscharacters appropriate Python statements that fill the
QB9) The process of identifying and removing empty lines for correct calculation.
logical errors and runtime errors is called ??? Num= int(input(
Answer ???: “Enter a nonnegative integer number”))
debugging if Num==0 or Num==1:
Fact=1
QB10) ??? errors are not indicated by interpreter. else:
Fact=Num
Answer ???: while Num >=2:
semantic,
logical and semantic logical ?a?
?b?
QB11) The Boolean (logical) operators in Python print(Fact)
Answer ?a?:
are ?a?, ?b?, and ?c?. Num=Num-1 or Fact=Fact*(Num-1)
Answer ?a?:
and Answer ?b?:
Fact=Fact*Num or Num=Num-1
Answer ?b?:

or QC3) Write the Python expression to find out the


Answer ?c?:
not value of the ten's-digit of a non-negative
number N.
QB12) Python programming language is ??? For example ten's-digit of N=234 is 3.
sensitive. Answer :
Answer ???: Num//10%10 or Num%100//10
case int(str(Num)[-2]) is also possible
Page 3

QC4) Write the value of expression in the box: QC9) Canceled because of a typing mistake.
1 != 2 and 3 < 4 or False
Answer ?a?:
True QC10) The following program is prepared to
check if a positive integer number Num is
QC5) Evaluate the expression, write answer in equal to sum cubes of its digits. For example,
the answering box: 153 = 33 + 53 +13. Fill in
5 + 4 ** 2 % 3 - 1 ?a? to get the last digit of N,
Answer :
5 ?b? to add cube of lastdig on Sum, and
?c? to remove the last digit of N while N>0.
QC6) A store sells video-games for 8 tl each, and
gives a 15% discount if the cost of the Num= int(input(
“Enter a nonnegative integer number”)
purchased quantity is more than 60. The Sum=0
following Python program is prepared to N=Num
while N>0:
compute cost according to purchased quantity. lastdig = ?a?
It asks first for the quantity, and prints the total ?b?
cost for the user including the discount. N=?c?
if Sum==Num:
Fill the missing parts of the statements to print(Num,
perform the required task. “is a digits cube sum number.”)
else:
quantity = int(input( print(Num,
'Enter quantity: ')) “is not a digits cube sum.”)
if ?a? :
print("Cost is", ?b? ) Answer ?a?:
else: N % 10
print("Cost is ", quantity*8)
Answer ?b?:
Answer ?a?:
quantity*8>60
Sum = Sum+lastdig**3
quantity*8>60 Answer ?c?:
quantity*8*(1-0.15)
Answer ?a?: N = N // 10
quantity*8*(1–0.15)
int(str(Num)[:-1]) is also possible
QC7) The following program is prepared to
check if a positive integer number that is input
from the keyboard is prime or not. Note that a
prime number is one that is evenly divisible by
1 and itself only. Fill in the missing ?a? and
?b? to make the program run correctly.
Num= int(input(
“Enter a nonnegative integer number”)
Div=2
Flag=True
while Flag and Div < Num:
if ?a? :
Flag=False
Div =Div+1
İf ?b?
print(Num, “is Prime”)
else:
print(Num, “is not Prime”)
Answer ?a?:
Num % Div == 0
Answer ?b?:
Flag==True:
QC8) Write the Python expression to calculate
the following mathematical expression in
terms of variables b, c, D, and x.
𝑥−1
𝐷=
𝑏𝐷+𝑐
Answer:
D=(x-1)/(b*D+c)

You might also like