8000 Session 3 · Ricklng/intro-to-python@7e552ea · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e552ea

Browse files
author
Replit user
committed
Session 3
1 parent 5dc8eb3 commit 7e552ea

File tree

2 files changed

+149
-18
lines changed

2 files changed

+149
-18
lines changed

session_01/lesson_1.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
print ("Hello, World!")
1+
# name = "Ada Lovelace!"
2+
# print(len(name))
3+
fullname = "Alan" + "Turing"
4+
length = len(fullname)
5+
middle_letter = fullname[int(length / 2)].lower()
6+
print(middle_letter)

session_03/exercises_3.py

Lines changed: 143 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,72 @@
22

33
## Section A
44
# 1. Ask for the user's name, if they are called "Bob", print "Welcome Bob!".
5-
6-
7-
5+
# name = input("What is your name? ")
6+
# if name == ("Rick") :
7+
# print("Hello Rick")
8+
# print("Welcome to class")
9+
# print( "You are not Rick")
810
# 2. Ask for the user's name, if they are not called "Alice", print "You're not Alice!".
9-
11+
# name = input("What is your name? ")
12+
# if name != ("Alice") :
13+
# print("You are not Alice! ")
14+
# else :
15+
# print("You are Alice!")
1016

1117

1218
# 3. Ask the user for a password, if they enter the password "qwerty123", print "You have successfully logged in".
1319
# If they get it wrong, print "Password failure".
14-
15-
20+
# password = input("Please insert your password ")
21+
# if password == ("qwerty123") :
22+
# print("You have successfully logged in ")
23+
# else :
24+
# print("Password failure ")
1625

1726
# 4. Ask the user to enter a number, if the number is even, print "Even", otherwise print "Odd".
18-
19-
27+
# number = int(input("Please enter a number "))
28+
# result = number%2
29+
# if result == 0 :
30+
# print("The number is even ")
31+
# else:
32+
# print("The number is odd ")
2033

2134
# 5. Ask the user for 2 different numbers, if the total of the two numbers is over 21, print "Bust" otherwise print "Safe"
22-
35+
# number_1 = int(input("Please input number 1 "))
36+
# number_2 = int(input("Please input number 2 "))
37+
# blackjack = number_1 + number_2
38+
# if blackjack > 21 :
39+
# print("Bust")
40+
# else :
41+
# print("Safe")
2342

2443

2544
# 6. Ask the user to enter the length and width of a shape and check if it is a square or not.
45+
# length = int(input("Please input the length of a shape "))
46+
# width = int(input("Please input the width of a shape "))
2647

27-
48+
# if length == width :
49+
# print("The shape is a square ")
50+
# else:
51+
# print("The shape is not a square ")
2852

2953
# 7. You have had a great year and are going to offer a bonus of 10% to any employee who has a service of over 3 years.
3054
# Ask the user to input their current salary and years of service and print out their salary and their bonus or "No bonus" if they are not receiving one.
31-
55+
# years = int(input("How many years have you been with us? "))
56+
# salary = float(input("How much is your current salary? "))
57+
# bonus = 0.1 * salary
58+
# if years > 3 :
59+
# print(0.1 * salary)
60+
# else:
61+
# print("You are not eligible for bonus ")
3262

3363

3464
# 8. Take a whole number input, if it's positive, print out the number cubed, if it is a negative, print out half its value.
35-
65+
# number = int(input("Please input a number "))
66+
# if number >= 0 :
67+
# print (number ** 3)
68+
# else:
69+
# print(number * 0.5)
70+
3671

3772

3873

@@ -42,38 +77,87 @@
4277
# 1. Ask for the user's name, if they are called "Alice" print "Hello, Alice", if they are called "Bob",
4378
# print "You're not Bob! I'm Bob", else print "You must be Charlie".
4479

45-
80+
# name = input("What is your name? ")
81+
# if name == ("Alice"):
82+
# print("Hello Alice! ")
83+
# elif name == ("Bob") :
84+
# print("Hello Bob! ")
85+
# else:
86+
# print("You must be Charlie ")
4687

4788
# 2. Ask the user to enter their age:
4889
# 1. If they are younger than 11, print "You're too young to go to this school"
4990
# 2. If they are between 11 and 16, print "You can can come to this school"
5091
# 3. If they are over 16, print 'You're too old for school"
5192
# 4. If they are 0, print "You're not born yet!"
52-
53-
93+
# age = int(input("How old are you? "))
94+
# if age == 0:
95+
# print("You're not born yet ")
96+
# elif age < 11:
97+
# print("You're too young to go to this school ")
98+
# elif age >= 11 and age <= 16 :
99+
# print("You can come to this school ")
100+
# elif age > 16:
101+
# print("You are too old for school ")
54102

55103
# 3. Ask the user to enter the name of a month. If the user enters March/April/May: print "<month> is in Spring", otherwise print "I don't know".
56104
# 1. Expand for the rest of the year, given that summer is June/July/August. Autumn is September/October/November. Winter is December/January/February.
57105
# 2. Ensure that when an unknown month is given it prints "I don't know".
58-
106+
# month = input(("What month are we in? "))
107+
# if month == ("March") or month == ("April") or month == ("May"):
108+
# print( month + (" is in Spring "))
109+
# if month == ("June") or month == ("July") or month == ("August"):
110+
# print( month + (" is in Summer "))
111+
# elif month == ("September") or month == ("October") or month == ("November"):
112+
# print( month + (" is in Autumn "))
113+
# elif month == ("December") or month == ("January") or month == ("February"):
114+
# print( month + (" is in Winter "))
115+
# else:
116+
# print(" I dont know ")
59117

