Quiz
Python Test
Este quiz tem tempo limite, por isso abre no player de sempre.
Perguntas do quiz (22)
1What are the data types in Python ?
- ANumbers, Strings
- BStrings, Integers
- CIntegers, Floats
2When we use input() built-in function what type of variable do we get ?
- AText
- BString
- CNumber
3What is the output of this command:
res = (5 + 6) * 2 + 30 / 3
print(res)- A32.0
- B17.3
- C117.2
4How we can cast or change the type of the number in Python. Let say we have a variable:
number = 55
How we can change it to string variable- Astr = string(number)
- Bstr = str(number)
- Cstr = number
5How we can define a "boolean" variable in Python ?
- Amy_boolean = true
- Bmy_boolean = True
- CBoth are true
6What is the output of this code ?
a = 2
if (a > 4)
print("Yes")
else:
print("No")- AYes
- BNo
- CSyntax Error
7What is the output ?
a = 34
b = 10
if (a % 2 == 0) and (b == 10):
if (a < 50):
print("Inner if")
else:
print("else")- Aelse
- BInner if
- CNo output
8What is the output of this code ?
i = 8
while i < 10:
print(i)
i += 1- AError
- B8
9
10 - C8
9
9What do we need to change in this code in order to make it correct ?
number = input("Input a number between 1-5: ")
while number != 4:
print(number)
number = input("Input a number between 1-5: ")- ANothing
- B"4"
- Cbreak statement
10What is the output of this code ?
for i in range(1,10,2):
print(i)- Anumbers from 1 to 10
- Bnumbers from 1 to 10 except 2
- C1,3,5,7,9
11Can we use break and continue without loops ?
- AVerdadeiro
- BFalso
12What do we need to add instead of the comment in order to print only odd numbers from the range (number which are not divisible by 2)
for i in range(1,10):
if (i % 2 == 0):
#what we need to add here
else:
print(i)- Abreak
- Bcontinue
- Ccode will not work
13We have the following function:
def get_number(number):
print number * 10
Can we call this function in this way ?
get_number()- AVerdadeiro
- BFalso
14How we can return 9 from this function ? (we may have more than one correct answer)
def return_text():
a = 9
return ?- Areturn a
- Breturn 9
- Cwe cannot do that
15What is the output of this code ?
name = "Jack"
def print_name():
name = "David"
#print inside the function
print(name)- AJack
- BDavid
- CDavid and Jack
16Can we change the value of a global variable from inside the function, using a "global" keyword ?
- AVerdadeiro
- BFalso
17What is the output of the following code ?
collection = (1,2,3)
collection[1] = 9
print(collection[1])- A9
- B2
- CError
18Which method can be used to add elements in the list ?
- Aappend()
- Binsert()
- Cextend()
- DAll the above
19Which element is removed from the list ?
my_list = ["bananas", "apple", "orange"]
my_list.pop()- Aapple
- Borange
- Cbananas
20How we can access the second element ?
country = {"Country":"USA", "Capital":"Washington", "Population":"681.170"}- Acountry[1]
- Bcountry[]
- Ccountry["Capital"]
21We have the following dictionary:
dic = {"1":"2", "3":"4", "5":"6"}
Can we do the following ?
dic["1"] = 44- AVerdadeiro
- BFalso
22What does the union() method do wit sets ?
- AGet a union of two sets
- BGet only the elements that the first set has that are not also in the second set.
- CThere is no union() method with sets
Informações
- Descrição
- Technologies Quiz sobre Python Test, criado por wahi narsisian em 19-01-2018.
- Autor
- wahi narsisian
- Idioma
- English
- Visualizações
- 4
- Etiquetas
- Avaliação
- Ainda sem avaliações Avalie este quiz