General Flashcards
Is it possible to assign a maximum or minimum value to a variable in python.
Yes, python has the concept of positive and negative infinity which is of type float.
What is a bitwise operation?
A bitwise operation is a logical operation performed on individual bits where 0 represents false and 1 represents true.
A bitwise ‘&’ operation tends to drop bits
A bitwise ‘|’ operation tends to add the bit together
What is binary? how does it work?
The binary number system is the base two representation of numbers using only 0s and 1s.
In python the prefix 0b is used to indicate that what follows is a binary number.
0b0101 is 5
What is floor division and what is the result of performing this operation?
floor division is just like regular division except the result is always an integer. It is important to note that the decimal portion of the result is NOT rounded, it is simply discarded.
What are the main types in python?
string, integer, float, boolean and None
Is there an increment and decrement operator in python?
Yes it is the ‘+= ‘ and ‘-=’.
Many C-style programming languages use ‘++’ and ‘–’ this does not exist in python.
Is python statically or dynamically typed?
What does this mean?
python is dynamically typed, which means you can assign any type to a variable, more IMPORTANT this also means that you can change the type of the variable after its assignment.
This in NOT recommended however.
How do we assign a multi-line string?
By using “”” (triple quotes).
If a multi-line string isn’t assigned a variable or used in an expression it is treated as a comment.
Is type hinting enforced by python?
The python interepter does not enforce types. Python is dynamically typed therefore type hinting only allows the user of the code to see the expected types.
Getting basic user input?
To capture user input into a variable assign the input function to a variable. The input function takes a prompt as an argument.
favorite_fruit = input(“What is your favorite fruit? “)