aboutsummaryrefslogtreecommitdiff
path: root/Python/Beginner training
diff options
context:
space:
mode:
authorSyndamia <kami02882@gmail.com>2019-06-30 15:05:38 +0300
committerSyndamia <kami02882@gmail.com>2019-06-30 15:05:38 +0300
commita0addea2b7bbdac244420ec917c0f3c14c4c8831 (patch)
treea05310b0033f995dfd31b5795e7675aa382a18f3 /Python/Beginner training
parent0c7164435abda2e497957e195e6653f94f20135d (diff)
downloadSelf-learning-a0addea2b7bbdac244420ec917c0f3c14c4c8831.tar
Self-learning-a0addea2b7bbdac244420ec917c0f3c14c4c8831.tar.gz
Self-learning-a0addea2b7bbdac244420ec917c0f3c14c4c8831.zip
Added some of the stuff I have done while learning Python
Diffstat (limited to 'Python/Beginner training')
-rw-r--r--Python/Beginner training/001 GoSkiing.py12
-rw-r--r--Python/Beginner training/002 Pets.py18
-rw-r--r--Python/Beginner training/003 Hotel.py31
-rw-r--r--Python/Beginner training/004 TakingCare.py15
-rw-r--r--Python/Beginner training/011 FitnessEquipment.py16
-rw-r--r--Python/Beginner training/012 FitnessVisitors.py25
-rw-r--r--Python/Beginner training/Basic synthax.py5
-rw-r--r--Python/Beginner training/Random.py67
8 files changed, 189 insertions, 0 deletions
diff --git a/Python/Beginner training/001 GoSkiing.py b/Python/Beginner training/001 GoSkiing.py
new file mode 100644
index 0000000..28f6f33
--- /dev/null
+++ b/Python/Beginner training/001 GoSkiing.py
@@ -0,0 +1,12 @@
+import sys
+import os
+
+skier_n = int(input('Type number of skiers: '))
+jacket_n_per_person = int(input('Type number of jackets per person: '))
+helmet_n_per_person = int(input('Type number of helmets per person: '))
+shoe_set_n_per_person = int(input('Type number of shoes per person: '))
+
+total_per_person = (jacket_n_per_person * 120) + (helmet_n_per_person * 75) + (shoe_set_n_per_person * 299.9)
+total_price = total_per_person * skier_n
+
+print('Total price for all skiers: ', round(total_price + total_price * 0.2, 2)) \ No newline at end of file
diff --git a/Python/Beginner training/002 Pets.py b/Python/Beginner training/002 Pets.py
new file mode 100644
index 0000000..bdc5a3b
--- /dev/null
+++ b/Python/Beginner training/002 Pets.py
@@ -0,0 +1,18 @@
+import sys
+import os
+import math
+
+days_absent = int(input('Type the number of days that you wil be absent: '))
+left_food_kg = float(input('Type the number of left food in kg: '))
+daily_consumption_first = float(input('Type the daily consumption of the first cat in kg: '))
+daily_consumption_second = float(input('Type the daily consumption of the second cat in kg: '))
+
+left_food_kg -= days_absent * daily_consumption_first
+left_food_kg -= days_absent * daily_consumption_second
+
+if left_food_kg >= 0:
+ print('The cats are well fed')
+ print('{} kilos of food left'.format(left_food_kg))
+else:
+ print('The cats are hungry')
+ print('{} more kilos of food are needed'.format(int(abs(left_food_kg)))) \ No newline at end of file
diff --git a/Python/Beginner training/003 Hotel.py b/Python/Beginner training/003 Hotel.py
new file mode 100644
index 0000000..0e2ed2a
--- /dev/null
+++ b/Python/Beginner training/003 Hotel.py
@@ -0,0 +1,31 @@
+import sys
+import os
+import math
+
+n_nights = int(input('Type number of nights: '))
+room_type = input('Type the type of room: ')
+
+price = 0.0
+if room_type == 'apartment':
+ price = n_nights * 70
+else:
+ price = n_nights * 125
+
+#code doesn't account for writing mistakes
+if n_nights < 10:
+ if room_type == 'apartment':
+ price *= 0.7
+ else:
+ price *= 0.9
+elif n_nights > 15:
+ if room_type == 'apartment':
+ price *= 0.5
+ else:
+ price *= 0.8
+else:
+ if room_type == 'apartment':
+ price *= 0.65
+ else:
+ price *= 0.85
+
+print('Total price: {}'.format(round(price, 2))) \ No newline at end of file
diff --git a/Python/Beginner training/004 TakingCare.py b/Python/Beginner training/004 TakingCare.py
new file mode 100644
index 0000000..47143a3
--- /dev/null
+++ b/Python/Beginner training/004 TakingCare.py
@@ -0,0 +1,15 @@
+import sys
+import os
+import math
+
+food = int(input('Type bought amount of food in kg: ')) * 1000
+days_care = int(input('Type days the the animals wil be taken care of: '))
+
+for i in range(days_care):
+ daily_consumption = int(input('Food that the animal has eaten that day: '))
+ food -= daily_consumption
+
+if food >= 0:
+ print('Food is enough! Leftovers: {} grams'.format(food))
+else:
+ print('Food is not enough. You need {} grams more'.format(abs(food))) \ No newline at end of file
diff --git a/Python/Beginner training/011 FitnessEquipment.py b/Python/Beginner training/011 FitnessEquipment.py
new file mode 100644
index 0000000..a8046da
--- /dev/null
+++ b/Python/Beginner training/011 FitnessEquipment.py
@@ -0,0 +1,16 @@
+import sys
+import math
+import random
+import os
+
+total_sum = 0.0
+for x in range(int(input())):
+ item_name = input()
+
+ if item_name == "treadmill": total_sum += 5899
+ elif item_name == "cross trainer": total_sum += 1699
+ elif item_name == "exercise bike": total_sum += 1789
+ elif item_name == "dumbells": total_sum += 579
+ else: print("ERROR, Invalid product name")
+
+print(round(total_sum, 2)) \ No newline at end of file
diff --git a/Python/Beginner training/012 FitnessVisitors.py b/Python/Beginner training/012 FitnessVisitors.py
new file mode 100644
index 0000000..382c145
--- /dev/null
+++ b/Python/Beginner training/012 FitnessVisitors.py
@@ -0,0 +1,25 @@
+import sys
+import math
+import random
+import os
+
+names = list(input("Type names: ").split(", "))
+
+while True:
+ command = input()
+ if command == "END": break
+
+ if command == "Add visitor":
+ names.append(input())
+ elif command == "Add visitor on position":
+ name_to_insert = input()
+ names.insert(int(input()), name_to_insert)
+ elif command == "Remove visitor on position":
+ names.pop(int(input()))
+ elif command == "Remove last visitor":
+ names.pop(len(names) - 1)
+ elif command == "Remove first visitor":
+ names.pop(0)
+ else: print("ERROR, indxistant command")
+
+print(names)
diff --git a/Python/Beginner training/Basic synthax.py b/Python/Beginner training/Basic synthax.py
new file mode 100644
index 0000000..2d87410
--- /dev/null
+++ b/Python/Beginner training/Basic synthax.py
@@ -0,0 +1,5 @@
+import sys
+import random
+import os
+
+for x in range(0, 6, 2): print(x) \ No newline at end of file
diff --git a/Python/Beginner training/Random.py b/Python/Beginner training/Random.py
new file mode 100644
index 0000000..d913a72
--- /dev/null
+++ b/Python/Beginner training/Random.py
@@ -0,0 +1,67 @@
+import sys
+import os
+import random
+import math
+
+
+
+''' Divide
+cycle_n = int(input("Type number of numbers that will be typed: "))
+p1 = 0; p2 = 0; p3 = 0
+
+for x in range(cycle_n):
+ num = int(input())
+
+ if num % 2 == 0: p1 += 1
+ if num % 3 == 0: p2 += 1
+ if num % 4 == 0: p3 += 1
+
+print(round(p1 * 100 / cycle_n, 2), "%")
+print(round(p2 * 100 / cycle_n, 2), "%")
+print(round(p3 * 100 / cycle_n, 2), "%")
+
+'''
+
+''' Histogram
+cycle_n = int(input("Type number of numbers that will be typed: "))
+p1 = 0; p2 = 0; p3 = 0; p4 = 0; p5 = 0
+
+for x in range(cycle_n):
+ num = int(input())
+
+ if num < 200: p1 += 1
+ elif num < 400: p2 += 1
+ elif num < 600: p3 += 1
+ elif num < 800: p4 += 1
+ else: p5 += 1
+
+print(round(p1 * 100 / cycle_n, 2), "%")
+print(round(p2 * 100 / cycle_n, 2), "%")
+print(round(p3 * 100 / cycle_n, 2), "%")
+print(round(p4 * 100 / cycle_n, 2), "%")
+print(round(p5 * 100 / cycle_n, 2), "%")
+'''
+
+''' Number matrix
+size = int(input("Type size of matrix: "))
+
+for x in range(size):
+ for y in range(size):
+ num = y + x + 1
+
+ if num <= size or x == 0:
+ print(end="{} ".format(num)) #doing it like this for practice
+ else:
+ print(end="{} ".format(2 * size - num)) #doing it like this for practice
+ else: print()
+'''
+
+''' Factoriel code:
+factoriel_n = int(input("Type times of factoriel: "))
+
+final_int = 1
+for x in range(1, factoriel_n + 1):
+ final_int *= x
+
+print(final_int)
+''' \ No newline at end of file