Class Notes (1,049,829)
US (413,393)
UC-Davis (8,848)
ECS (242)
ECS 32A (28)
tba (14)
Lecture 16

ECS 32A Lecture 16: Function StubsPremium

2 pages78 viewsWinter 2019

Department
Engineering: Computer Science
Course Code
ECS 32A
Professor
tba
Lecture
16

This preview shows half of the first page. to view the full 2 pages of the document.
2/11/19
Control Statement Review
“Pass” statement just goes through the loop and does nothing
If char.isdigit():
Pass
If the condition is satisfied, and runs the pass statement which just continues on with the
program
For loops
sequence = []
for item in sequence: # for each item
pass
or
for integer in range(0): # counts integers
pass
Functions Review
def example_function(param1, param2):
temp_var = param1 * param2
return temp_var
arg1 = 2
Arg2 = 8
Output = example_function(arg1, arg2)
print(output)
We can also put branches in functions
def is_deci(s):
If 0” <= s <= 9” or s == .:
Return True
Return False
User_input = input(Enter a string: )
We can also put loops in functions
def get_lengths(list_of_strings):
Dict_of_lengths = {}
For string in list_of_strings:
Dict_of_lengths[string] = len(string)
Return dict_of_lengths
How big should functions get?
A function is like a paragraph of text
A module is like 1-3 pages
You're Reading a Preview

Unlock to view full version

Subscribers Only

Loved by over 2.2 million students

Over 90% improved by at least one letter grade.