ECS 10 Lecture 6: If Statements Cont.

48 views1 pages

Document Summary

The def has to be placed to be able to define and run a function. if that does not happen then it is simply regular code that will execute as normal. If statements are used to check a condition and they can be nested within each other. the nesting allows you to check one thing after another, which allows an exponential increase of choices. The line of code will be identified by the indentation of the code itself. An if expression is written a = b if cond else c, which can be written for simple if. A common error is the multiple or error which is when you use multiple signs. Generally the is statement shouldn"t be used in the context of this class. within the single or statement. We wrote a practice program in class, in which we predicted whether or not it would rain. Here is what we wrote: import random def is_raining_today(odds_of_rain):

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents