Python Ba
Quiz yourself by thinking what should be in
each of the black spaces below before clicking
on it to display the answer.
Help!
|
|
||||
---|---|---|---|---|---|
show | def
🗑
|
||||
show | Static
🗑
|
||||
What is the result of a function that contains no return statement? None Error True 0 | show 🗑
|
||||
show | :
🗑
|
||||
show | lambda
🗑
|
||||
In Python, how do you indicate a function's documentation string? comment """Docstring""" 'docstring' // comment | show 🗑
|
||||
show | global
🗑
|
||||
What happens if you define a function parameter with a default value followed by a non-default parameter? IndexError The function works SyntaxError TypeError | show 🗑
|
||||
What is the correct syntax to define a lambda function that doubles the input x? x * 2 lambda x : x * 2 lambda x: return x * 2 def double(x) : x * 2 | show 🗑
|
||||
show | nonlocal
🗑
|
||||
show | __doc__
🗑
|
||||
show | Arbitrary number of positional arguments
🗑
|
||||
Which of the following best describes a recursive function? A function with many parameters A function that returns multiple values A function that calls itself A function that runs in a loop | show 🗑
|
||||
What must every recursive function include to prevent infinite recursion? Loop Break statement Return Base condition | show 🗑
|
||||
show | map()
🗑
|
||||
Which statement about global variables is true in Python? They must be declared global to modify inside a function They are always modifiable inside functions They are local by default They require no special declaration | show 🗑
|
||||
Which Python module feature helps break large programs into smaller files? Blocks Snippets Packages Modules | show 🗑
|
||||
show | from
🗑
|
||||
show | __init__.py file
🗑
|
||||
show | It pollutes the namespace
🗑
|
||||
for i in range(10): if i == 5: break else: print(i) else: print("Here") | show 🗑
|
||||
for i in range(10): if i == 5: break else: print(i) else: print("Here") | show 🗑
|
||||
x = 'abcd' for i in range(len(x)): i[x].upper() # This line is syntactically incorrect print(x) | show 🗑
|
||||
for i in "abcd"[::-1]: print(i) | show 🗑
|
||||
show | 34
🗑
|
||||
i = 0 while i < 3: print(i) i += 1 else: print(0) | show 🗑
|
||||
show | 4321
🗑
|
||||
show | error
🗑
|
||||
x = 'abcd' for i in range(len(x)): i.upper() print(x) | show 🗑
|
||||
show | Error
🗑
|
||||
x = "abcdef" while i in x: print(i, end="") | show 🗑
|
||||
show | 0 1
🗑
|
||||
show | 0 a 1 b 2 c
🗑
|
||||
show | Error
🗑
|
||||
show | 1 2
🗑
|
||||
show | aaaaaa
🗑
|
||||
show | ABCD
🗑
|
||||
show | [1]
🗑
|
||||
show | Error
🗑
|
||||
Python supports the creation of anonymous functions at runtime, using a construct called __________. anonymous None of the mentioned Lambda pi | show 🗑
|
||||
def say(message, times = 1): print(message * times) say('Hello') say('World', 5) Choices Hello World 5 Hello HelloHelloHelloHelloHello Hello, World,World,World,World,World Hello WorldWorldWorldWorldWorldWorld | show 🗑
|
||||
show | 48
🗑
|
||||
show | 3 2
🗑
|
||||
def hadji(x): print(x + 1) x = -2 x = 4 hadji(12) | show 🗑
|
||||
show | All of the mentioned
🗑
|
||||
def C2F(c): return c * 9 / 5 + 32 print C2F(100) print C2F(0) Choices 212 32 314 24 None of the mentioned 567 98 | show 🗑
|
||||
show | Built-in function
🗑
|
||||
show | Error
🗑
|
||||
def a(b): b = b + [5] c = [1, 2, 3, 4] a(c) print(len(c)) | show 🗑
|
||||
show | 1
🗑
|
||||
show | Def
🗑
|
||||
def maximum(x, y): if x > y: return x elif x == y: return 'The numbers are equal' else: # This implicitly means x < y return y print(maximum(2, 3)) | show 🗑
|
Review the information in the table. When you are ready to quiz yourself you can hide individual columns or the entire table. Then you can click on the empty cells to reveal the answer. Try to recall what will be displayed before clicking the empty cell.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.
Normal Size Small Size show me how
Normal Size Small Size show me how
Created by:
user-1863747