Mod 2 Flashcards

1
Q

What is the output of:
print(“The itsy bitsy spider climbed up the waterspout.”)
print()
print(“Down came the rain and washed the spider out.”)

A

The itsy bitsy spider climbed up the waterspout.

Down came the rain and washed the spider out.

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

What is the output of:
print(“The itsy bitsy spider\nclimbed up the waterspout.”)
print()
print(“Down came the rain\nand washed the spider out.”)

A

The itsy bitsy spider
climbed up the waterspout.

Down came the rain
and washed the spider out.

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

How do you print one backslash?

A

print(“\”)

this will return an error: print(“")

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

What is the output of:

print(“The itsy bitsy spider” , “climbed up” , “the waterspout.”)

A

The itsy bitsy spider climbed up the waterspout.

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

What is the output of:
print(“My name is”, “Python.”, end=” “)
print(“Monty Python.”)

A

My name is Python. Monty Python.

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

What is the output of:
print(“My name is”, “Python.”, end=”\n”)
print(“Monty Python.”)

A

My name is Python.

Monty Python.

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

What is the output of:
print(“My name is “, end=””)
print(“Monty Python.”)

A

My name is Monty Python.

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

What is the output of:

print(“My”, “name”, “is”, “Monty”, “Python.”, sep=””)

A

MynameisMontyPython.

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

What is the output of:
print(“My”, “name”, “is”, sep=”_”, end=””)
print(“Monty”, “Python.”, sep=”
”, end=”*\n”)

A

My_name_isMontyPython.*

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

What are Literals and what are the two types?

A

String and integer number. A literal is data whose values are determined by the literal itself

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

Two ways of writing 11 million

A

11000000 or 11_000_000 (anything else is prohibited)

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

Example of an octal number and how to convert it

Example of an hexadecimal number and how to convert it.

A

0o123 or 0O123, print(0o123)

0x123 or 0X123, print(0x123)

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

Write the “to the power of 10” expression to output 1 million

A

1E6 or 1e6

1 is the base, 6 is the exponent

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

How to print(2):

I like “Monty Python”

A
print('I like "Monty Python"') 
#OR 
print("I like \"Monty Python\"")
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
what are the outputs:
print(6 / 3)
print(6 / 3.)
print(6. / 3)
print(6. / 3.)
A
  1. 0
  2. 0
  3. 0
  4. 0
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
What are the outputs:
print(6 // 3)
print(6 // 3.)
print(6. // 3)
print(6. // 3.)
A

2

  1. 0
  2. 0
  3. 0
17
Q

What are the outputs?
print(-6 // 4)
print(6. // -4)

A
  • 2

- 2.0

18
Q

What are the outputs:
print(16 % 3)
print(3 % 16)

A

1

3

19
Q

Does exponentiation use right or left sided binding?

A

right

20
Q

Rules of naming a variable(4):

A
  1. A variable name is limited to upper-case letters, lower-case letters, digits, or underscores (_)
  2. The name of the variable must begin with a letter. The underscore character is a letter.
  3. Variables are case sensitive
  4. The name of the variable must not be a keyword
21
Q

What is the result of the input() function?

A

A string. In order to do math must make it into a integer or float.

22
Q

What does + do to strings?

What does * do to a string and number?

A

Concatenate and Replicate

23
Q

What does the str() function do?

A

Converts a number into a string