M03 - Decision Statements Flashcards

1
Q

Input Function Syntax

A

input(“Gather some input”)

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

Input Function defaults to:

A

String

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

Convert input to 1. integer; 2. float syntax

A
  1. int(input(“Gettin that input”))

2.
float(input(“Gettin that input”))

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

If syntax

A

if condition :

(tab) statement1
(tab) statement2
(tab) etc.

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

3 general rules when using “If” statements

A
  1. Begins with “if” followed by condition that will be evaluated as True or False
  2. Next line is a block of statements. These MUST be consistently indented. It is REQUIRED or won’t be executed
  3. If the condition is determined “False” then the statements are skipped
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

if-else statement

A

Used when we need an outcome for both True AND False conditions

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

if-else syntax

A

if condition :

(tab) trueStatement1
(tab) etc.

else :

(tab) falseStatement1
(tab) etc.

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

2 general rules for if-else statements

A
  1. Make sure that if statement and else statement are aligned
  2. Make sure the statements under if and else statements are consistently indented
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

if-elif-else syntax

A

if condition :
(tab) statement

elif condition :
(tab) statement
.......................................
else :
(tab) statement

*NOTE: if, elif, and else are all equally indented

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