Python Functions Flashcards

1
Q

What is an if statement?

A

An if statement allows a program to carry out different actions depending on the nature of the data to be processed

An if statement is like a fork in the road. Depending upon a decision, different parts of the program are executed.

Ex:

temperature has a value of 88

if temperature > 90:
print(“It is”)
else:
print(“It is not”)
print (“a hot day.”)

Prints:
It is not
a hot day.

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