List Concatenation
How do you concatenate two lists in Python?
- Using the `append()` method only.
- Using the `join()` method.
- Using the `+` operator or the `extend()` method.
- Using the `concat()` function.
- Using the `add()` method.
Loop Differences
When should you use a 'while' loop instead of a 'for' loop in Python?
- When iterating over a predefined sequence.
- When you only have an end condition and don’t know exactly how many times it will repeat.
- When you want to iterate in reverse order.
- When you know the exact number of iterations.
- while loops aren't usable in python
Floor Function
Which function is used to get the largest integer less than or equal to a given number in Python?
- math.ceiling()
- math.round()
- math.floor()
- math.trunc()
- math.integer()
Division Operators
What is the difference between the `/` and `//` operators in Python?
- / is for integer division, // is for float division
- / returns an integer, // returns a float
- / represents precise division, // represents floor division
- / represents floor division, // represents precise division
- There is no diffrence
Indentation Importance
Is indentation required in Python, and if so, why?
- No, indentation is just for readability.
- Yes, indentation defines code blocks.
- Only for functions, not loops.
- Only for classes, not functions.
- Only for comments
Functions as Arguments
Can a function be passed as an argument to another function in Python?
- No, functions can only return values.
- Yes, because functions are objects.
- Only if the function is defined within the same file.
- Only if the function is a lambda function.
- No, functions can't be arguments
Dynamic Typing
What does it mean for Python to be a dynamically typed language?
- Data types must be declared manually before use.
- Data types are checked at compile time.
- The data type of a variable is determined at runtime.
- Python isn't dynamically typed.
- Data types can never be changed
Pass Statement
What is the purpose of the 'pass' statement in Python?
- To skip to the next iteration of a loop.
- To terminate the program.
- To define an empty function or block.
- To declare a variable.
- To return a value
Argument Passing
How are arguments passed in Python, and is it by value or by reference?
- Always by value.
- Always by reference.
- By object reference, behaving like pass-by-value for immutable objects and pass-by-reference for mutable objects.
- By pointer.
- by copy
Lambda Functions
What is a lambda function in Python?
- A function with a specific name.
- An anonymous function that can have multiple statements.
- An anonymous function that can have any number of parameters, but only one statement.
- A function that only accepts integer arguments.
- A build in function
List Concatenation shorthand
Which of the following operations will result in a new concatenated list?
- list1.extend(list2)
- list1.append(list2)
- list1 = list1 + list2
- list1.concat(list2)
- list1.add(list2)
While Loop Condition
What is the most important consideration when using a 'while' loop to prevent infinite loops?
- Ensuring the loop variable is decremented correctly.
- Ensuring the loop condition eventually becomes false.
- Ensuring the loop contains at least one statement.
- Ensuring the loop variable is properly initialized.
- Ensurring it doesn't repeat more than 10 times
Ceiling Function
Which function will give you the smallest integer greater than or equal to a given number?
- math.floor()
- math.ceil()
- math.round()
- math.truncate()
- math.absolute()
Division by zero
What is the result of dividing a number by zero?
- It returns zero.
- It returns null.
- It raises a ZeroDivisionError.
- It returns infinity.
- It returns 1
Code block indicator
Which character is commonly used to define a code block in Python, often preceding an indented section?
- ; (semicolon)
- : (colon)
- { (curly brace)
- ( (parenthesis)
- [ (square bracket)
Function with arguments
If I want to pass one function to another, what data type would that parameter be?
- A string
- An integer
- A function
- A boolean
- A float
Data Typing
What other languages are similar to Python in that they are dynamically typed?
- Java
- C++
- C
- Javascript
- Cobol
Code placeholder
What is another name for the 'pass' statement?
- A function
- A placeholder
- A variable
- An argument
- A constant
Passing Arguments
Which is not a correct way of passing arguments to a function?
- call by value
- call by reference
- call by object
- call by object reference
- call by named reference
Lambda shorthand
What symbol is used in the definition of the lambda function?
- def
- lambda
- return
- pass
- class