01. Perform Operations using Data Types and Operators 2 Flashcards
Why would you use whitespace in python?
- Python uses whitespace to create blocks of code.
- In other words, it uses whitespace for code suites
Refer to the code below. What is this an example of?
import math as fun
This is an example of using a separate aliased namespace for “math” module
Refer to the code below. Why would you import selectively?
from math import pi, tan
It allows you to directly using the functions without the need to add the prefix, i.e. math.pi
What action should be avoided so that you do not mistakenly overwrite names that you have already defined?
a: Use aliases when importing
b: use the wildcard import
c: Import selective objects
d: Import selectively with aliases
b: use the wildcard import
In what format does the input function read in user input?
a: String
b: Object
c: Boolean
d: Array
a: String
By default, how many spaces are code suites indented when using the Python IDLE?
a: 5
b: 3
c: 4
d: 2
c: 4
When using the Python shell and a code block, what triggers the interpreter to begin evaluating the block of code?
a: The execute command
b: The semi-colon symbol
c: The closed parenthesis
d: A blank line
d: A blank line
What command is used to output text from both the Python shell and within a Python module?
a: count()
b: OutputStream()
c: print()
d: System.out.println()
c: print()
What data type is now represented by int in Python 3
a: Decimal
b; Float
c: Long
d: Short
c: Long
Which of the following will not result in declaring x a data type of float?
a: x = int(y)
b: x = float(10)
c: float.fromhex(“A”)
x = 5.
a: x = int(y)
Which statement accurately describe the bool class?
a: Boolean Not returns False if the operand is True
b: Boolean Or returns the first False or the last True value
c: Zero values are considered True
d: The bool class is a subclass of the array class
a: Boolean Not returns False if the operand is True
What type of class can be used to create special numbers, such as infinity?
The float class
Which statement will correctly assign x as an infinite number?
a: x = infinity
b: x = int(‘inf)
c: pos_infinity
d: float(‘inf)
d: float(‘inf)
Continue from Sequence types
Continue from Sequence types