General Flashcards

1
Q

Is it possible to assign a maximum or minimum value to a variable in python.

A

Yes, python has the concept of positive and negative infinity which is of type float.

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

What is a bitwise operation?

A

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

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

What is binary? how does it work?

A

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

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

What is floor division and what is the result of performing this operation?

A

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.

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

What are the main types in python?

A

string, integer, float, boolean and None

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

Is there an increment and decrement operator in python?

A

Yes it is the ‘+= ‘ and ‘-=’.
Many C-style programming languages use ‘++’ and ‘–’ this does not exist in python.

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

Is python statically or dynamically typed?
What does this mean?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do we assign a multi-line string?

A

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.

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

Is type hinting enforced by python?

A

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.

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

Getting basic user input?

A

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? “)

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