60118

61119
# 4. Ask the user for two different numbers, if both numbers are even, print "Even", if both numbers are odd, print "Odd", else print the product of the two numbers.
120+
# num1 = int(input("Please input a number: "))
121+
# num2 = int(input("Please input another number: "))
122+
# if num1%2 == 0 and num2%2 == 0:
123+
# print("Even")
8000 124+
# elif num1%2 > 0 and num2%2 > 0:
125+
# print("Odd")
126+
# else :
127+
# print(num1 * num2)
62128

63129

64130

65131
# 5. Ask the user to input two numbers. Decide which is the number of highest value and print this out.
66-
132+
# num1 = int(input("Please input a number: "))
133+
# num2 = int(input("Please input another number: "))
134+
# if num1 > num2 :
135+
# print("The hightest number is " + str(num1))
136+
# else:
137+
# print("The hightest number is " + str(num2))
67138

68139

69140
# 6. You have had a fantastic year and are now going to offer a bonus of 20% to any employee who has a service of over 7 years,
70141
# a bonus of 15% to any employee who has a service of over 5 years and a bonus of 10% to any employee who has a service of 3 - 5 years.
71142
# Ask the user to input their current salary and years of service and print out their salary and their bonus or "No bonus" if they are not receiving one.
143+
# salary = float(input("How much do you earn? "))
144+
# service = int(input("How long have you been with us? "))
145+
# if service >= 3 and service <= 5:
146+
# print("Your salary is " + str(salary)+ " and your bonus is " + str(0.1 * salary))
147+
# elif service > 5 and service <7:
148+
# print("Your salary is " + str(salary)+ " and your bonus is " + str(0.15 * salary))
149+
# elif service >= 7:
150+
# print("Your salary is " + str(salary) + " and your bonus is " + str(0.2 * salary))
151+
# else:
152+
# print ("Since your years of service is less than three, you are ineligible for bonus this year")
72153

73154

74155

75156
# 7. Take the age and name of three people and determine who is the oldest and youngest and print out the name and age of the oldest and youngest.
76157
# If all three ages are the same, print that.
158+
sum = 5 + 6
159+
if sum == 10:
160+
print("the value is 10")
77161

78162

79163

@@ -85,3 +169,45 @@
85169
# e. 25 to 45 – E
86170
# f. Below 25 - F
87171
# Ask user to enter the lesson and the marks for three lessons and print out the corresponding grades for the lesson.
172+
# lesson1 = input("Input name of first lesson: ")
173+
# grade1 = int(input("Input grade of " + lesson1 + ": " ))
174+
# lesson2 = input("Input name of seccond lesson: ")
175+
# grade2 = int(input("Input grade of " + lesson2 + ": " ))
176+
# lesson3 = input("Input name of third lesson: ")
177+
# grade3 = int(input("Input grade of " + lesson3 + ": " ))
178+
# if grade1 < 25:
179+
# print("Grade for " + str(lesson1) + " is F")
180+
# elif grade1 >=25 and grade1 <= 45:
181+
# print("Grade for " + str(lesson1) + " is E")
182+
# elif grade1 >45 and grade1 <= 50:
183+
# print("Grade for " + str(lesson1) + " is D")
184+
# elif grade1 >50 and grade1 <= 60:
185+
# print("Grade for " + str(lesson1) + " is C")
186+
# elif grade1 >60 and grade1 <= 80:
187+
# print("Grade for " + str(lesson1) + " is B")
188+
# else:
189+
# print("Grade for " + str(lesson1) + " is A")
190+
# if grade2 < 25:
191+
# print("Grade for " + str(lesson2) + " is F")
192+
# elif grade2 >=25 and grade2 <= 45:
193+
# print("Grade for " + str(lesson2) + " is E")
194+
# elif grade2 >45 and grade2 <= 50:
195+
# print("Grade for " + str(lesson2) + " is D")
196+
# elif grade2 >50 and grade2 <= 60:
197+
# print("Grade for " + str(lesson2) + " is C")
198+
# elif grade2 >60 and grade2 <= 80:
199+
# print("Grade for " + str(lesson2) + " is B")
200+
# else:
201+
# print("Grade for " + str(lesson2) + " is A")
202+
# if grade3 < 25:
203+
# print("Grade for " + str(lesson3) + " is F")
204+
# elif grade3 >=25 and grade3 <= 45 :
205+
# print("Grade for " + str(lesson3) + " is E")
206+
# elif grade3 >45 and grade3 <= 50:
207+
# print("Grade for " + str(lesson3) + " is D")
208+
# elif grade3 >50 and grade3 <= 60:
209+
# print("Grade for " + str(lesson3) + " is C")
210+
# elif grade3 >60 and grade3 <= 80:
211+
# print("Grade for " + str(lesson3) + " is B")
212+
# else:
213+
# print("Grade for " + str(lesson3) + " is A")

0 commit comments

Comments
 (0)
0