Python In General
If/Else
AND/OR Statements
Data Types
Booleans
100

What is rapid prototyping?

You see where syntax errors are, tells you what's wrong with it, etc...

100

Can you have an "else" statement without the initial "if" statement?

NOPE!!


It's called "if/else" for a reason :P

100

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

100

For an AND statement... how many have to be "True?"

BOTH

100

What are the two outputs of Booleans?

True/False

200

= is used for __________

== is used for __________

Variable assignments

Mathematical Operations

200

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

200

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

200

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

200

What is the output of this code? (Think booleans!!)

print(10 > 9)

print(10 == 9)

print(10 < 9)


True

False

False

300

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.

300

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!

300

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.

300

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.

300

x = 19

y = 35


print(x > y)

FALSE

400

Python is pretty cool, let's be honest.

List as many concepts (that we've gone over) as you can.

Print

If/Else

Type Casting

Booleans

Rapid Prototyping

AND

OR

NOT

400

How could I use an If statement to see if a number is positive?

number = something

if number > 0:    

print('Number is positive.')

400

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.

400

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.

400

x = 17

y = 92

print(x > 12 and y < 100)

TRUE

500

Who invented Python and when?

It was created by Guido van Rossum, and released in 1991.

500

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')

500

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?

500

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

500

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.