Skip to content

Commit 67807d2

Browse files
authored
Added 8 Python projects
1 parent ccf527e commit 67807d2

8 files changed

Lines changed: 158 additions & 0 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name = input("enter your name:")
2+
print("your nickname is", name.capitalize())
3+
username = input("enter your username:")
4+
print("your username is", username.capitalize())
5+
number = input("enter your number:")
6+
7+
number = number
8+
nickname = name.capitalize()
9+
username = username.capitalize()
10+
11+
12+
def hello(nickname, username):
13+
print("hello world".capitalize()) # перетворюємо рядок на великі літери
14+
print(f"Hi, {nickname} {username}")
15+
16+
17+
hello(nickname, username)
18+
19+
print('your number is', number)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
choice = input("Enter your choice (додати, відняти, помножити, поділити): ")
2+
number1 = float(input("Enter first number: "))
3+
number2 = float(input("Enter second number: "))
4+
5+
if choice == "додати":
6+
result = number1 + number2
7+
print("Сума:", result)
8+
9+
elif choice == "відняти":
10+
result = number1 - number2
11+
print("Різниця:", result)
12+
13+
elif choice == "помножити":
14+
result = number1 * number2
15+
print("Множення:", result)
16+
17+
elif choice == "поділити":
18+
if number2 == 0:
19+
print("На 0 не ділиться!")
20+
else:
21+
result = number1 / number2
22+
print("Ділення:", result)
23+
24+
else:
25+
print("Невірний вибір!")
26+
27+
if 'result' in locals():
28+
print("Результат:", result)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
list = [1, "Vasya", float(50.5), True, None]
2+
del list[2]
3+
print(list)
4+
list.reverse()
5+
print(list)
6+
print(len(list))
7+
list2 = ["Misha", float(11.1)]
8+
print(list + list2)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
list = [1, "Vasya", float(50.5), True, None]
2+
list2 = ["Misha", float(11.1)]
3+
print(list.__add__(list2))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
journal = {
2+
'price': 2500,
3+
'brand': 'Aplle',
4+
}
5+
print("choose your option:")
6+
choice = input("enter your choice:")
7+
print(journal[choice])
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
num = {8, 10, 15, 18, 19, 33}
2+
num.add(16)
3+
num2 = {1, 8, 11, 18}
4+
numeric = num.intersection(num2)
5+
linst = list(numeric)
6+
7+
print(numeric)
8+
print(linst)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
x = 7
2+
if x > 0:
3+
print("good")
4+
5+
6+
age = 16
7+
if age <= 18:
8+
print("you baned")
9+
else:
10+
print("you are not baned")
11+
12+
13+
grade = 90
14+
if grade >= 90:
15+
print('good')
16+
elif 70 <= grade <= 90:
17+
print('normal')
18+
else:
19+
print('bad')
20+
21+
names = ['Bohdan', 'Anna', 'Luca']
22+
for name in names:
23+
print(name)
24+
25+
y = 1
26+
while y <= 5:
27+
print(y)
28+
y += 1
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
players = [
2+
{'name': 'Cristiano Ronaldo', 'position': 'Forward',
3+
'jersey': 10, 'goals': 25, 'assists': 18},
4+
{'name': 'Kevin De Bruyne', 'position': 'Midfielder',
5+
'jersey': 17, 'goals': 10, 'assists': 22},
6+
{'name': 'Virgil van Dijk', 'position': 'Defender',
7+
'jersey': 4, 'goals': 3, 'assists': 2},
8+
{'name': 'Thibaut Courtois', 'position': 'Goalkeeper',
9+
'jersey': 1, 'goals': 0, 'assists': 0}
10+
]
11+
12+
positions = {player['position'] for player in players}
13+
print(positions)
14+
15+
for player in players:
16+
if player['name'] == 'Cristiano Ronaldo':
17+
player['goals'] = 69
18+
player['assists'] = 30
19+
20+
print(players)
21+
22+
statistic_goal = []
23+
for player in players:
24+
statistic_goal.append(player['goals'])
25+
26+
statistic_assists = []
27+
for player in players:
28+
statistic_assists.append(player['assists'])
29+
30+
print(statistic_goal + statistic_assists)
31+
32+
avarage_goal = sum(statistic_goal) / len(statistic_goal)
33+
avarage_assists = sum(statistic_assists) / len(statistic_assists)
34+
35+
print(avarage_goal)
36+
print(avarage_assists)
37+
38+
39+
def add_player():
40+
name = input("Введіть ім'я гравця: ")
41+
position = input("Введіть позицію гравця: ")
42+
jersey = int(input("Введіть номер на футболці: "))
43+
goals = int(input("Введіть кількість голів: "))
44+
assists = int(input("Введіть кількість асистів: "))
45+
46+
player = {
47+
'name': name,
48+
'position': position,
49+
'jersey': jersey,
50+
'goals': goals,
51+
'assists': assists
52+
}
53+
players.append(player)
54+
55+
56+
add_player()
57+
print(players)

0 commit comments

Comments
 (0)