Fiches de travail Nom
Python
Classe
Nombre total de questions : 20
Durée de la feuille de travail : 10 minutes
Date
Nom de l'instructeur : Fahad Hero
1. What will the output be from the following code?
print("Hello world!\nHello world!")
a) Hello world! b) Hello world!
Hello world!
c) Hello world! Hello world! d) SyntaxError
2. What will the output be from the following code?
print("Hello" + str(2) + "world!")
a) Hello world! Hello world! b) SyntaxError
c) Hello Hello world! world! d) Hello2world!
3. What is syntax?
a) Syntax is the word used to describe an error b) It is used to output information
c) It is used to read information d) Syntax is the rules of the programming
language
4. Code executed based on a condition being true
a) Sequence b) Selection
c) Variable d) Iteration
5. Code repeated / looped until a condition has been met or a set number of times.
a) Selection b) Variable
c) Iteration d) Sequence
6. What does the following code do? myAge = int (myAge)
a) Converts the var (variable) myAge to a integer b) Converts the var (variable) myAge to a string
c) Converts the var (variable) myAge from a d) Converts the var (variable) myAge to if
integer to a string statement
7. What is python named after
a) Television show called Monty Python b) The snake
8. What will the output be from the following code?
print(Hello world!)
a) SyntaxError b) Hello world
c) print(Hello world!) d) Hello world!
9. Decides if a string only contains numbers
a) string() b) isnumeric()
c) isalpha() d) int()
10. Tells the interpreter that the code which follows is a function
a) while b) def
c) int d) const
11. Python identifies blocks of code by
a) BEGIN and END keywords b) aligning up the starts of lines (indentation)
c) guessing d) { and }
12. What does the term 'debug' mean?
a) Identify errors and fix them. b) Making a calculation
c) A set of instructions d) Looking at code
13. What syntax can you use to insert a line break between strings so that they appear over multiple
lines?
a) \n b) /
c) n d) \l
14. What will the output be from the following code?
print("Hello world!" * 2)
a) Hello world! * 2 b) Hello world!Hello world!
c) Hello world world! d) TypeError
15. Joining elements together to make a string is called what?
a) Connecting b) Combining
c) Stringing d) Concatenation
16. Python is an example of a....
a) Text-based programming language b) language written in java script
c) Visual-based programming language d) Object orientated programming language
17. If you want more than one option for your code, what do you use (after if)?
a) elif b) else
c) ifif
18. people = ["John", "Rob", "Bob"]
print (people[1])
what would this result be?
a) John b) Rob
c) Bob
19. people = ["John", "Rob", "Bob"]
print (people[-1])
what would this result be?
a) Rob b) Bob
c) John
20. people = ["John", "Rob", "Bob"]
print (people[4])
what would this result be?
a) John b) Error
c) Rob d) Bob