-
Notifications
You must be signed in to change notification settings - Fork 0
Week 1 03 25
fengttt edited this page Mar 25, 2020
·
1 revision
- Create project and a directory
- First program, hello world
- if/elif/else, while/for/break/continue
- A guess game
- Modify guess.py, to guess a number in range 1-100
- Modify guess.py, to limit the number of guess to 10. If you guess the right number within 10 tries, print "You Win", otherwise, print "You Lose".
- You should ALWAYS win. If you change the range to 1-1000, will you ALWAYS win?
- Adding a new function to toy.py
def sumodd(n):
''' Return sum of the first n odd numbers.'''
# Your code here.
- import toy, then run sumodd. What is the result of sumodd(1)? 2? 3? 100? 200?
- Adding a new function to toy.py
def gcd(a, b):
''' Return the greatest common divisor of a and b '''
- What is gcd(123456789, 987654321)?