What is rapid prototyping?
You see where syntax errors are, tells you what's wrong with it, etc...
Can you have an "else" statement without the initial "if" statement?
NOPE!!
It's called "if/else" for a reason :P
For an AND statement...how many need to be "True?"
For an OR statement...how many need to be "True?"
AND --> BOTH
OR --> JUST ONE
For an AND statement... how many have to be "True?"
BOTH
What are the two outputs of Booleans?
True/False
= is used for __________
== is used for __________
Variable assignments
Mathematical Operations
What is the output of this statement?
a = 128
b = 87
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")
b is not greater than a
Will this code execute? Is it a syntax error? Why or why not?
a = 35
b = 35
if a > 20 or b < 40:
print("Hornets!!")
Think like a computer... An OR statement needs one condition to be true.
a is 35, which is greater than 20, so yeah it'll execute right there.
It will not even check on b cause there's just no need
Let's pretend x = 52.86 and I cast it as an integer.
How is the computer going to interpret it?
52
Recall that an integer doesn't know what decimals are
What is the output of this code? (Think booleans!!)
print(10 > 9)
print(10 == 9)
print(10 < 9)
True
False
False
What is an indentation? How do we type it on our keyboards?
Indentations used in several statements to tell the computer who belongs to who.
We type it with the TAB key.
Is the "if" statement going to be executed or is the "else" statement going to be executed?
a = 200
b = 33
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")
ELSE!
Will this code execute? Is it a syntax error? Why or why not?
a = 35
b = 71
if a > 20 and b < 40:
print("Hornets!!")
It's not a syntax error.
Buuutttt because both conditions are not satisfied, "Hornets!!" will never display.
Let's pretend x = 8 and i cast it as a float.
How is the computer going to interpret it??
8.0
Recall that a float MUST have decimals.
x = 19
y = 35
print(x > y)
FALSE
Python is pretty cool, let's be honest.
List as many concepts (that we've gone over) as you can.
If/Else
Type Casting
Booleans
Rapid Prototyping
AND
OR
NOT
How could I use an If statement to see if a number is positive?
number = something
if number > 0:
print('Number is positive.')
Will this code execute?
a = 15
b = 34
if a > 20 or b < 40:
print("Hornets!!")
You bet it will. a is not greater than 20 BUT IT'S FINE because b is less than 40.
Why do we use data types?
To only allow certain inputs. There cannot be a 13th month or a 35th day when creating an account, for instance.
Additionally, it helps keep your code neat and proper, as well as optimizing its performance.
x = 17
y = 92
print(x > 12 and y < 100)
TRUE
Who invented Python and when?
It was created by Guido van Rossum, and released in 1991.
How do we use an if/else statement to determine if a number is positive, negative, or zero?
number = something
if number > 0:
print("Positive number")
else if number == 0:
print('Zero')
else if :
print('Negative number')
Will this code execute? Why or why not?
x = 5
y = 7
z = 10
if x < 8 or y < 5 and z > 2:
print("Go Hornets!!")
WOOAAHH we're mixing and as well as or. Check it out:
The first expression (x < 8 or y < 5) is TRUE because x is indeed less than 8.
The second expression (z > 2) is also TRUE because z is indeed greater than 2.
So. What happens when you put two TRUE statements in and AND statement?
If i have a complex number like 236.882 and I cast it as an integer... what is happening to the lost data?
It's be TRUNCATED
Examine this code. What is it doing?
>>> import datetime
>>> def before_noon():
... return datetime.datetime.now().hour < 12
...
>>> def greet():
... if before_noon:
... print("Good morning!")
... else:
... print("Good evening!")
...
>>> greet()
Good morning!
>>> datetime.datetime.now().hour
20
Right so it's importing a database called datetime to allow the script to read our computer's internal clock.
Once it does that, it will either tell us good morning or good evening based upon the results.
We will get into creating functions at a later date.