EXAM PACK
, lOMoARcPSD|21997160
Assessment 1
Question 1
Question text
The command line is used to execute Python code ____ .
a.
each line dynamically
b.
one line at a time
c.
multiple lines simultaneously
d.
multiple lines sequentially
Question 2
Question text
If the data type of a value in a variables does not match the format code,
then ____ will occur.
a.
an exception
b.
an event handler
, lOMoARcPSD|21997160
c.
an auto conversion
d.
an error message
Question 3
Question text
For the provided input, what is the output?
#This is the input
a=int(input('Please enter the number of masks issued to the school : '))
b=int(input('Please enter the number of learners in the school: '))
#this is the processing
thetotal=a//b
theremain=a%b
#this is the output
print('Each learner receives : ', thetotal)
print('The remainder is:', theremain)
a.
Please enter the number of masks issued to the school : 300
Please enter the number of learners in the school: 900
Each learner receives : 0
The remainder is: 300
b.
Please enter the number of masks issued to the school : 300
Please enter the number of learners in the school: 900
Each learner receives : 30
The remainder is: 3
c.
Please enter the number of masks issued to the school : 300
Please enter the number of learners in the school: 900
Downloaded by Thomas Mboya ()
, lOMoARcPSD|21997160
Each learner receives : 3
The remainder is: 0
d.
Please enter the number of masks issued to the school : 300
Please enter the number of learners in the school: 900
Each learner receives : 300
The remainder is: 0
Question 4
Question text
The print() function prints a new line. Which one of the following print()
commands includes characters that will supress the printing of a new line?
a.
print (‘Good luck’, end == ‘ ’ )
b.
print (‘Good luck’, end = ‘ ’ )
c.
print (‘Good luck’, nl/// )
d.
print (‘Good luck’, end )
Question 5
Question text
What is the output from the code executed?
#add 2 numbers and show the result