Cs5001 cs5003 intensive foundations of computer science
Pdf File 888.02 KByte, 35 Pages
Lecture 5: Dictionaries and Recursion
CS5001 / CS5003: Intensive Foundations of Computer Science
PDF of this presentation
1
Lecture 5: Practice!
Let's practice a few topics that I think some students are still unclear about: Looping a certain number of times Printing a comma-separated list without the last comma Breaking out of a while True loop
Practice 1: Write a loop to print a string, s, X times (once per line), where X is the length of the string. E.g., if the string is "bats":
bats bats bats bats
2
Lecture 5: Practice!
Let's practice a few topics that I think some students are still unclear about:
Looping a certain number of times Printing a comma-separated list without the last comma Breaking out of a while True loop
Practice 1: Write a loop to print a string, s, X times (once per line), where X is the length of the string. E.g., if the string is "bats":
bats
# solution for i in range(len(s)):
print(s)
bats
bats
bats
3
Lecture 5: Practice!
Let's practice a few topics that I think some students are still unclear about: Looping a certain number of times Printing a comma-separated list without the last comma Breaking out of a while True loop
Practice 2: print a list, lst, one value at a time and comma separated, without the last comma.
4
Lecture 5: Practice!
Let's practice a few topics that I think some students are still unclear about:
Looping a certain number of times Printing a comma-separated list without the last comma Breaking out of a while True loop
Practice 2: print a list, lst, one value at a time and comma separated, without the last comma.
# solution #1 lst = ['cat', 'dog', 'bat', 'rat']
for i, val in enumerate(lst): if i == len(lst) - 1: print(val) else: print(f"{val}, ", end='')
# solution #3 lst = ['cat', 'dog', 'bat', 'rat']
print(', '.join(lst))
# solution #2 lst = ['cat', 'dog', 'bat', 'rat']
for v in lst[:-1]: print(f"{v}, ", end='') print(lst[-1])
5
Lecture 5: Practice!
Let's practice a few topics that I think some students are still unclear about: Looping a certain number of times Printing a comma-separated list without the last comma Breaking out of a while True loop
Practice 3: Print random numbers between 0 and 99 until two numbers in a row are 90 or above
6
- handbook of theoretical computer science ebook
- cs 341 foundations of computer science ii prof marvin
- foundations of computer science
- undergraduate computer science education in china
- foundations of data science
- department of computer science college of engineering and
- computer science systems bachelor of science in
- computer science graduate programs in computer
- cs 182 foundations of computer science syllabus
- eecs 376 foundations of computer science
- computer science standards of learning vdoe
- department of computer science undergraduate handbook
- cs5001 cs5003 intensive foundations of computer
- cs5001 cs5003 intensive foundations of computer science
- there are 10mm in 1cm primary resources
- sanco 10619 2009 en rev 1 european parliament
- project management
- vehicle stolen police recovery how mopar evts
- profitstar profitability profitstar suite and