aboutsummaryrefslogtreecommitdiff
path: root/Python/Beginner training/Tasks.py
diff options
context:
space:
mode:
authorSyndamia <kami02882@gmail.com>2019-07-14 18:24:40 +0300
committerSyndamia <kami02882@gmail.com>2019-07-14 18:24:40 +0300
commit65edf7296baf48aad1b4e0c09b57f1a7f48791a8 (patch)
tree0c163496769d66363a4907cab3e72f42e5030c75 /Python/Beginner training/Tasks.py
parenta0addea2b7bbdac244420ec917c0f3c14c4c8831 (diff)
downloadSelf-learning-65edf7296baf48aad1b4e0c09b57f1a7f48791a8.tar
Self-learning-65edf7296baf48aad1b4e0c09b57f1a7f48791a8.tar.gz
Self-learning-65edf7296baf48aad1b4e0c09b57f1a7f48791a8.zip
Combined exam exercises files into one file, added a file for OOP exercises
Diffstat (limited to 'Python/Beginner training/Tasks.py')
-rw-r--r--Python/Beginner training/Tasks.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/Python/Beginner training/Tasks.py b/Python/Beginner training/Tasks.py
new file mode 100644
index 0000000..873bde6
--- /dev/null
+++ b/Python/Beginner training/Tasks.py
@@ -0,0 +1,71 @@
+import sys
+import os
+import random
+import math
+
+def 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), "%")
+
+def 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), "%")
+
+def NumberMatrix():
+ 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()
+
+def Factoriel():
+ 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)
+
+Divide()
+Histogram()
+NumberMatrix()
+Factoriel() \ No newline at end of file