CSC 127A Lecture Notes - Lecture 6: Redundant Code

13 views2 pages

Document Summary

Monday is labor day, don"t come to class. Mix the following ingredients in a bowl: When confronted with a redundant code, look to see if a variable or a constant would work. For the following code, a line or box function would be best. It makes it reusable, if you come back in 6 months to your code and wanted to add new lines, all you have to do is change the functions. N represents a parameter, or simply a placeholder. A value passed to a funtion by its caller. () for expression, add what you want for code in the above line. Example: it passes the expression into the parameter: say_password(42) say_password(12345) A parameter in loops: a parameter can guide the number of repetitions of a loop. For i in range(0, times): this starts at 0 and chant is 3. 3 lines as opposed to starting at 1. I. e. (1, 3) would only print out 2 lines.

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

Related Documents