1. Hello Python Flashcards
The name Python comes from —- —-
Monty Python!
a = 3
is an example of —- —–
variable assignment
Python is different from Java and C++ when it comes to variables in that…
- You don’t need to declare variables before using them
- You don’t need to tell Python the variable type
How do you call a function in Python?
Explain through an example
- Function name
- Brackets
- Argument(s) within brackets
E.g. print("hello")
How do you write comments in Python?
By using the # symbol
How can you identify a code block within Python?
- Colon at the end of the line (:)
- Followed by indentation
For example:
if spam_amount > 0: print("But I don't want ANY spam!")
Give an example of operator overloading
- 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
What type of variable is this?a = 3.5
Float
How can you find out the type of variable in Python?
type(spam_amount)
How can I found out the following floor division
10 / 3 = 3
i.e. ignore the fraction of the quotient
a // b
How can I found it the following modulus
10 / 3 = 1
i.e. integer remainder, after division
a % b
How can I convert the following…
6.75 -> 6
int(6.75)
How do you add a cell in notebooks below the current cell?
Click in current cell
Hit escape
Type the letter “b”