1. Hello Python Flashcards

1
Q

The name Python comes from —- —-

A

Monty Python!

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

a = 3
is an example of —- —–

A

variable assignment

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

Python is different from Java and C++ when it comes to variables in that…

A
  • You don’t need to declare variables before using them
  • You don’t need to tell Python the variable type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you call a function in Python?

Explain through an example

A
  • Function name
  • Brackets
  • Argument(s) within brackets

E.g. print("hello")

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

How do you write comments in Python?

A

By using the # symbol

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

How can you identify a code block within Python?

A
  • Colon at the end of the line (:)
  • Followed by indentation

For example:

if spam_amount > 0:
    print("But I don't want ANY spam!")
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Give an example of operator overloading

A
  • sybmol can be used to multiply two numbers AND can also be used to repeat a string a number of times

viking_song = "Spam " * spam_amount

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

What type of variable is this?
a = 3.5

A

Float

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

How can you find out the type of variable in Python?

A

type(spam_amount)

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

How can I found out the following floor division
10 / 3 = 3
i.e. ignore the fraction of the quotient

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

How can I found it the following modulus
10 / 3 = 1
i.e. integer remainder, after division

A

a % b

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

How can I convert the following…
6.75 -> 6

A

int(6.75)

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

How do you add a cell in notebooks below the current cell?

A

Click in current cell
Hit escape
Type the letter “b”

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