01. Perform Operations using Data Types and Operators 2 Flashcards

1
Q

Why would you use whitespace in python?

A
  1. Python uses whitespace to create blocks of code.
  2. In other words, it uses whitespace for code suites
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Refer to the code below. What is this an example of?

import math as fun

A

This is an example of using a separate aliased namespace for “math” module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Refer to the code below. Why would you import selectively?

from math import pi, tan

A

It allows you to directly using the functions without the need to add the prefix, i.e. math.pi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

b: use the wildcard import

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In what format does the input function read in user input?

a: String
b: Object
c: Boolean
d: Array

A

a: String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

By default, how many spaces are code suites indented when using the Python IDLE?

a: 5
b: 3
c: 4
d: 2

A

c: 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

d: A blank line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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()

A

c: print()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What data type is now represented by int in Python 3

a: Decimal

b; Float

c: Long
d: Short

A

c: Long

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

a: x = int(y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

a: Boolean Not returns False if the operand is True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What type of class can be used to create special numbers, such as infinity?

A

The float class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which statement will correctly assign x as an infinite number?

a: x = infinity
b: x = int(‘inf)
c: pos_infinity
d: float(‘inf)

A

d: float(‘inf)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Continue from Sequence types

A

Continue from Sequence types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly