1. What do you call a command-line interpreter which lets you interact with your OS and execute Python commands and scripts?
- An editor
- Jython
- A console
- A compiler
prin("Goodbye!")- The program will generate an error message to the screen
- The program will output ("Goodbye!") to the screen
- The program will output "Goodbye!" to the screen
- The program will output Goodbye! to the screen
print("Hello!")- The program will output Hello! to the screen
- The program will generate an error message to the screen
- The program will output "Hello!" to the screen
- The program will output ("Hello!") to the screen
- It's a programming language that is a superset of the C language, designed to produce Python-like performance with code written in C
- It's the default, reference implementation of the C language, written in Python
- It's a programming language that is a superset of Python, designed to produce C-like performance with code written in Python
- It's the default, reference implementation of Python, written in the C language
I. The code is converted directly into machine code executable by the processor II. It tends to be slower that interpretation III. Both you and the end user must have the compiler to run your code IV. It tends to be faster that interpretation
- I and II
- I and III
- II and III
- I and IV
- any number of arguments (including zero)
- just one argument
- any number of arguments (excluding zero)
- not more than five arguments
2. What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively?
x = input()
y = input()
print(x + y)- 24
- 2
- 4
- 6
y = 2 + 3 * 5.
print(Y)- 25
- the program will generate an error message to the screen
- 17
- 17.0
- does not exist
- performs duplicated multiplication
- performs floating-point multiplication
- performs exponentiation
- its position within the argument list
- its value
- the argument's name specified along with its value
- its connection with existing variables
my_list = [1, 2, 3]
for v in range(len(my_list)):
my_list.insert(1, my_list[v])
print(my_list)- [1, 2, 3, 1, 2, 3]
- [1, 2, 3, 3, 2, 1]
- [3, 2, 1, 1, 2, 3]
- [1, 1, 1, 1, 2, 3]
i = 0
while i <= 5:
i += 1
if i % 2 == 0:
break
print("*")- three
- one
- two
- zero
my_list = [i for i in range(-1, 2)]- four
- one
- two
- three
my_list = [3, 1, -2]
print(my_list[my_list[-1]])- -2
- 3
- 1
- -1
x = 1
x = x == x- False
- 1
- True
- 0
def func(a, b):
return a ** a
print(func(2))- 4
- 2
- None
- error
def func(inp=2, out=3):
return inp * out
print(func(out=2))- 2
- 4
- 6
- error
def decorator(func):
def wrapper():
print("Before function call", end=" >> ")
result = func()
print("After function call", end=" >> ")
return result
return wrapper
@decorator
def say_hello():
print("Hello!", end=" >> ")
say_hello()- Before function call >> Hello!
- Hello! >> Before function call
- Before function call >> Hello! >> After function call >>
- The program will generate an error message to the screen
def func(x):
global y
y = x * x
return y
func(2)
print(y)- 2
- None
- 4
- error
def func(x, y, z):
return x + 2 * y + 3 * z
print(func(0, z=1, y=3))- 3
- error
- 0
- 9
- asyncio.start()
- asyncio.run()
- asyncio.loop()
- asyncio.call()
- By running them on different threads
- By switching between tasks using the event loop
- By running them on multiple CPU cores
- By starting a new event loop for each task
- The coroutine will run twice
- The coroutine will throw a runtime error
- The coroutine will return a coroutine object instead of running
- The coroutine will block the event loop
- def async_function():
- async def async_function():
- def async async_function():
- def async_function async():
- It creates a new event loop for each coroutine
- It ensures coroutines run sequentially
- It schedules multiple coroutines to run concurrently
- It waits for each coroutine to finish before starting the next one