Professional Documents
Culture Documents
ipynb - Colaboratory
You have been asked to create a program with the following functions:
Ask user for their lottery ticket number. If the input matches the winning number, 8918354118, then print a message, “Congratulations,
you are the winner!”
If the input does not match the winning number, then print, “Sorry, you are not the winner.”
Print “Thank you for using my system!” to all users.
Ask Professor to enter a score between 0 and 100. If the score is out of range, print an error message. If the score is between 0 and 100, print a
grade using the following table:
if >=90: A
if >=80: B
if >=70: C
if <70: F
1 # Using for loop to count the number of items in a list: [3, 41, 12, 9, 74, 15]
2 count = 0
3 for itervar in [3, 41, 12, 9, 74, 15]:
4 count = count + 1
5 print('Count: ', count)
Count: 6
1 # Using for loop to compute the sum of all numbers in the list
2 mysum = 0
3 for itervar in [3, 41, 12, 9, 74, 15]:
4 mysum = mysum + itervar
5 print("Sum is : ", mysum)
Sum is : 154
1 # Functions
2 def is_even( i):
3 """
4 Input: i, a positive int
5 Returns True if i is even, otherwise False
https://colab.research.google.com/drive/1VluN0xmP5qa2hKpsn885ieMBJNN665qI#scrollTo=tUKq3zz3LeDW&printMode=true 1/2
12/09/2023, 20:16 BANA200Week2.ipynb - Colaboratory
6 """
7 print("This is an even number?")
8 return i%2 == 0
9
10
11 x=3
12 is_even(x)
13
https://colab.research.google.com/drive/1VluN0xmP5qa2hKpsn885ieMBJNN665qI#scrollTo=tUKq3zz3LeDW&printMode=true 2/2