Skip to content

Commit 0f4d80b

Browse files
updated
1 parent 9ea6c95 commit 0f4d80b

11 files changed

Lines changed: 231 additions & 0 deletions

File tree

18-for/main.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# for x in range(1, 10):
2+
# print(x)
3+
4+
# print("Done!")
5+
6+
# for x in reversed(range(1, 11)):
7+
# print(x)
8+
9+
# print("Done!")
10+
11+
12+
# for x in range(1, 11,2):
13+
# print(x)
14+
15+
# print("Done!")
16+
17+
# credit_card = '1234-5678-9012-3456'
18+
19+
# for x in credit_card:
20+
# print(x)
21+
22+
for x in range(1,11,1):
23+
if x == 5:
24+
continue
25+
else:
26+
print(x)
27+
print("Done!")
28+

19-timer/main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import time
2+
3+
my_time = int(input("Enter the time in seconds: "))
4+
5+
def timer():
6+
for i in range(my_time, 0, -1):
7+
seconds = i % 60
8+
minutes = i // 60
9+
print(f"{minutes} minutes and {seconds} seconds left")
10+
print(i)
11+
time.sleep(3)
12+
print("Time is up!")
13+
timer()

20-nested-loops/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for x in range(3):
2+
for y in range(3):
3+
print(x, y)

21-lists/main.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
fruits = ["apple", "banana", "cherry", "dragon fruit", "elderberry", "fig", "grape", "honeydew"]
3+
4+
# Print the list
5+
# print(dir(fruits))
6+
# print(help(fruits))
7+
# print(len(fruits))
8+
9+
fruits.append("kiwi")
10+
fruits[0] = "apricot"
11+
fruits.insert(1, "blueberry")
12+
fruits.remove("banana")
13+
fruits = fruits.sort()
14+
for fruit in fruits:
15+
print(fruit)
16+
17+
18+
# Print the list in reverse order

21-sets/main.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
fruits = {"apple", "banana", "cherry", "dragon fruit", "elderberry", "fig", "grape", "honeydew"}
3+
4+
# print(dir(fruits))
5+
6+
for fruit in fruits:
7+
print(fruit)
8+
9+
10+
11+
fruits.add("kiwi")
12+
13+
print(fruits)
14+
15+
fruits.remove("banana")
16+
17+
print(fruits)
18+

22-shopping-cart/main.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
foods: list = []
2+
prices: list = []
3+
total = 0
4+
5+
while True:
6+
food = input("Enter a food item: ")
7+
if food == "q" or food == "quit" or food == "Q" or food == "quit":
8+
break
9+
price = float(input("Enter the price: $ "))
10+
foods.append(food)
11+
prices.append(price)
12+
13+
print("====Pavan's Food Emporium====")
14+
for i in range(len(foods)):
15+
print(f"{i + 1} {foods[i]} ${prices[i]}")
16+
total += prices[i]
17+
18+
print(f"Total: ${total}")

23-2d-collections/main.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
fruits = ["apple", "banana", "cherry"]
2+
vegetables = ["carrot", "lettuce", "onion"]
3+
meats = ["beef", "chicken", "pork"]
4+
5+
# Create a 2D list
6+
7+
food = [fruits, vegetables, meats]
8+
9+
# Access the 2D list
10+
print(food[0][1]) # banana
11+
print(food[1][0]) # carrot
12+
print(food[2][2]) # pork
13+
print(food[1][1]) # lettuce
14+
15+
# Modify the 2D list
16+
17+
food[0][1] = "blueberry"
18+
19+
print(food[0]) # ['apple', 'blueberry', 'cherry']

23-2d-collections/numpad.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
num_pad = (
2+
(7, 8, 9),
3+
(4, 5, 6),
4+
(1, 2, 3),
5+
("*",0,"#")
6+
)
7+
8+
for x in num_pad:
9+
for y in x:
10+
print(y, end=" ")
11+
print()

24-quiz-game/main.py

Whitespace-only changes.

25-tuples/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# create tuple
2+
3+
fruits = ("apple", "banana", "cherry")
4+
5+
print(fruits)
6+
7+
# Access Tuple Items
8+
# You can access tuple items by referring to the index number, inside square brackets:
9+
10+
# Example
11+
# Print the second item in the tuple:
12+
print(fruits[1])

0 commit comments

Comments
 (0)