CSE 1010 Lecture Notes - Lecture 8: List Comprehension, 5,6,7,8

31 views3 pages
jadetortoise401 and 55 others unlocked
CSE 1010 Full Course Notes
84
CSE 1010 Full Course Notes
Verified Note
84 documents

Document Summary

Cse notes 10/5/17: an alternative way to make fields. >>> [0 for i in range(4)] #list of four zeros. >>> f = [[0,0,0,0] for i in range(3)] [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]: when using list comprehension, result is list. >>> f = [[0 for i in range(4)] for j in range(3)] #make a list of three lists of four zeros: how to return values and what comes back, example fieldmaker. py def newfield(nrows, ncols): return [[0 for i in range(ncols)] for j in range(nrows)] Will run nine iterations: nested loops, write a python program that prints the following patterns separately one below the other. Use nested for loops to generate the patterns. Gnu nano 2. 2. 6 file: exl. py for i in range(10): for j in range(i+1): print("*", end=" ") print() for i in range(10): print("*" * (i+1): example 2.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers