Back to notes
What is the output of the following code? ```python a = 7 > 3 print(a) ```
Press to flip
True
What Python data type would be used for representing a number with both real and imaginary parts?
complex
What is the result of the following string operation in Python? ```python print("Hello" * 5) ```
'HelloHelloHelloHelloHello'
What will be the output of the following code? ```python s = "Programming" print(s[0:5]) ```
'Progr'
How would you print the number `8` stored in a variable `a`?
print(a)
What operator is used to concatenate strings in Python?
The `+` operator.
Define and print a complex number with a real part 1 and imaginary part 3.
`c = 1 + 3j print(c) # Output: 1+3j`
What is the output of `int(5.88)` in Python?
5 (removes decimal, does not round)
Show a code example of step slicing to print every second character in the string 'Programming'.
`s = "Programming" print(s[0:10:2]) # Output: 'Pormn'`
Describe what the following code does: ```python word1 = "Machine" word2 = "Learning" print(word1 + " " + word2) ```
Concatenates the strings 'Machine' and 'Learning' with a space in between, resulting in 'Machine Learning'
Write a Python code snippet that converts a floating-point number `x = 2.3` into an integer.
y = int(x)
How would you convert an integer `x = 10` to a floating point number in Python?
y = float(x)
What does the `bool` type represent in Python?
The `bool` type represents True or False.
How do you check the data type of a variable `a` in Python?
type(a)
Identify the data type: `my_string = "Machine Learning"`
str
Previous
Next