λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°

University of California, Berkeley/ElectricalEngineering & ComputerSciences

Control

Control

Print and None

print and None

None Indicates that Nothing is Returned

-      The special value None represents nothing in Python

-      A function that does not explicitly return a value will return None

-      Careful : None is not displayed by the interpreter as the value of an expression

python codes ex. def does_not_return_square(x):

                                  x*x

does_not_return_square(4) à None

Pure Functions & Non-Pure functions

Pure Functions : just return values _ argument -> return value

Non-Pure Functions : have side effects (ex) print _ -2 -> None : return None but python displays the output “-2”, A side effect isn’t a value; it’s anything that happens as a consequence of calling a function

Nested Expressions with Print

print vs return

Control

-      Expressions in programs evaluated to values

-      Statements are executed to perform actions

Ex : assignment and def statements

-      With what we have seen so far, a lot of useful programs have been left out

-      For example : returning ‘hot, ‘warm’ or ‘cold’ depending on an argument temp

-      To do this we introduce the concept of control

Conditional statements ( if statements )

Syntax : Always start with if clause, Zero or more elif clauses, Zero or one else clause always at the end

Execution Rule for Conditional Statements :

Each header is considered in order

 

Summary

-      print vs None

: None represents when an expressions doesn't evaluate to a value

: print displays values in the interpreter

-      Control

: Allow for the interpreter to selectively or repetitively execute parts of a program

-      Iteration

: A particular variant of control which is based in the idea of repeating operations to compute a value

'University of California, Berkeley > ElectricalEngineering & ComputerSciences' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

Environment Diagrams  (0) 2019.06.28
LAB_day 1  (0) 2019.06.27
DISC  (0) 2019.06.27
Functions  (0) 2019.06.26
Intro  (0) 2019.06.25