Skip to content

Commit 9ea6c95

Browse files
updated
1 parent 268daa7 commit 9ea6c95

27 files changed

Lines changed: 337 additions & 0 deletions

File tree

1-print/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
print("I like pizza !")
2+
print("It's my favorite food !")
3+
# this is my first python program

10-temp/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
unit = input("Enter the unit of temperature (F/C): ")
2+
temp = float(input("Enter the temperature: "))
3+
if unit == "F":
4+
temp = round(((temp - 32) * 5) / 9)
5+
print(f'The temperature in Fahrenheit is, {temp} {unit}')
6+
elif unit == "C":
7+
temp = round(((temp * 9 ) / 5) + 32)
8+
print(f'The temperature in Celsius is, {temp} {unit}')

11-logical/main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
temp = float(input("What is the temperature outside? "))
2+
is_sunny = True
3+
4+
if temp > 20 and is_sunny:
5+
print("Don't forget your sunscreen!")
6+
elif temp <= 20 and is_sunny:
7+
print("Wear a hat!")
8+
elif temp > 20 and not is_sunny:
9+
print("Take an umbrella!")
10+
else:
11+
print("Stay home!")

12-conditional/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
num = 5
2+
a = 6
3+
b = 7
4+
5+
max_num = a if a > b else b
6+
print(f'maximum number: {max_num}')
7+
min_num = a if a < b else b
8+
print(f'minimum number: {min_num}')

13-string/main.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name = input("Enter your name: ")
2+
3+
print("Hello, " + name + "!")
4+
5+
len = len(name)
6+
7+
print("Your name has " + str(len) + " characters.")
8+
9+
result = name.upper()
10+
11+
print("Your name in uppercase: " + result)
12+
13+
result = name.lower()
14+
15+
print("Your name in lowercase: " + result)
16+
17+
result = name.title()
18+
19+
print("Your name in titlecase: " + result)
20+
21+
22+
find_p = name.find("P")
23+
24+
print("The position of the letter 'P': " + str(find_p))
25+
26+
#result = name.isdigit()
27+
28+
result = name.isnumeric()
29+
30+
31+
print("Is your name a number? " + str(result))

14-index/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
credit_card = '4111123456781234'
2+
3+
print(credit_card[0:4])

15-format/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
price1 = 3.234443
2+
price2 = 4.234443
3+
price3 = 5.234443
4+
price4 = 1234567.234443
5+
6+
print(f'Price 1: $ {price1:.2f}')
7+
print(f'Price 1 - right justified: $ {price1:>10}')
8+
print(f'Price 1 - left justified: $ {price1:<10}')
9+
10+
print(f'Price 1 - left justified: $ {price4: ,}')
11+
12+
print(f'Price 1 - left justified: $ {price4: ,.2f}')

16-while/age.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
age = int(input("Enter your age: "))
2+
3+
while age < 18:
4+
print("You are a minor")
5+
age = int(input("Enter your age: "))

16-while/food.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
food = input("What is your favorite food? ")
2+
3+
while food != "q":
4+
print("You like", food, "?")
5+
food = input("What is your favorite food? ")
6+
7+
print("you are quitting the while loop!")

16-while/num.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
num = input("Enter a number between 1 and 10: ")
3+
4+
while int(num) < 1 or int(num) > 10:
5+
print("You must enter a number between 1 and 10")
6+
num = input("Enter a number between 1 and 10: ")
7+
8+
print("You entered", num)

0 commit comments

Comments
 (0)