-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathAssingment 5.py
More file actions
69 lines (47 loc) · 1.98 KB
/
Assingment 5.py
File metadata and controls
69 lines (47 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 23 05:12:06 2023
@author: Admin
"""
# Part a: If statement
print ('\n\n', "---------------------Questin 5a-------------------------- ",'\n')
alien_color = 'green'
if alien_color == 'green':
print("Congratulations! You just earned 5 points.")
# part b: Version that fails the if test (no output)
print ('\n\n', "---------------------Questin 5b-------------------------- ",'\n')
if alien_color != 'green':
print("This won't be printed.")
alien_color = 'green'
if alien_color == 'green':
print("Congratulations! You just earned 5 points.")
else:
print("Congratulations! You just earned 10 points.")
# Part c: If-Elif-Else chain
print ('\n\n', "---------------------Questin 5c (green)-------------------------- ",'\n')
alien_color = 'green'
# Version for green alien (prints message for 5 points)
if alien_color == 'green':
print("Congratulations! You just earned 5 points.")
elif alien_color == 'yellow':
print("Congratulations! You just earned 10 points.")
else:
print("Congratulations! You just earned 15 points.")
# Version for yellow alien (prints message for 10 points)
print ('\n\n', "---------------------Questin 5c (yellow)-------------------------- ",'\n')
alien_color = 'yellow'
if alien_color == 'green':
print("Congratulations! You just earned 5 points.")
elif alien_color == 'yellow':
print("Congratulations! You just earned 10 points.")
else:
print("Congratulations! You just earned 15 points.")
# Version for red alien (prints message for 15 points)
print ('\n\n', "---------------------Questin 5c (red)-------------------------- ",'\n')
alien_color = 'red'
if alien_color == 'green':
print("Congratulations! You just earned 5 points.")
elif alien_color == 'yellow':
print("Congratulations! You just earned 10 points.")
else:
print("Congratulations! You just earned 15 points.")