CSE 1010 Lecture 7: While Loop, For Loop, Range

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

Document Summary

An if statement has a condition, a consequent, and an alternate if condition: consequent : else: Alternate if condition1: consequent1 elif condition 2: consequent 2: else: A while loop has a condition and a body while condition: While n < 5: if n %2 ==0 this means divide by two and return the remainder else : n=n+1 print( program finished") This will print out in the program : Number guessing import random num = random. randint(1,10) guess = 0 while guess !=num: guess = int(input( guess a number from 1 to 10")) if guess < num: elif guess > num: print(n, is odd") print( too low") print( too high") print( correct!") A slice is a sublist that can contain 0 or more of the elements from some other list. >>> squares[1:3] this goes up to but not including the last index. A list can contain values of different types. >>> y = [ year", 2017] string and number.

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

Related Questions