1/71
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
The pass statement generates an error when executed.
False
Which of the following is NOT a logical operator in Python? If, or, and, not?
If
An if statement requires at least one statement in its body.
True
Is there a limit on the number of elif statements that can be used in a chained conditional?
No Limit
The expression "if a and b:" checks if both a and b are True.
True
The "else" statement can exist without a preceding "if" statement.
False
In a chained conditional, what happens if no condition is true and there is no else clause?
Nothing happens, the program continues to the next statement
The condition in an if-else statement must evaluate to either true or false.
True
If all conditions in a chained conditional are false and there is an else clause, the else clause will execute.
True
Where must the else clause be placed in a chained conditional?
At the end
What does the expression x is y check for in Python?
If x is the same as y
What happens if more than one condition is true in a chained conditional?
Only the first true branch executes
What condition determines whether x is even?
x % 2 == 0
What will be the output of the following code?
x = 5
if x > 0:
—-) print (‘Positive’)
Positive
The elif statement can be used without a preceding if statement.
False
What does "elif" stand for in Python?
Else If
Given x = 1 and y = 2, what is the value of not (x > y)?
True
What does the “not” operator do?
It makes the Boolean give the opposite True/False Signal
What is the key difference between = and == in Python?
= is used for assignment, while == is used for comparison
Which of the following is NOT a valid comparison operator in Python? =, <=, >= or ! =?
=
There is a limit on the number of statements that can appear in the body of an if statement.
False
The boolean expression after the if statement is called the condition.
True
The expression x > 0 and x < 10 is true when:
x is both greater than 0 and less than 10
What will be the output of the following code if x = 5 and y = 10?
x is less than y
What will happen when the following code is executed if phone_balance is 3 and bank_balance is 50?
phone_balance will be 13 and bank_balance will be reduced by 10
An else clause is required in every chained conditional
Fasle
x = y
What does the operator != check for?
If two values are not equal
What character must end the if statement header line?
Colon (:)
Which operator is used to check if two values are equal in Python?
==
In a chained conditional, the conditions are checked from top to bottom in the order they appear
True
Which of the following is a text data type in Python? Bool, Int, Str or Float
Str
Hello John
['John', 'Harv', 'Union']
3
Given the variable x = ("apple", "banana", "cherry")
, what is the data type of x
Tuple
True
1
Value: 3.33, Type: Float
A variable name must start with a
Letter or Underscore character
Given the variable x = ["apple", "banana", "cherry"]
, what is the data type of x
List
6
HELLO,JOHN!
Variables that are created outside of a function are known as
Global Variables
Which of the following statements about tuples in Python is true?
Tuple items are indexed, starting with index 0 for the first item.
3345
8
apple
True
If you create a variable with the same name inside a function, this variable will be:
Local Variable
25Tiger
Which of the following data types is used to represent True or False values in Python? List, Int, Bool or Str?
Bool
Variable names are case-sensitive.
True
False
Which of the following is a numeric data type in Python? Range, Tuple, List or Float?
Float
8
33Tiger
What will happen if you define a function with the same name twice in Python?
The second function definition will overwrite the first one.
Which of the following best describes a function parameter?
It terminates the function, It defines the name of the function,
It provides a value for the function to process, or It returns a value from the function?
It provides a value for the function to process.
It provides a value for the function to process. def myFunc():, func myFunc():, def myFunc;, function myFunc():?
def myFunc():
Which of the following statements is true about Python functions?
Function names cannot start with an underscore _ , A function must always have at least one argument, Functions cannot call themselves, or A function can return multiple values?
A function can return multiple values.
What will be the result of bool(1)
in Python?
True
What is the Boolean result of 5 > 3 and 10 < 20?
True
What is a correct Python List method used to return the number of elements in a list?
len()
Which of the following is not a valid function call in Python? myFunc[10, 20]
,
myFunc("hello") , myFunc() , myFunc(10, 20)
myFunc[10, 20]
Which statement is used to exit a function and return a value?
return
What is the return type of a function that does not return any value?
none
What is the purpose of the type
keyword in Python?
It returns the data type of a given variable or value.
Which of the following statements will evaluate to False
? bool(0), bool([]), bool(““) or all the above?
All of the above
What is the correct keyword for defining functions in Python?
def
Which of the following represents the Boolean values in Python?
1,0
True, False
true, false
1,0 and True, False
What is recursion in functions?
A function that calls itself
Which of the following is not a valid Boolean expression in Python?
5 == 5
5 === 5
True and False
10 <= 20
5 === 5