From f3e79a9f16afe90f0f49a833b7e3fcf0d50891fa Mon Sep 17 00:00:00 2001 From: kulpiq Date: Wed, 12 Oct 2022 11:16:25 +0200 Subject: [PATCH 01/20] pp1 --- 02-TypesAndVariables/task10.py | 7 +++++++ 02-TypesAndVariables/task11.py | 6 ++++++ 02-TypesAndVariables/task7.py | 12 ++++++++++++ 02-TypesAndVariables/task8.py | 9 +++++++++ 02-TypesAndVariables/task9.py | 3 +++ 02-TypesAndVariables/~$-TypesAndVariables.docx | Bin 0 -> 162 bytes 6 files changed, 37 insertions(+) create mode 100644 02-TypesAndVariables/task10.py create mode 100644 02-TypesAndVariables/task11.py create mode 100644 02-TypesAndVariables/task7.py create mode 100644 02-TypesAndVariables/task8.py create mode 100644 02-TypesAndVariables/task9.py create mode 100644 02-TypesAndVariables/~$-TypesAndVariables.docx diff --git a/02-TypesAndVariables/task10.py b/02-TypesAndVariables/task10.py new file mode 100644 index 000000000..aeb0be35b --- /dev/null +++ b/02-TypesAndVariables/task10.py @@ -0,0 +1,7 @@ +x = input("Enter first number: ") +y = input("Enter second number: ") + +x = int(x) +y = int (y) + +print(f"the first number plus the second is {x+y}") \ No newline at end of file diff --git a/02-TypesAndVariables/task11.py b/02-TypesAndVariables/task11.py new file mode 100644 index 000000000..36bf7dd5c --- /dev/null +++ b/02-TypesAndVariables/task11.py @@ -0,0 +1,6 @@ +name = input("Enter your name:") +age = input("Enter your age:") +height = input("Enter your hight") +age = int(age) +height = int(height) +print (f"My name is {name}, I\'m {age} years old, and my height is {height}") \ No newline at end of file diff --git a/02-TypesAndVariables/task7.py b/02-TypesAndVariables/task7.py new file mode 100644 index 000000000..877251f76 --- /dev/null +++ b/02-TypesAndVariables/task7.py @@ -0,0 +1,12 @@ +n1 = 5 +n2 = 1 +n3 = 8 +n4 = 6 +n5 = 3 +a = n1+n2+n3+n4+n5 +print (a) +b = n1**2+n2**2+n3**2+n4**2+n5**2 +print (b) +c = n3 / n5 +print (c) +print (n3 == n4) diff --git a/02-TypesAndVariables/task8.py b/02-TypesAndVariables/task8.py new file mode 100644 index 000000000..c59f12c42 --- /dev/null +++ b/02-TypesAndVariables/task8.py @@ -0,0 +1,9 @@ +from re import X + + +x = 7 +y = 34 +z = x +x = y +y = z +print(x, y) \ No newline at end of file diff --git a/02-TypesAndVariables/task9.py b/02-TypesAndVariables/task9.py new file mode 100644 index 000000000..52538e8d6 --- /dev/null +++ b/02-TypesAndVariables/task9.py @@ -0,0 +1,3 @@ +name = input("Enter your name: ") +surname = input("Enter your surname: ") +print(f"your name is {name} and surname is {surname}") \ No newline at end of file diff --git a/02-TypesAndVariables/~$-TypesAndVariables.docx b/02-TypesAndVariables/~$-TypesAndVariables.docx new file mode 100644 index 0000000000000000000000000000000000000000..2f65a00b08820821d5df36dd2cea1889745b6869 GIT binary patch literal 162 zcmd-m)-^CR)-|+XAO&zR6f@{D7%&(z7z1fT2AFP-nf#6ifd(1yuAZC7#K2%zjcO`T m2n=B2@*;lU`S0CeJhh=%LdKhc;o9m08UjE*Ojpp(FIxdd^c8^s literal 0 HcmV?d00001 From cbc97c3fb55225a94feb4c437de871f37d267d19 Mon Sep 17 00:00:00 2001 From: s-013-18 Date: Wed, 26 Oct 2022 11:08:36 +0200 Subject: [PATCH 02/20] lesson 2 --- 04-Subroutines/__pycache__/m.cpython-310.pyc | Bin 0 -> 284 bytes 04-Subroutines/__pycache__/module.cpython-310.pyc | Bin 0 -> 452 bytes 04-Subroutines/m.py | 3 +++ 04-Subroutines/module.py | 7 +++++++ 04-Subroutines/task10.py | 6 ++++++ 04-Subroutines/task15.py | 9 +++++++++ 04-Subroutines/task5.py | 7 +++++++ 04-Subroutines/task6.py | 9 +++++++++ 04-Subroutines/task7.py | 4 ++++ 04-Subroutines/task8.py | 7 +++++++ 04-Subroutines/task9.py | 5 +++++ 11 files changed, 57 insertions(+) create mode 100644 04-Subroutines/__pycache__/m.cpython-310.pyc create mode 100644 04-Subroutines/__pycache__/module.cpython-310.pyc create mode 100644 04-Subroutines/m.py create mode 100644 04-Subroutines/module.py create mode 100644 04-Subroutines/task10.py create mode 100644 04-Subroutines/task15.py create mode 100644 04-Subroutines/task5.py create mode 100644 04-Subroutines/task6.py create mode 100644 04-Subroutines/task7.py create mode 100644 04-Subroutines/task8.py create mode 100644 04-Subroutines/task9.py diff --git a/04-Subroutines/__pycache__/m.cpython-310.pyc b/04-Subroutines/__pycache__/m.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7a66cc374f38322bd30b0555732fc64bd8ff4047 GIT binary patch literal 284 zcmd1j<>g`k0?V%v$!(44TZzKoK}#1hSZc z*cph61%N~eLkVLFV>1xeGSn~t)ie233ApB!q!uY8D&&>sCZ!fxDQGg?V$RGfxy729 zS5R7_$#{#gVkJWn3sCzn!(^+N(Bjmh;+SGx14Cn7LyH)f)Z*-t{DPQ*0>c;s6W!p_ zq@w)NlFYo+;+R~$g34RmMX8A?@es2??kNTt#KXwKSi}Zo_-R6Du<=L)D^TthhfQvN PN@-529ata8(>x3Sdq6r& literal 0 HcmV?d00001 diff --git a/04-Subroutines/__pycache__/module.cpython-310.pyc b/04-Subroutines/__pycache__/module.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fe190b39d2de3a2af57c1678e7b9b1d47842e207 GIT binary patch literal 452 zcmZXPF-ycS6vvaM?Nx2T&BdW>hsqU2^bir$(JqG|N0+;%L-CrHBn3}&I=_Ouj((-C zPMuxE$@f~7f-k&(-V6V{{8D<}CV{y6yh)#7f5&DR1~g}oY8QkPPM^q(aD%fYol$Ob z3wr3LB(PI(`~`)IL7qdZZ4gZ~<#Y|}kvtIa8}a?lrO=u5=f0?m1r(95OaFM{2S&qk zp&Kg~RjmWs(7QJxO_=g^m`;*wl}VMTa2)N2(NS`dsasuENmWJ3_#m9t3t84W7nw?m zlGn>@uUa*B{{&)v;2@WpRN7FqkR<-cj-CPg3$SzJ)%am&af_4M4G@5}_p?ElgbtrP{_h4`rL1Z_;IqAQ1icc$KcZkDW`VGMCT3Y}B literal 0 HcmV?d00001 diff --git a/04-Subroutines/m.py b/04-Subroutines/m.py new file mode 100644 index 000000000..45b564682 --- /dev/null +++ b/04-Subroutines/m.py @@ -0,0 +1,3 @@ +def read_number(): + x=int(input("Enter a number: ")) + return x \ No newline at end of file diff --git a/04-Subroutines/module.py b/04-Subroutines/module.py new file mode 100644 index 000000000..3341639aa --- /dev/null +++ b/04-Subroutines/module.py @@ -0,0 +1,7 @@ +def number(): + x=int(input("Enter a number 1 to 9: ")) + return x +import random +def randomnumber(): + y=random.randint(1,9) + return y \ No newline at end of file diff --git a/04-Subroutines/task10.py b/04-Subroutines/task10.py new file mode 100644 index 000000000..68b0a84f1 --- /dev/null +++ b/04-Subroutines/task10.py @@ -0,0 +1,6 @@ +import m + +a=m.read_number() +b=m.read_number() + +print(f"The sum is {a+b}") \ No newline at end of file diff --git a/04-Subroutines/task15.py b/04-Subroutines/task15.py new file mode 100644 index 000000000..03f94bcce --- /dev/null +++ b/04-Subroutines/task15.py @@ -0,0 +1,9 @@ + +import module +x=module.number() +y= module.randomnumber() +if x==y: + print("Bingo!") +else: + print("try again") + diff --git a/04-Subroutines/task5.py b/04-Subroutines/task5.py new file mode 100644 index 000000000..2384fb5d1 --- /dev/null +++ b/04-Subroutines/task5.py @@ -0,0 +1,7 @@ +def university_address(): + print ("Cracow University of Economics") + print("Rakowicka 27") + print("31-510 Kraków, POLAND") + +university_address() +university_address() \ No newline at end of file diff --git a/04-Subroutines/task6.py b/04-Subroutines/task6.py new file mode 100644 index 000000000..925536d15 --- /dev/null +++ b/04-Subroutines/task6.py @@ -0,0 +1,9 @@ +def numbers(): + x=9 + for i in range(1, x+1): + if i%3 ==0: + print(i) + else: + print(i, end=" ") + +numbers() diff --git a/04-Subroutines/task7.py b/04-Subroutines/task7.py new file mode 100644 index 000000000..daac82c44 --- /dev/null +++ b/04-Subroutines/task7.py @@ -0,0 +1,4 @@ +def multiplication(x, y): + print( f"{x} * {y} = {x*y}" ) + +multiplication(3,4) diff --git a/04-Subroutines/task8.py b/04-Subroutines/task8.py new file mode 100644 index 000000000..62aaee548 --- /dev/null +++ b/04-Subroutines/task8.py @@ -0,0 +1,7 @@ +def intnum(n): + for i in range(1,n+1): + print(i, end=" ") + +intnum(15) +print() +intnum(25) diff --git a/04-Subroutines/task9.py b/04-Subroutines/task9.py new file mode 100644 index 000000000..9ac497cdd --- /dev/null +++ b/04-Subroutines/task9.py @@ -0,0 +1,5 @@ +def multiplication(x,y): + return x*y + +print( f"15 * 12 is {multiplication(15,12)}" ) +print( f"10 * 4 is {multiplication(10,4)}" ) \ No newline at end of file From f852e0049af97720508cee98e651b5bef287a005 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Sat, 29 Oct 2022 09:32:05 +0200 Subject: [PATCH 03/20] h3 --- 03-ControlStructures/task16.py | 6 ++++++ 03-ControlStructures/task17.py | 10 ++++++++++ 03-ControlStructures/task18.py | 22 ++++++++++++++++++++++ 03-ControlStructures/task19.py | 5 +++++ 03-ControlStructures/task20.py | 2 ++ 03-ControlStructures/task21.py | 4 ++++ 03-ControlStructures/task22.py | 10 ++++++++++ 03-ControlStructures/task23.py | 3 +++ 03-ControlStructures/task24.py | 10 ++++++++++ 03-ControlStructures/task25.py | 5 +++++ 10 files changed, 77 insertions(+) create mode 100644 03-ControlStructures/task16.py create mode 100644 03-ControlStructures/task17.py create mode 100644 03-ControlStructures/task18.py create mode 100644 03-ControlStructures/task19.py create mode 100644 03-ControlStructures/task20.py create mode 100644 03-ControlStructures/task21.py create mode 100644 03-ControlStructures/task22.py create mode 100644 03-ControlStructures/task23.py create mode 100644 03-ControlStructures/task24.py create mode 100644 03-ControlStructures/task25.py diff --git a/03-ControlStructures/task16.py b/03-ControlStructures/task16.py new file mode 100644 index 000000000..fcacbcfd0 --- /dev/null +++ b/03-ControlStructures/task16.py @@ -0,0 +1,6 @@ +x=int(input("Enter first number: ")) +y=int(input("Enter second number: ")) +if y>x: + print (x,y) +else: + print (f"Numbers in ascending order: {y},{x}") \ No newline at end of file diff --git a/03-ControlStructures/task17.py b/03-ControlStructures/task17.py new file mode 100644 index 000000000..27751097d --- /dev/null +++ b/03-ControlStructures/task17.py @@ -0,0 +1,10 @@ +x=int(input("Enter x: ")) +y=int(input("Enter y: ")) +if x>0 and y>0: + print(f"P({x},{y}) is in first quadrant of the coordinate system") +elif x<0 and y>0: + print(f"P({x},{y}) is in second quadrant of the coordinate system") +elif x<0 and y<0: + print(f"P({x},{y}) is in third quadrant of the coordinate system") +else: + print(f"P({x},{y}) is in fourth quadrant of the coordinate system") diff --git a/03-ControlStructures/task18.py b/03-ControlStructures/task18.py new file mode 100644 index 000000000..112e49aa2 --- /dev/null +++ b/03-ControlStructures/task18.py @@ -0,0 +1,22 @@ +amount=int(input("Enter the amount in PLN: ")) +if amount%5 == 0: + zl5=amount//5 + zl2=0 + zl1=0 + print(f"5zl-{zl5}") + print(f"2zl-{zl2}") + print(f"1zl-{zl1}") +elif amount%5==2 or amount%5==4: + zl5=amount//5 + zl2=(amount-5*zl5)//2 + zl1=0 + print(f"5zl-{zl5}") + print(f"2zl-{zl2}") + print(f"1zl-{zl1}") +else: + zl5=amount//5 + zl2=(amount-5*zl5)//2 + zl1=1 + print(f"5zl-{zl5}") + print(f"2zl-{zl2}") + print(f"1zl-{zl1}") \ No newline at end of file diff --git a/03-ControlStructures/task19.py b/03-ControlStructures/task19.py new file mode 100644 index 000000000..072d8e436 --- /dev/null +++ b/03-ControlStructures/task19.py @@ -0,0 +1,5 @@ +age=int(input("Enter the dog's age in human years:")) +if age<=2: + print("The dog's age in dog’s years is 10.5") +else: + print("The dog's age in dog’s years is", age*4) \ No newline at end of file diff --git a/03-ControlStructures/task20.py b/03-ControlStructures/task20.py new file mode 100644 index 000000000..d6f7957fd --- /dev/null +++ b/03-ControlStructures/task20.py @@ -0,0 +1,2 @@ +for i in range(1,11): + print(f"6 * {i} =",6*i) diff --git a/03-ControlStructures/task21.py b/03-ControlStructures/task21.py new file mode 100644 index 000000000..b71f76fc2 --- /dev/null +++ b/03-ControlStructures/task21.py @@ -0,0 +1,4 @@ +university=str("UEK w Krakowie") +print (university) +result=' '.join(university) +print(result) diff --git a/03-ControlStructures/task22.py b/03-ControlStructures/task22.py new file mode 100644 index 000000000..f56d1b525 --- /dev/null +++ b/03-ControlStructures/task22.py @@ -0,0 +1,10 @@ +for i in range(1,31): + print(i) + if i%3==0 and i%5!=0: + print("THREE") + elif i%5==0 and i%3!=0: + print("FIVE") + elif i%3==0 and i%5==0: + print("BINGO") + else: + print("") diff --git a/03-ControlStructures/task23.py b/03-ControlStructures/task23.py new file mode 100644 index 000000000..eeaf39e96 --- /dev/null +++ b/03-ControlStructures/task23.py @@ -0,0 +1,3 @@ +for i in range(1,10): + print(str(i) * i) + \ No newline at end of file diff --git a/03-ControlStructures/task24.py b/03-ControlStructures/task24.py new file mode 100644 index 000000000..1d41ff5cb --- /dev/null +++ b/03-ControlStructures/task24.py @@ -0,0 +1,10 @@ +x = 8 +for i in range(0, x): + for j in range(0, i + 1): + print("*", end=' ') + print(" ") + +for i in range(x , 0, -1): + for j in range(0, i - 1): + print("*", end=' ') + print(" ") \ No newline at end of file diff --git a/03-ControlStructures/task25.py b/03-ControlStructures/task25.py new file mode 100644 index 000000000..bddab6d5b --- /dev/null +++ b/03-ControlStructures/task25.py @@ -0,0 +1,5 @@ +a=int(input("Enter a: ")) +b=int(input("Enter b: ")) +for i in range (0,a): + for j in range (0, b): + print("*") \ No newline at end of file From 66ce2435fd3ded0ff619f7d67c32197a57147392 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Wed, 16 Nov 2022 07:49:24 +0100 Subject: [PATCH 04/20] pp1 --- 03-ControlStructures/spr2.py | 17 +++++++++++++++++ 03-ControlStructures/spr3.py | 11 +++++++++++ 03-ControlStructures/spr4.py | 16 ++++++++++++++++ 03-ControlStructures/sprawdzam.py | 15 +++++++++++++++ 03-ControlStructures/task10.py | 2 ++ 03-ControlStructures/task11.py | 2 ++ 03-ControlStructures/task12.py | 4 ++++ 03-ControlStructures/task13.py | 4 ++++ 03-ControlStructures/task16g.py | 6 ++++++ 03-ControlStructures/task17g.py | 10 ++++++++++ 03-ControlStructures/task20g.py | 4 ++++ 03-ControlStructures/task21g.py | 3 +++ 03-ControlStructures/task22g.py | 9 +++++++++ 03-ControlStructures/task23g.py | 5 +++++ 03-ControlStructures/task29.py | 0 03-ControlStructures/task6.py | 6 ++++++ 03-ControlStructures/task7.py | 6 ++++++ 03-ControlStructures/task8.py | 6 ++++++ 03-ControlStructures/task9.py | 6 ++++++ 04-Subroutines/mocktest1.py | 5 +++++ 04-Subroutines/mocktest2.py | 15 +++++++++++++++ 04-Subroutines/mocktest3.py | 16 ++++++++++++++++ 04-Subroutines/mocktest4.py | 25 +++++++++++++++++++++++++ 04-Subroutines/mt1.py | 5 +++++ 04-Subroutines/mt2.py | 15 +++++++++++++++ 04-Subroutines/mt3.py | 12 ++++++++++++ 04-Subroutines/mt4.py | 19 +++++++++++++++++++ 04-Subroutines/task16.py | 27 +++++++++++++++++++++++++++ 04-Subroutines/task17.py | 11 +++++++++++ 04-Subroutines/task18.py | 9 +++++++++ 04-Subroutines/task19.py | 9 +++++++++ 04-Subroutines/task20.py | 8 ++++++++ 04-Subroutines/task21.py | 8 ++++++++ 04-Subroutines/task22.py | 2 ++ 34 files changed, 318 insertions(+) create mode 100644 03-ControlStructures/spr2.py create mode 100644 03-ControlStructures/spr3.py create mode 100644 03-ControlStructures/spr4.py create mode 100644 03-ControlStructures/sprawdzam.py create mode 100644 03-ControlStructures/task10.py create mode 100644 03-ControlStructures/task11.py create mode 100644 03-ControlStructures/task12.py create mode 100644 03-ControlStructures/task13.py create mode 100644 03-ControlStructures/task16g.py create mode 100644 03-ControlStructures/task17g.py create mode 100644 03-ControlStructures/task20g.py create mode 100644 03-ControlStructures/task21g.py create mode 100644 03-ControlStructures/task22g.py create mode 100644 03-ControlStructures/task23g.py create mode 100644 03-ControlStructures/task29.py create mode 100644 03-ControlStructures/task6.py create mode 100644 03-ControlStructures/task7.py create mode 100644 03-ControlStructures/task8.py create mode 100644 03-ControlStructures/task9.py create mode 100644 04-Subroutines/mocktest1.py create mode 100644 04-Subroutines/mocktest2.py create mode 100644 04-Subroutines/mocktest3.py create mode 100644 04-Subroutines/mocktest4.py create mode 100644 04-Subroutines/mt1.py create mode 100644 04-Subroutines/mt2.py create mode 100644 04-Subroutines/mt3.py create mode 100644 04-Subroutines/mt4.py create mode 100644 04-Subroutines/task16.py create mode 100644 04-Subroutines/task17.py create mode 100644 04-Subroutines/task18.py create mode 100644 04-Subroutines/task19.py create mode 100644 04-Subroutines/task20.py create mode 100644 04-Subroutines/task21.py create mode 100644 04-Subroutines/task22.py diff --git a/03-ControlStructures/spr2.py b/03-ControlStructures/spr2.py new file mode 100644 index 000000000..910b755a9 --- /dev/null +++ b/03-ControlStructures/spr2.py @@ -0,0 +1,17 @@ +def f(x,y,z): + if x > y and y > z and x > z: + print(x-z) + elif x > y and y < z and x > z: + print(x-y) + elif y > x and x < z and z < y: + print(y-x) + elif y > x and x > z and y > z: + print(y-z) + elif z > x and x < z and y < x: + print(z-y) + else: + print(z-x) + +f(17,15,19) +f(29,14,19) + \ No newline at end of file diff --git a/03-ControlStructures/spr3.py b/03-ControlStructures/spr3.py new file mode 100644 index 000000000..b0d533eed --- /dev/null +++ b/03-ControlStructures/spr3.py @@ -0,0 +1,11 @@ +def f(pause): + length = len(pause) + for i in range(0, length): + if pause[i] == " ": + pass + else: + print(pause[i], end = "") + print() + +f("1 2 3 4 5") +f("aa bb cc dd") \ No newline at end of file diff --git a/03-ControlStructures/spr4.py b/03-ControlStructures/spr4.py new file mode 100644 index 000000000..0956aa878 --- /dev/null +++ b/03-ControlStructures/spr4.py @@ -0,0 +1,16 @@ +def f(palindrom): + lenght = len(palindrom) + if palindrom[0] == palindrom[-1]: + pass + + for i in range(1,int(lenght/2)): + if palindrom[i] == palindrom[-i+1]: + pass + else: + print ("False") + return False + +f("abcdefgfedcba") +f("radar") +f("abcdecdba") +f("12345432") \ No newline at end of file diff --git a/03-ControlStructures/sprawdzam.py b/03-ControlStructures/sprawdzam.py new file mode 100644 index 000000000..df1031091 --- /dev/null +++ b/03-ControlStructures/sprawdzam.py @@ -0,0 +1,15 @@ + +def f(first_letters): + length = len(first_letters) + print(first_letters[0], end= "") + for i in range(0, length): + if first_letters[i] == " ": + print(first_letters[i+1]) + else: + pass + print() + +f("blue water") +f("to be or not to be") +f("Cracow Poland") + diff --git a/03-ControlStructures/task10.py b/03-ControlStructures/task10.py new file mode 100644 index 000000000..887f83c3d --- /dev/null +++ b/03-ControlStructures/task10.py @@ -0,0 +1,2 @@ +for i in range(5): + print("Practice makes perfect") \ No newline at end of file diff --git a/03-ControlStructures/task11.py b/03-ControlStructures/task11.py new file mode 100644 index 000000000..3aca7f6fe --- /dev/null +++ b/03-ControlStructures/task11.py @@ -0,0 +1,2 @@ +for i in range(1,21): + print(i, end=" ") \ No newline at end of file diff --git a/03-ControlStructures/task12.py b/03-ControlStructures/task12.py new file mode 100644 index 000000000..7b9e27175 --- /dev/null +++ b/03-ControlStructures/task12.py @@ -0,0 +1,4 @@ +sum=0 +for i in range(100, 151): + sum=sum+ i +print(sum) diff --git a/03-ControlStructures/task13.py b/03-ControlStructures/task13.py new file mode 100644 index 000000000..025babbaa --- /dev/null +++ b/03-ControlStructures/task13.py @@ -0,0 +1,4 @@ + +for i in range(1,11): + a=1/i + print(f"1/{i} = {a}") \ No newline at end of file diff --git a/03-ControlStructures/task16g.py b/03-ControlStructures/task16g.py new file mode 100644 index 000000000..f71e5bbfc --- /dev/null +++ b/03-ControlStructures/task16g.py @@ -0,0 +1,6 @@ +x = int(input("Enter x: ")) +y = int(input("Entwe y: ")) +if x >= y: + print(f"Numbers in ascending order: {y},{x}") +else: + print(f"Numbers in ascending order: {x}, {y}") \ No newline at end of file diff --git a/03-ControlStructures/task17g.py b/03-ControlStructures/task17g.py new file mode 100644 index 000000000..110cd46bc --- /dev/null +++ b/03-ControlStructures/task17g.py @@ -0,0 +1,10 @@ +x = int(input("Enter x: ")) +y = int(input("Enter y: ")) +if x > 0 and y > 0: + print(f"P({x},{y}) is in first quadrant") +elif x < 0 and y > 0: + print(f"P({x},{y}) is in second quadrant") +elif x < 0 and y > 0: + print(f"P({x},{y}) is in third quadrant") +else: + print(f"P({x},{y}) is in fourth quadrant") \ No newline at end of file diff --git a/03-ControlStructures/task20g.py b/03-ControlStructures/task20g.py new file mode 100644 index 000000000..c8f6f969c --- /dev/null +++ b/03-ControlStructures/task20g.py @@ -0,0 +1,4 @@ + +x = int(input("Enter number: ")) +for i in range(1,11): + print(f"{x} x {i} = {x*i}") \ No newline at end of file diff --git a/03-ControlStructures/task21g.py b/03-ControlStructures/task21g.py new file mode 100644 index 000000000..eec9637c1 --- /dev/null +++ b/03-ControlStructures/task21g.py @@ -0,0 +1,3 @@ +university = str("UEK w Krakowie") +x= ' '. join(university) +print(x) \ No newline at end of file diff --git a/03-ControlStructures/task22g.py b/03-ControlStructures/task22g.py new file mode 100644 index 000000000..830361ad9 --- /dev/null +++ b/03-ControlStructures/task22g.py @@ -0,0 +1,9 @@ +for i in range(1,31): + if i%3 == 0 and i%5 ==0: + print(i, "BINGO ", end= "") + elif i%5 == 0: + print(i, "FIVE ", end= "") + elif i%3 == 0: + print(i,"THREE ", end= "") + else: + print(i ," ", end= "") \ No newline at end of file diff --git a/03-ControlStructures/task23g.py b/03-ControlStructures/task23g.py new file mode 100644 index 000000000..b481e00a3 --- /dev/null +++ b/03-ControlStructures/task23g.py @@ -0,0 +1,5 @@ +n = int(input("Enter number of raws: ")) +for i in range(1,n+1): + for j in range(1,i+1): + print(j, end=" ") + print() \ No newline at end of file diff --git a/03-ControlStructures/task29.py b/03-ControlStructures/task29.py new file mode 100644 index 000000000..e69de29bb diff --git a/03-ControlStructures/task6.py b/03-ControlStructures/task6.py new file mode 100644 index 000000000..444acee9e --- /dev/null +++ b/03-ControlStructures/task6.py @@ -0,0 +1,6 @@ +speed_limit = 130 +car_speed=int(input("Enter a car speed: ")) +if car_speed>=speed_limit: + print("You are speeding") +else: + print("Good job") \ No newline at end of file diff --git a/03-ControlStructures/task7.py b/03-ControlStructures/task7.py new file mode 100644 index 000000000..f9df91bb1 --- /dev/null +++ b/03-ControlStructures/task7.py @@ -0,0 +1,6 @@ +x=int(input("Enter x: ")) + +if x%2 == 0: + print("x is even") +else: + print("x is odd") \ No newline at end of file diff --git a/03-ControlStructures/task8.py b/03-ControlStructures/task8.py new file mode 100644 index 000000000..f0274eacc --- /dev/null +++ b/03-ControlStructures/task8.py @@ -0,0 +1,6 @@ +pauls_age = 21 +annies_age = 18 +if pauls_age>= 18 and annies_age >= 18: + print("They are both adult") +else: + print("Someone cant be adult") \ No newline at end of file diff --git a/03-ControlStructures/task9.py b/03-ControlStructures/task9.py new file mode 100644 index 000000000..8b8b1d2ea --- /dev/null +++ b/03-ControlStructures/task9.py @@ -0,0 +1,6 @@ +x = int(input("Enter x:")) +y = int(input("Enter y: ")) +if x>0 or y>0: + print("At least one is positive") +else: + print("At least one of them is not positive") \ No newline at end of file diff --git a/04-Subroutines/mocktest1.py b/04-Subroutines/mocktest1.py new file mode 100644 index 000000000..aac91876c --- /dev/null +++ b/04-Subroutines/mocktest1.py @@ -0,0 +1,5 @@ +def f(card_number): + card_number= card_number[0:2] + "**********" + card_number[12:16] + print(card_number) + +f("5290312400019022") \ No newline at end of file diff --git a/04-Subroutines/mocktest2.py b/04-Subroutines/mocktest2.py new file mode 100644 index 000000000..f6d6b8fba --- /dev/null +++ b/04-Subroutines/mocktest2.py @@ -0,0 +1,15 @@ +def f(binary_number): + length = len(binary_number) + binary= None + for i in range(0,length): + if binary_number[i] == "0" or binary_number[i] == "1": + pass + else: + binary = False + print(binary) + return False + binary = True + print(binary) + +f("101101") +f("1311a10100") diff --git a/04-Subroutines/mocktest3.py b/04-Subroutines/mocktest3.py new file mode 100644 index 000000000..dbd275183 --- /dev/null +++ b/04-Subroutines/mocktest3.py @@ -0,0 +1,16 @@ +def f(amount): + rem = amount % 5 + zl5 = (amount - rem)/5 + rem = amount % 2 + zl2 = (amount - rem)/2 + zl1 = rem + + print(int(zl5 + zl2 + zl1)) + + + +f(8) +f(2) +f(0) + +#jest źle:) diff --git a/04-Subroutines/mocktest4.py b/04-Subroutines/mocktest4.py new file mode 100644 index 000000000..9c2dc8f4d --- /dev/null +++ b/04-Subroutines/mocktest4.py @@ -0,0 +1,25 @@ +def f(number,even): + sum = 0 + length = len(str(number)) + if even == True: + for i in range(0, length): + if number[i]%2 == 0: + sum+= int(str(number[i])) + else: + pass + + if even == False: + for i in range(0, length): + if int(str(number)[i])%2 == 1: + sum = sum +int(str(number)[i]) + else: + pass + + print(sum) + +f(3124,True) +f(3124,False) +f(20576,False) +f(20576,True) +f(13115,True) + diff --git a/04-Subroutines/mt1.py b/04-Subroutines/mt1.py new file mode 100644 index 000000000..7e5aaa6eb --- /dev/null +++ b/04-Subroutines/mt1.py @@ -0,0 +1,5 @@ +def f(card_number): + card_number = card_number[0:2] + "**********" + card_number[12:16] + print(card_number) + +f("5290312400019022") \ No newline at end of file diff --git a/04-Subroutines/mt2.py b/04-Subroutines/mt2.py new file mode 100644 index 000000000..991d75c01 --- /dev/null +++ b/04-Subroutines/mt2.py @@ -0,0 +1,15 @@ +def f(binary_number): + lenght = len(binary_number) + binary = None + for i in range(0, lenght): + if binary_number[i] == "0" or binary_number[i] == "1": + pass + else: + binary = False + print(binary) + return False + binary = True + print(binary) + +f("101101") +f("1311a10100") \ No newline at end of file diff --git a/04-Subroutines/mt3.py b/04-Subroutines/mt3.py new file mode 100644 index 000000000..e93d3787f --- /dev/null +++ b/04-Subroutines/mt3.py @@ -0,0 +1,12 @@ +def f(amount_to_pay): + if amount_to_pay%5 == 0: + print (int(amount_to_pay/5)) + elif (amount_to_pay - int((amount_to_pay/5)*5)) %2 == 0: + print(int(amount_to_pay/5) + ((amount_to_pay - int((amount_to_pay/5)*5)))/2) + else: + print(int(amount_to_pay/5) + ((amount_to_pay - int((amount_to_pay/5)*5)))/2 +1) + +f(23) +f(8) +f(2) +f(0) \ No newline at end of file diff --git a/04-Subroutines/mt4.py b/04-Subroutines/mt4.py new file mode 100644 index 000000000..1b9cf86bf --- /dev/null +++ b/04-Subroutines/mt4.py @@ -0,0 +1,19 @@ +def f(number, even): + length = len(str(number)) + sum = 0 + if even == True: + for i in range(0,length): + if int(str(number)[i]) % 2 == 0: + sum += int(str(number)[i]) + else: + pass + + if even == False: + for i in range(0,length): + if int(str(number)[i]) % 2 != 0: + sum += int(str(number)[i]) + else: + pass + print(sum) + +f(3124,True) diff --git a/04-Subroutines/task16.py b/04-Subroutines/task16.py new file mode 100644 index 000000000..e056ddb6e --- /dev/null +++ b/04-Subroutines/task16.py @@ -0,0 +1,27 @@ +def month(n): + if n == 1: + print("January") + elif n == 2: + print("February") + elif n == 3: + print("March") + if n == 4: + print("April") + elif n == 5: + print("March") + elif n == 6: + print("Mai") + if n == 7: + print("June") + elif n == 8: + print("July") + elif n == 9: + print("September") + if n == 10: + print("October") + elif n == 11: + print("November") + elif n == 12: + print("December") + +month(7) \ No newline at end of file diff --git a/04-Subroutines/task17.py b/04-Subroutines/task17.py new file mode 100644 index 000000000..941fabbed --- /dev/null +++ b/04-Subroutines/task17.py @@ -0,0 +1,11 @@ +def f(letters): + length = len(letters) + sum = 0 + for i in range(0, length): + if letters[i] == "e": + sum = sum+1 + else: + pass + print(sum) + +f("You never get a second chance to make a first impression") \ No newline at end of file diff --git a/04-Subroutines/task18.py b/04-Subroutines/task18.py new file mode 100644 index 000000000..2f9718525 --- /dev/null +++ b/04-Subroutines/task18.py @@ -0,0 +1,9 @@ +def f(digits): + length = len(digits) + sum = 0 + for i in range(0, length): + sum = sum + int(digits[i]) + + print(sum) + +f("7182") \ No newline at end of file diff --git a/04-Subroutines/task19.py b/04-Subroutines/task19.py new file mode 100644 index 000000000..43da2ec5a --- /dev/null +++ b/04-Subroutines/task19.py @@ -0,0 +1,9 @@ +def f(number,x,y): + if number >= x and number <=y: + print(True) + else: + print(False) + +f(4,2,6) +f(3,7,8) + diff --git a/04-Subroutines/task20.py b/04-Subroutines/task20.py new file mode 100644 index 000000000..86fb6d33a --- /dev/null +++ b/04-Subroutines/task20.py @@ -0,0 +1,8 @@ + +def power(x,n): + pow = 0 + pow = x**n + print(pow) + +power(5,3) +power(2,10) \ No newline at end of file diff --git a/04-Subroutines/task21.py b/04-Subroutines/task21.py new file mode 100644 index 000000000..f18efe0c5 --- /dev/null +++ b/04-Subroutines/task21.py @@ -0,0 +1,8 @@ +def f(x,y): + if x>y: + print(True) + else: + print(False) + +f(1,2) +f(3,1) \ No newline at end of file diff --git a/04-Subroutines/task22.py b/04-Subroutines/task22.py new file mode 100644 index 000000000..327658218 --- /dev/null +++ b/04-Subroutines/task22.py @@ -0,0 +1,2 @@ +lambda x : x%2== 0: print(True) + From bfb66189335c635cb47e61730c22a99018091f3e Mon Sep 17 00:00:00 2001 From: kulpiq Date: Wed, 16 Nov 2022 11:14:18 +0100 Subject: [PATCH 05/20] s --- 06-Arrays/task12.py | 18 ++++++++++++++++++ 06-Arrays/task6.py | 26 ++++++++++++++++++++++++++ 06-Arrays/task7.py | 15 +++++++++++++++ 06-Arrays/task8.py | 14 ++++++++++++++ 06-Arrays/task9.py | 0 5 files changed, 73 insertions(+) create mode 100644 06-Arrays/task12.py create mode 100644 06-Arrays/task6.py create mode 100644 06-Arrays/task7.py create mode 100644 06-Arrays/task8.py create mode 100644 06-Arrays/task9.py diff --git a/06-Arrays/task12.py b/06-Arrays/task12.py new file mode 100644 index 000000000..fcd522830 --- /dev/null +++ b/06-Arrays/task12.py @@ -0,0 +1,18 @@ +array = [[2,5,4],[9,0,3]] + +print(array) + +print(len(array), len(array[0])) + +print(array[0][1]) + +print(array[1][2]) + + +for i in array[1]: + print(i, end = " ") + +print() + +for i in array: + print(i) diff --git a/06-Arrays/task6.py b/06-Arrays/task6.py new file mode 100644 index 000000000..37e03be3f --- /dev/null +++ b/06-Arrays/task6.py @@ -0,0 +1,26 @@ +x=[2,3,7,5,4] +print(x) + +print(x[0]) + +print(len(x)) + +print(x[1]) + +print(x[-1]) + +print(x[0] + x[-1]) + +print(x[len(x) - 2]) + +print(x[len(x) // 2]) + +for i in x: + print(i, end=" ") + +print() + +for i in range(len(x)// 2 + 1): + print(x[i], end=" ") + +print() \ No newline at end of file diff --git a/06-Arrays/task7.py b/06-Arrays/task7.py new file mode 100644 index 000000000..2ce75b1d1 --- /dev/null +++ b/06-Arrays/task7.py @@ -0,0 +1,15 @@ +x= [1,2,3,4,5] + +x[0] = x[0] -1 +print(x) + +x[-1] = x[-1] + 4 +print(x) + +x[len(x)//2] = x[len(x)//2]*2 +print(x) + +for i in range(len(x)): + x[i]= x[i] +4 + +print(x) \ No newline at end of file diff --git a/06-Arrays/task8.py b/06-Arrays/task8.py new file mode 100644 index 000000000..346ffd5af --- /dev/null +++ b/06-Arrays/task8.py @@ -0,0 +1,14 @@ +array = [-15, 8, -31, 47, -2, 19] + +max_x=array[0] +min_x=array[0] + +for i in array: + if i>= max_x: + max_x = i + elif i <= min_x: + min_x = i + +print(f"Maximum is {max_x}, and minimum is {min_x}") + + diff --git a/06-Arrays/task9.py b/06-Arrays/task9.py new file mode 100644 index 000000000..e69de29bb From d50773e8ea730a152e569d67b5dce045a4f051bb Mon Sep 17 00:00:00 2001 From: kulpiq Date: Wed, 23 Nov 2022 11:07:45 +0100 Subject: [PATCH 06/20] ok --- 07-FileHandling/countries.txt | 5 +++++ 07-FileHandling/films_titles.txt | 5 +++++ 07-FileHandling/numbers.txt | 7 +++++++ 07-FileHandling/shopping.txt | 1 + 07-FileHandling/student.txt | 3 +++ 07-FileHandling/task10.py | 9 +++++++++ 07-FileHandling/task11.py | 5 +++++ 07-FileHandling/task12.py | 3 +++ 07-FileHandling/task6.py | 4 ++++ 07-FileHandling/task7.py | 7 +++++++ 07-FileHandling/task9.py | 7 +++++++ 07-FileHandling/~$-FilesHandling.docx | Bin 0 -> 162 bytes 12 files changed, 56 insertions(+) create mode 100644 07-FileHandling/countries.txt create mode 100644 07-FileHandling/films_titles.txt create mode 100644 07-FileHandling/numbers.txt create mode 100644 07-FileHandling/shopping.txt create mode 100644 07-FileHandling/student.txt create mode 100644 07-FileHandling/task10.py create mode 100644 07-FileHandling/task11.py create mode 100644 07-FileHandling/task12.py create mode 100644 07-FileHandling/task6.py create mode 100644 07-FileHandling/task7.py create mode 100644 07-FileHandling/task9.py create mode 100644 07-FileHandling/~$-FilesHandling.docx diff --git a/07-FileHandling/countries.txt b/07-FileHandling/countries.txt new file mode 100644 index 000000000..9092dc4a0 --- /dev/null +++ b/07-FileHandling/countries.txt @@ -0,0 +1,5 @@ +Poland +Germany +Norway +France +Ukraine diff --git a/07-FileHandling/films_titles.txt b/07-FileHandling/films_titles.txt new file mode 100644 index 000000000..04ea3e773 --- /dev/null +++ b/07-FileHandling/films_titles.txt @@ -0,0 +1,5 @@ +film1 +film2 +film3 +film4 +film5 diff --git a/07-FileHandling/numbers.txt b/07-FileHandling/numbers.txt new file mode 100644 index 000000000..f04fade56 --- /dev/null +++ b/07-FileHandling/numbers.txt @@ -0,0 +1,7 @@ +56 +6 +23 +5 +76 +33 +4 diff --git a/07-FileHandling/shopping.txt b/07-FileHandling/shopping.txt new file mode 100644 index 000000000..684fd18e9 --- /dev/null +++ b/07-FileHandling/shopping.txt @@ -0,0 +1 @@ +& "c:/Program Files (x86)/python/python.exe" c:/Users/s-013-23/Desktop/pp1/07-FileHandling/task12.pymaslo diff --git a/07-FileHandling/student.txt b/07-FileHandling/student.txt new file mode 100644 index 000000000..3c77a3130 --- /dev/null +++ b/07-FileHandling/student.txt @@ -0,0 +1,3 @@ +Dominika Kulpa +UEK w Krakowie +225882 diff --git a/07-FileHandling/task10.py b/07-FileHandling/task10.py new file mode 100644 index 000000000..dba3cf2f3 --- /dev/null +++ b/07-FileHandling/task10.py @@ -0,0 +1,9 @@ +with open('student.txt','w', encoding= "UTF-8") as f: + f.write("Dominika Kulpa\n") + f.write("UEK w Krakowie\n") + f.write("225882\n") + +#file = open("student.txt", "w") +#f.write("Dominika Kulpa\n") +#f.write("UEK w Krakowie\n") +#f.write("225882\n") \ No newline at end of file diff --git a/07-FileHandling/task11.py b/07-FileHandling/task11.py new file mode 100644 index 000000000..ee5b60efb --- /dev/null +++ b/07-FileHandling/task11.py @@ -0,0 +1,5 @@ +array = ["film1", "film2", "film3", "film4", "film5"] +file = open("films_titles.txt", "w") +for i in range(5): + file.write(f"{array[i]}\n") +file.close() \ No newline at end of file diff --git a/07-FileHandling/task12.py b/07-FileHandling/task12.py new file mode 100644 index 000000000..69cc7297d --- /dev/null +++ b/07-FileHandling/task12.py @@ -0,0 +1,3 @@ +with open("shopping.txt", "a") as file: + item= input("enter item: ") + file.write(f"{item} \n") diff --git a/07-FileHandling/task6.py b/07-FileHandling/task6.py new file mode 100644 index 000000000..6c41f5913 --- /dev/null +++ b/07-FileHandling/task6.py @@ -0,0 +1,4 @@ +file = open('countries.txt','r') +file_content = file.read() +print( file_content ) +file.close() diff --git a/07-FileHandling/task7.py b/07-FileHandling/task7.py new file mode 100644 index 000000000..480a362a1 --- /dev/null +++ b/07-FileHandling/task7.py @@ -0,0 +1,7 @@ +file = open('countries.txt','r') +counter = 1 +for line in file: + print(counter, line, end="") + counter = counter + 1 + +file.close() \ No newline at end of file diff --git a/07-FileHandling/task9.py b/07-FileHandling/task9.py new file mode 100644 index 000000000..a6fbce291 --- /dev/null +++ b/07-FileHandling/task9.py @@ -0,0 +1,7 @@ +file = open('numbers.txt','r') +sum = 0 +for line in file: + sum = sum + int(line) + +file.close() +print(sum) diff --git a/07-FileHandling/~$-FilesHandling.docx b/07-FileHandling/~$-FilesHandling.docx new file mode 100644 index 0000000000000000000000000000000000000000..5401a1c506685d17a2879f257f93563a81b7d667 GIT binary patch literal 162 zcmZQzAQ#MLWMG)#HGkdzdIkn5s39-rnYQWx*$XZQr-I}cx1yTP1m(iS|6e(`TjKu> aMn%(z=-T594C~fO{{Zn}x`K9guLA)5!x|+3 literal 0 HcmV?d00001 From e0ab501faf38bffde4e79bee85bdf68fc741382b Mon Sep 17 00:00:00 2001 From: kulpiq Date: Sun, 4 Dec 2022 15:41:24 +0100 Subject: [PATCH 07/20] fs --- 06-Arrays/task10.py | 15 ++++++ 06-Arrays/task11.py | 11 ++++ 06-Arrays/task12.2.py | 23 +++++++++ 06-Arrays/task13.py | 8 +++ 06-Arrays/task14.py | 8 +++ 06-Arrays/task15.py | 16 ++++++ 06-Arrays/task16.py | 6 +++ 06-Arrays/task17.2.py | 16 ++++++ 06-Arrays/task17.py | 8 +++ 06-Arrays/task18.py | 12 +++++ 06-Arrays/task19.py | 20 +++++++ 06-Arrays/task20.py | 11 ++++ 06-Arrays/task21.py | 25 +++++++++ 06-Arrays/task22.py | 17 ++++++ 06-Arrays/task5.py | 29 +++++++++++ 06-Arrays/task6.2.py | 25 +++++++++ 06-Arrays/task7.2.py | 15 ++++++ 06-Arrays/task8.2.py | 11 ++++ 06-Arrays/task9.py | 10 ++++ 07-FileHandling/GrainsAndBread.txt | 5 ++ 07-FileHandling/MeatAndFish.txt | 4 ++ 07-FileHandling/copy.txt | 83 ++++++++++++++++++++++++++++++ 07-FileHandling/copylines.txt | 83 ++++++++++++++++++++++++++++++ 07-FileHandling/file.txt | 83 ++++++++++++++++++++++++++++++ 07-FileHandling/filename.txt | 5 ++ 07-FileHandling/intigers.txt | 50 ++++++++++++++++++ 07-FileHandling/powers.txt | 10 ++++ 07-FileHandling/randomint.txt | 50 ++++++++++++++++++ 07-FileHandling/shoppinglist.txt | 21 ++++++++ 07-FileHandling/task13.py | 5 ++ 07-FileHandling/task14.py | 11 ++++ 07-FileHandling/task15.py | 9 ++++ 07-FileHandling/task16.py | 10 ++++ 07-FileHandling/task17.py | 7 +++ 07-FileHandling/task18.py | 8 +++ 07-FileHandling/task19.py | 5 ++ 07-FileHandling/task20.py | 7 +++ 07-FileHandling/task21.py | 9 ++++ 07-FileHandling/task22.py | 0 39 files changed, 751 insertions(+) create mode 100644 06-Arrays/task10.py create mode 100644 06-Arrays/task11.py create mode 100644 06-Arrays/task12.2.py create mode 100644 06-Arrays/task13.py create mode 100644 06-Arrays/task14.py create mode 100644 06-Arrays/task15.py create mode 100644 06-Arrays/task16.py create mode 100644 06-Arrays/task17.2.py create mode 100644 06-Arrays/task17.py create mode 100644 06-Arrays/task18.py create mode 100644 06-Arrays/task19.py create mode 100644 06-Arrays/task20.py create mode 100644 06-Arrays/task21.py create mode 100644 06-Arrays/task22.py create mode 100644 06-Arrays/task5.py create mode 100644 06-Arrays/task6.2.py create mode 100644 06-Arrays/task7.2.py create mode 100644 06-Arrays/task8.2.py create mode 100644 07-FileHandling/GrainsAndBread.txt create mode 100644 07-FileHandling/MeatAndFish.txt create mode 100644 07-FileHandling/copy.txt create mode 100644 07-FileHandling/copylines.txt create mode 100644 07-FileHandling/file.txt create mode 100644 07-FileHandling/filename.txt create mode 100644 07-FileHandling/intigers.txt create mode 100644 07-FileHandling/powers.txt create mode 100644 07-FileHandling/randomint.txt create mode 100644 07-FileHandling/shoppinglist.txt create mode 100644 07-FileHandling/task13.py create mode 100644 07-FileHandling/task14.py create mode 100644 07-FileHandling/task15.py create mode 100644 07-FileHandling/task16.py create mode 100644 07-FileHandling/task17.py create mode 100644 07-FileHandling/task18.py create mode 100644 07-FileHandling/task19.py create mode 100644 07-FileHandling/task20.py create mode 100644 07-FileHandling/task21.py create mode 100644 07-FileHandling/task22.py diff --git a/06-Arrays/task10.py b/06-Arrays/task10.py new file mode 100644 index 000000000..f4b63b35d --- /dev/null +++ b/06-Arrays/task10.py @@ -0,0 +1,15 @@ +array = [11,42,6,1,5,7,63,68,0] +even = 0 +odd = 0 +i = 0 +while i < len(array): + if array[i] %2 == 0: + even += 1 + else: + odd +=1 + i = i+1 + +print(f"Even number equals: {even} \nOdd numbers equals: {odd}") + + + diff --git a/06-Arrays/task11.py b/06-Arrays/task11.py new file mode 100644 index 000000000..d4b3605f2 --- /dev/null +++ b/06-Arrays/task11.py @@ -0,0 +1,11 @@ +def month(n): + list = ["January", "February", "March", "April", "Mai", "June" , "July", "August", "September", "October", "November", "December"] + for i in range(12): + list[i] = list[n-1] + + print(list[n-1]) + +month(1) +month(2) +month(11) +month(12) \ No newline at end of file diff --git a/06-Arrays/task12.2.py b/06-Arrays/task12.2.py new file mode 100644 index 000000000..606f6c517 --- /dev/null +++ b/06-Arrays/task12.2.py @@ -0,0 +1,23 @@ +array = [[2,5,4],[9,0,3]] +#a. the array +print(array) + +#b. size of the array (number of rows and columns) +print(len(array), len(array[0])) + +#c. value 5 from the array +print(array[0][1]) + +#d. value 3 from the array +print(array[1][2]) + +#e. second row of the array as below: +#9 0 3 +for i in array[1]: + print(i, end = " ") +print() +#f. all values from the array as below: +#2 5 4 +#9 0 3 +for i in array: + print(i) \ No newline at end of file diff --git a/06-Arrays/task13.py b/06-Arrays/task13.py new file mode 100644 index 000000000..1603e9870 --- /dev/null +++ b/06-Arrays/task13.py @@ -0,0 +1,8 @@ +array = [3,9,2],[2,4,5],[7,1,6],[0,4,8] +sum = 0 +for i in range(int(len(array))): + for j in range(int(len(array[0]))): + sum = sum + int(array[i][j]) + +print(sum) + \ No newline at end of file diff --git a/06-Arrays/task14.py b/06-Arrays/task14.py new file mode 100644 index 000000000..d1a5213e2 --- /dev/null +++ b/06-Arrays/task14.py @@ -0,0 +1,8 @@ +array = [[True,False],[True,True],[False,False]] +for i in range(int(len(array))): + for j in range(int(len(array[0]))): + if array[i][j] == bool("True"): + array[i][j] = False + else: + array[i][j] = True +print(array) \ No newline at end of file diff --git a/06-Arrays/task15.py b/06-Arrays/task15.py new file mode 100644 index 000000000..b564c4172 --- /dev/null +++ b/06-Arrays/task15.py @@ -0,0 +1,16 @@ +array = [[0,0,0],[0,0,0],[0,0,0]] +for i in range(int(len(array))): + for j in range(int(len(array[0]))): + if i == j : + array[i][j] = 1 + else: + array[i][j] + +for i in range(int(len(array))): + for j in range(int(len(array[0]))): + if j ==2: + print(array[i][j], end = " ") + print() + else: + print(array[i][j], end = " ") + \ No newline at end of file diff --git a/06-Arrays/task16.py b/06-Arrays/task16.py new file mode 100644 index 000000000..09bcedab6 --- /dev/null +++ b/06-Arrays/task16.py @@ -0,0 +1,6 @@ +array = [15, 8, 31, 47, 2, 19] +print(f"existed array: {array}") +#array.reverse() +print("reverse array: ", end = " ") +for i in range(int(len(array)-1), -1, -1): + print(array[i], end = " ") diff --git a/06-Arrays/task17.2.py b/06-Arrays/task17.2.py new file mode 100644 index 000000000..932df76ea --- /dev/null +++ b/06-Arrays/task17.2.py @@ -0,0 +1,16 @@ +def f(): + array = [8,5,2,1,9] + s1 = "Array: " + s2 = '' + s5='' + for i in range(int(len(array))): + s2 =s2 + " " +str(array[i]) + s3= "\n" + s4="2nd power array: " + for i in range(int(len(array))): + s5 = s5 + " "+str(array[i]*array[i]) + + return s1 + s2 +s3 + s4+ s5 + +print(f()) + diff --git a/06-Arrays/task17.py b/06-Arrays/task17.py new file mode 100644 index 000000000..57da116c4 --- /dev/null +++ b/06-Arrays/task17.py @@ -0,0 +1,8 @@ +array = [8,5,2,1,9] +print("Array: ", end = " ") +for i in range(int(len(array))): + print(array[i], end = " ") +print() +print("2nd power array: ", end =" ") +for i in range(int(len(array))): + print(array[i]*array[i], end = " ") diff --git a/06-Arrays/task18.py b/06-Arrays/task18.py new file mode 100644 index 000000000..824ed61bb --- /dev/null +++ b/06-Arrays/task18.py @@ -0,0 +1,12 @@ +array = [15, 8, 31, 47, 2, 19] +sum = 0 +lenght = len(array) +for i in array: + print(i, end = " ") + +print() +for i in array: + sum = sum +i + +sre = sum/lenght +print(f"arithmetic mean = {sre}") \ No newline at end of file diff --git a/06-Arrays/task19.py b/06-Arrays/task19.py new file mode 100644 index 000000000..68e2a9f48 --- /dev/null +++ b/06-Arrays/task19.py @@ -0,0 +1,20 @@ +array = [15, 8, 31, 47, 2, 19] +length = len(array) +i = 0 +sum = 0 +j = 0 +print("Array: ", end = " ") +while i < length: + print(array[i] , end =" ") + i = i + 1 + +print() +print("arithmetic mean: ", end = " ") + +while j < length: + sum = sum + int(array[j]) + j = j + 1 + +average = sum / length +print(average) + diff --git a/06-Arrays/task20.py b/06-Arrays/task20.py new file mode 100644 index 000000000..e26291fb5 --- /dev/null +++ b/06-Arrays/task20.py @@ -0,0 +1,11 @@ +array = [12, 6, 4, 9, 10] +length = len(array) +for i in range(length): + print(array[i], int(array[i])*"*") + +def star(n): + for i in range(n): + s1 = str(n) + " " + n*"*" + return s1 + +print(star(7)) \ No newline at end of file diff --git a/06-Arrays/task21.py b/06-Arrays/task21.py new file mode 100644 index 000000000..4eb625f24 --- /dev/null +++ b/06-Arrays/task21.py @@ -0,0 +1,25 @@ +def compare(array1, array2): + arr = True + s1 = None + s2 = None + if len(array1) == len(array2): + s2 = True + pass + else: + s2 = False + if len(array1) == len(array2): + for i in range(int(len(array1))): + if array1[i] == array2[i]: + pass + else: + s1 = False + if s1 == None: + s1 = True + if s1 != False and s2 != False: + return arr + + +print(compare(["water","book","sky"] , ["water","book","sky"])) +print(compare([True,False] , [True,False,True])) +print(compare([5,3,1] , [5,3,1])) +print(compare([3,2,1] , [3,2])) diff --git a/06-Arrays/task22.py b/06-Arrays/task22.py new file mode 100644 index 000000000..8364e5795 --- /dev/null +++ b/06-Arrays/task22.py @@ -0,0 +1,17 @@ +array1 = [4,36,12,28,9,44,5] +array2 = [5,1,36] +array3 = [] +ist = 0 +for i in array1: + for j in array2: + if i == j: + ist = ist + 1 + if ist == 0: + array3.append(i) + ist = 0 + + +print(array3) + + + \ No newline at end of file diff --git a/06-Arrays/task5.py b/06-Arrays/task5.py new file mode 100644 index 000000000..1ede180b3 --- /dev/null +++ b/06-Arrays/task5.py @@ -0,0 +1,29 @@ +import random +arr1 = [3,7,0,4] +print(arr1) +arr2 = [[2,3],[7,1],[0,4]] +print(arr2) +arr3 = [7 for i in range(5)] +print(arr3) +arr4 = [i for i in range(1,10)] +print(arr4) +arr5 = [i*2 for i in range(1,10)] +print(arr5) +arr6 = [random.randint(1,20) for i in range(10)] +print(arr6) +arr7 = [[] for i in range(5)] +print(arr7) +arr8 = [[1 for i in range(2)] for j in range(4)] +print(arr8) +arr9 = [[random.randint(1,20) for i in range(3)] for j in range(5)] +print(arr9) +arr10 = [4,0,3] +print(arr10) +arr11 = [0 for i in range(50)] +print(arr11) +arr12 = [i for i in range(1,31)] +print(arr12) +arr13 = [random.randint(0,1) for i in range(20)] +print(arr13) +arr14 = [[False for i in range(5)] for j in range(2)] +print(arr14) \ No newline at end of file diff --git a/06-Arrays/task6.2.py b/06-Arrays/task6.2.py new file mode 100644 index 000000000..1c7be33fb --- /dev/null +++ b/06-Arrays/task6.2.py @@ -0,0 +1,25 @@ +array = [2,3,7,5,4] +#display the array +print(array) +#b. number of elements +print(len(array)) +#c. first value +print(array[0]) +#d. second value +print(array[1]) +#e. last value +print(array[-1]) +#f. last but one value +print(array[4]) +#g. sum of the first and last value +print(array[0] + array[-1]) +#h. middle value +middle = int(len(array)) +print(array[int(middle/2)]) +#i. all array values separated by a single space (use a loop statement) +for i in array: + print(i , end = " ") +print() +#j. all array values from first to middle separated by a single space (use a loop statement) +for i in range(int(len(array)/2 +1)): + print(array[i], end = " ") diff --git a/06-Arrays/task7.2.py b/06-Arrays/task7.2.py new file mode 100644 index 000000000..4bbd29b30 --- /dev/null +++ b/06-Arrays/task7.2.py @@ -0,0 +1,15 @@ +array = [1,2,3,4,5] +#a. subtract one from the first element of the array +array[0] = array[0] - 1 +print(array) + +#b. increase the last array element by 4 +array[4] = array[4] + 4 +print(array) +#c. multiple the middle array element by 2 +array[int(len(array)/2 )] = array[int(len(array)/2)] *2 +print(array) +#d. adds 3 to each value of the array (use a loop statement) +for i in range(int(len(array))): + array[i] = array[i] + 3 + print(array[i] , end = ' ') \ No newline at end of file diff --git a/06-Arrays/task8.2.py b/06-Arrays/task8.2.py new file mode 100644 index 000000000..866bdd3c9 --- /dev/null +++ b/06-Arrays/task8.2.py @@ -0,0 +1,11 @@ +maxi = mini = 0 +array = [-15, 8, -31, 47, -2, 19] +for i in array: + if i > maxi: + maxi = i +print(maxi) + +for i in array: + if i < mini: + mini = i +print(mini) \ No newline at end of file diff --git a/06-Arrays/task9.py b/06-Arrays/task9.py index e69de29bb..344b1a3ba 100644 --- a/06-Arrays/task9.py +++ b/06-Arrays/task9.py @@ -0,0 +1,10 @@ +array = ["Genowefa", "Onufry", "Celestyna", "Alojzy", "Pankracy"] +longest = "" +for i in array: + if int(len(longest)) < int(len(i)): + longest = i + else: + pass + +print(f"names {array}") +print(f"Longest name: {longest}") diff --git a/07-FileHandling/GrainsAndBread.txt b/07-FileHandling/GrainsAndBread.txt new file mode 100644 index 000000000..49bf18c3c --- /dev/null +++ b/07-FileHandling/GrainsAndBread.txt @@ -0,0 +1,5 @@ +Bread +Rice +All purpose flour +Breakfast cereal +Pasta \ No newline at end of file diff --git a/07-FileHandling/MeatAndFish.txt b/07-FileHandling/MeatAndFish.txt new file mode 100644 index 000000000..9a5f2c2bb --- /dev/null +++ b/07-FileHandling/MeatAndFish.txt @@ -0,0 +1,4 @@ +Skinless white meat +Tuna fish +Luncheon meat +Lean cuts of red meat diff --git a/07-FileHandling/copy.txt b/07-FileHandling/copy.txt new file mode 100644 index 000000000..e48507e8c --- /dev/null +++ b/07-FileHandling/copy.txt @@ -0,0 +1,83 @@ +You're a good soldier +Choosing your battles +Pick yourself up +And dust yourself off +And back in the saddle +You're on the front line +Everyone's watching +You know it's serious +We are getting closer +This isn't over +The pressure is on +You feel it +But you got it all +Believe it +When you fall, +Get up oh, oh +If you fall, +Get up eh, eh +Tsa mina mina zangalewa +Cause this is Africa +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +This time for Africa +Listen to your God +This is our motto +Your time to shine +Don't wait in line +Y vamos por todo +People are raising +Their expectations +Go on and feed them +This is your moment +No hesitations +Today's your day, +I feel it +You paved the way, +Believe it +If you get down +Get up oh, oh +When you get down +Get up eh, eh +Tsa mina mina zangalewa +This time for Africa +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +Anawa aa aa +Tsa mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +This time for Africa +Abuya lamajoni piki piki mama, one A to Zed +Athi susa lamajoni piki piki mama from east to west +Athi waka waka ma eh eh +Waka waka ma eh eh +Zonk' izizwe mazibuye +Cause this is Africa +(Tsa mina mina +Anawa aa aa +Tsa mina mina +Tsa mina mina +Ana wa aa aa) +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +Anawa aa aa +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +This time for Africa +Jungo oh, eh eh +Jungo oh, eh eh +Tsa mina mina zangalewa +Anawa aa aa +Jungo oh, eh eh +Jungo oh, eh eh +Tsa mina mina zangalewa +Anawa aa aa +This time for Africa +This time for Africa +We are all Africa +We are all Africa \ No newline at end of file diff --git a/07-FileHandling/copylines.txt b/07-FileHandling/copylines.txt new file mode 100644 index 000000000..e48507e8c --- /dev/null +++ b/07-FileHandling/copylines.txt @@ -0,0 +1,83 @@ +You're a good soldier +Choosing your battles +Pick yourself up +And dust yourself off +And back in the saddle +You're on the front line +Everyone's watching +You know it's serious +We are getting closer +This isn't over +The pressure is on +You feel it +But you got it all +Believe it +When you fall, +Get up oh, oh +If you fall, +Get up eh, eh +Tsa mina mina zangalewa +Cause this is Africa +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +This time for Africa +Listen to your God +This is our motto +Your time to shine +Don't wait in line +Y vamos por todo +People are raising +Their expectations +Go on and feed them +This is your moment +No hesitations +Today's your day, +I feel it +You paved the way, +Believe it +If you get down +Get up oh, oh +When you get down +Get up eh, eh +Tsa mina mina zangalewa +This time for Africa +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +Anawa aa aa +Tsa mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +This time for Africa +Abuya lamajoni piki piki mama, one A to Zed +Athi susa lamajoni piki piki mama from east to west +Athi waka waka ma eh eh +Waka waka ma eh eh +Zonk' izizwe mazibuye +Cause this is Africa +(Tsa mina mina +Anawa aa aa +Tsa mina mina +Tsa mina mina +Ana wa aa aa) +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +Anawa aa aa +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +This time for Africa +Jungo oh, eh eh +Jungo oh, eh eh +Tsa mina mina zangalewa +Anawa aa aa +Jungo oh, eh eh +Jungo oh, eh eh +Tsa mina mina zangalewa +Anawa aa aa +This time for Africa +This time for Africa +We are all Africa +We are all Africa \ No newline at end of file diff --git a/07-FileHandling/file.txt b/07-FileHandling/file.txt new file mode 100644 index 000000000..e48507e8c --- /dev/null +++ b/07-FileHandling/file.txt @@ -0,0 +1,83 @@ +You're a good soldier +Choosing your battles +Pick yourself up +And dust yourself off +And back in the saddle +You're on the front line +Everyone's watching +You know it's serious +We are getting closer +This isn't over +The pressure is on +You feel it +But you got it all +Believe it +When you fall, +Get up oh, oh +If you fall, +Get up eh, eh +Tsa mina mina zangalewa +Cause this is Africa +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +This time for Africa +Listen to your God +This is our motto +Your time to shine +Don't wait in line +Y vamos por todo +People are raising +Their expectations +Go on and feed them +This is your moment +No hesitations +Today's your day, +I feel it +You paved the way, +Believe it +If you get down +Get up oh, oh +When you get down +Get up eh, eh +Tsa mina mina zangalewa +This time for Africa +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +Anawa aa aa +Tsa mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +This time for Africa +Abuya lamajoni piki piki mama, one A to Zed +Athi susa lamajoni piki piki mama from east to west +Athi waka waka ma eh eh +Waka waka ma eh eh +Zonk' izizwe mazibuye +Cause this is Africa +(Tsa mina mina +Anawa aa aa +Tsa mina mina +Tsa mina mina +Ana wa aa aa) +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +Anawa aa aa +Tza mina mina eh eh +Waka waka eh eh +Tsa mina mina zangalewa +This time for Africa +Jungo oh, eh eh +Jungo oh, eh eh +Tsa mina mina zangalewa +Anawa aa aa +Jungo oh, eh eh +Jungo oh, eh eh +Tsa mina mina zangalewa +Anawa aa aa +This time for Africa +This time for Africa +We are all Africa +We are all Africa \ No newline at end of file diff --git a/07-FileHandling/filename.txt b/07-FileHandling/filename.txt new file mode 100644 index 000000000..223b2f40c --- /dev/null +++ b/07-FileHandling/filename.txt @@ -0,0 +1,5 @@ +dfsf +fsfs +hg +dgd +df \ No newline at end of file diff --git a/07-FileHandling/intigers.txt b/07-FileHandling/intigers.txt new file mode 100644 index 000000000..96cc55885 --- /dev/null +++ b/07-FileHandling/intigers.txt @@ -0,0 +1,50 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 diff --git a/07-FileHandling/powers.txt b/07-FileHandling/powers.txt new file mode 100644 index 000000000..5f3e2ff3e --- /dev/null +++ b/07-FileHandling/powers.txt @@ -0,0 +1,10 @@ +1 , 1 , 1 +2 , 4 , 8 +3 , 9 , 27 +4 , 16 , 64 +5 , 25 , 125 +6 , 36 , 216 +7 , 49 , 343 +8 , 64 , 512 +9 , 81 , 729 +10 , 100 , 1000 diff --git a/07-FileHandling/randomint.txt b/07-FileHandling/randomint.txt new file mode 100644 index 000000000..cbae83f10 --- /dev/null +++ b/07-FileHandling/randomint.txt @@ -0,0 +1,50 @@ +636 +349 +161 +779 +214 +837 +328 +803 +950 +866 +984 +775 +984 +472 +658 +608 +163 +346 +931 +378 +913 +954 +679 +721 +532 +175 +502 +196 +837 +280 +215 +833 +955 +223 +731 +436 +962 +958 +312 +783 +669 +601 +536 +355 +264 +200 +136 +329 +636 +528 diff --git a/07-FileHandling/shoppinglist.txt b/07-FileHandling/shoppinglist.txt new file mode 100644 index 000000000..03431da4a --- /dev/null +++ b/07-FileHandling/shoppinglist.txt @@ -0,0 +1,21 @@ +Skinless white meat +Tuna fish +Luncheon meat +Lean cuts of red meat +Skinless white meat +Tuna fish +Luncheon meat +Lean cuts of red meat +Bread +Rice +All purpose flour +Breakfast cereal +Pasta Skinless white meat +Tuna fish +Luncheon meat +Lean cuts of red meat +Bread +Rice +All purpose flour +Breakfast cereal +Pasta \ No newline at end of file diff --git a/07-FileHandling/task13.py b/07-FileHandling/task13.py new file mode 100644 index 000000000..75796f796 --- /dev/null +++ b/07-FileHandling/task13.py @@ -0,0 +1,5 @@ +with open("filename.txt") as file: + for line in file: + print(line, end = "") +file.close() + diff --git a/07-FileHandling/task14.py b/07-FileHandling/task14.py new file mode 100644 index 000000000..63d680111 --- /dev/null +++ b/07-FileHandling/task14.py @@ -0,0 +1,11 @@ +file = open(input("Enter file name:")) +lines = 1 +for i in file: + lines = lines +1 + +print(lines-1) + + + + +file.close() \ No newline at end of file diff --git a/07-FileHandling/task15.py b/07-FileHandling/task15.py new file mode 100644 index 000000000..e59c5155e --- /dev/null +++ b/07-FileHandling/task15.py @@ -0,0 +1,9 @@ +import time +file = open("file.txt") +lines = 0 +for i in file: + print(i, end = "") + lines = lines +1 + if lines == 5: + time.sleep(5) + lines = 0 \ No newline at end of file diff --git a/07-FileHandling/task16.py b/07-FileHandling/task16.py new file mode 100644 index 000000000..3f2d80514 --- /dev/null +++ b/07-FileHandling/task16.py @@ -0,0 +1,10 @@ +file1 = open("file.txt") +text = file1.read() +file1.close() +file2 = open("copy.txt", "r") +if file2.writable(): + file2.write(text) +else: + print("File is not writable") +file2.close() + diff --git a/07-FileHandling/task17.py b/07-FileHandling/task17.py new file mode 100644 index 000000000..faa22d5a0 --- /dev/null +++ b/07-FileHandling/task17.py @@ -0,0 +1,7 @@ +file1 = open("file.txt") +file2 = open("copylines.txt", "w") +text = "" +for i in file1: + text = text + i +file1.close() +file2.write(text) \ No newline at end of file diff --git a/07-FileHandling/task18.py b/07-FileHandling/task18.py new file mode 100644 index 000000000..7c3b769c6 --- /dev/null +++ b/07-FileHandling/task18.py @@ -0,0 +1,8 @@ +file1 = open("MeatAndFish.txt", "r") +text1 = file1.read() +file1.close() +file2 = open("GrainsAndBread.txt", "r") +text2 = file2.read() +file3 = open("shoppinglist.txt", "a") +file3.write(text1) +file3.write(text2) \ No newline at end of file diff --git a/07-FileHandling/task19.py b/07-FileHandling/task19.py new file mode 100644 index 000000000..e08a9e66a --- /dev/null +++ b/07-FileHandling/task19.py @@ -0,0 +1,5 @@ +file = open("intigers.txt", "w") +for i in range(1,51): + i = str(i) + "\n" + file.write(i) +file.close() \ No newline at end of file diff --git a/07-FileHandling/task20.py b/07-FileHandling/task20.py new file mode 100644 index 000000000..3b7cf71c3 --- /dev/null +++ b/07-FileHandling/task20.py @@ -0,0 +1,7 @@ +import random +file = open("randomint.txt", "w") +for i in range(50): + i = random.randint(100,1000) + i = str(i) + "\n" + file.write(i) +file.close() \ No newline at end of file diff --git a/07-FileHandling/task21.py b/07-FileHandling/task21.py new file mode 100644 index 000000000..6d2403a28 --- /dev/null +++ b/07-FileHandling/task21.py @@ -0,0 +1,9 @@ +file = open("powers.txt", "w") +pow2 = 0 +pow3 = 0 +st = "" +for i in range(1,11): + pow2 = i* i + pow3 = i* i * i + st = str(i) + " , " + str(pow2) + " , " + str(pow3) + "\n" + file.write(st) diff --git a/07-FileHandling/task22.py b/07-FileHandling/task22.py new file mode 100644 index 000000000..e69de29bb From b2a89834ac3624a2120bfd5093eea7b3581e289b Mon Sep 17 00:00:00 2001 From: kulpiq Date: Sun, 4 Dec 2022 19:16:27 +0100 Subject: [PATCH 08/20] add --- 07-FileHandling/students.txt | 6 ++++++ 07-FileHandling/task22.py | 6 ++++++ 07-FileHandling/task23.py | 9 +++++++++ 07-FileHandling/task24.py | 4 ++++ 07-FileHandling/task25.py | 4 ++++ 07-FileHandling/task26.py | 6 ++++++ 6 files changed, 35 insertions(+) create mode 100644 07-FileHandling/students.txt create mode 100644 07-FileHandling/task23.py create mode 100644 07-FileHandling/task24.py create mode 100644 07-FileHandling/task25.py create mode 100644 07-FileHandling/task26.py diff --git a/07-FileHandling/students.txt b/07-FileHandling/students.txt new file mode 100644 index 000000000..41ffbffef --- /dev/null +++ b/07-FileHandling/students.txt @@ -0,0 +1,6 @@ +first_name,last_name,age,gender,email +Decca,Blackstone,52,Male,dblackstone0@time.com +Elena,Rechert,27,Female,erechert1@ucoz.com +Bibbye,Norree,26,Female,bnorree2@reddit.com +Alasdair,McCoole,53,Male,amccoole3@foxnews.com +Hogan,Hatrey,26,Male,hhatrey4@zimbio.com \ No newline at end of file diff --git a/07-FileHandling/task22.py b/07-FileHandling/task22.py index e69de29bb..7915a418d 100644 --- a/07-FileHandling/task22.py +++ b/07-FileHandling/task22.py @@ -0,0 +1,6 @@ +import csv +with open("students.txt", newline = '') as file: + text = csv.DictReader(file) + for row in text: + if int(row['age']) < 30: + print(row['first_name'], row['last_name'], row ["email"]) diff --git a/07-FileHandling/task23.py b/07-FileHandling/task23.py new file mode 100644 index 000000000..90ae93ff5 --- /dev/null +++ b/07-FileHandling/task23.py @@ -0,0 +1,9 @@ +import re + +message = "Tuesday: 22C, Wednesday: 21C, Thursday: 26C " +temperatures = re.findall("\d{2}",message) +sum = 0 +for i in temperatures: + sum = sum + int(i) +average = sum / int(len(temperatures)) +print(average) \ No newline at end of file diff --git a/07-FileHandling/task24.py b/07-FileHandling/task24.py new file mode 100644 index 000000000..9857bf8e7 --- /dev/null +++ b/07-FileHandling/task24.py @@ -0,0 +1,4 @@ +import re +text = "To be, or not to be, that is the question" +volwes = re.findall(r'a|e|i|o|u|y',text) +print(len(volwes)) \ No newline at end of file diff --git a/07-FileHandling/task25.py b/07-FileHandling/task25.py new file mode 100644 index 000000000..d62f638e0 --- /dev/null +++ b/07-FileHandling/task25.py @@ -0,0 +1,4 @@ +import re +text = "To be, or not to be, that is the question" +number_of_words = re.findall(r'\w+' ,text) +print(len(number_of_words)) diff --git a/07-FileHandling/task26.py b/07-FileHandling/task26.py new file mode 100644 index 000000000..bb14e9819 --- /dev/null +++ b/07-FileHandling/task26.py @@ -0,0 +1,6 @@ +import re +file = open("file.txt", "r") +text = file.read() +file.close() +sixLettersOrMore = re.findall(r'w{6}',text) +print(sixLettersOrMore) \ No newline at end of file From 8ebef303919b0e75c53f3a5a090eeb45198a6c19 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Wed, 14 Dec 2022 11:08:03 +0100 Subject: [PATCH 09/20] add --- 10-ObjectOrientedProgramming/task10.py | 25 ++++++++++++++++++ 10-ObjectOrientedProgramming/task11.py | 35 ++++++++++++++++++++++++++ 10-ObjectOrientedProgramming/task12.py | 35 ++++++++++++++++++++++++++ 10-ObjectOrientedProgramming/task8.py | 24 ++++++++++++++++++ 10-ObjectOrientedProgramming/task9.py | 23 +++++++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 10-ObjectOrientedProgramming/task10.py create mode 100644 10-ObjectOrientedProgramming/task11.py create mode 100644 10-ObjectOrientedProgramming/task12.py create mode 100644 10-ObjectOrientedProgramming/task8.py create mode 100644 10-ObjectOrientedProgramming/task9.py diff --git a/10-ObjectOrientedProgramming/task10.py b/10-ObjectOrientedProgramming/task10.py new file mode 100644 index 000000000..c3f2db4ae --- /dev/null +++ b/10-ObjectOrientedProgramming/task10.py @@ -0,0 +1,25 @@ +class TV(): + def __init__(self): + self.is_on = False + self.channel_no = 1 + def turn_on(self): + self.is_on = True + + def turn_off(self): + self.is_on = False + + def set_channel(self,new_channel_no): + self.channel_no = new_channel_no + def show_status(self): + if self.is_on == True: + print("TV is on, channel", self.channel_no) + + else: + print("TV is off") + +tv1 = TV() +tv1.show_status() +tv1.turn_on() +tv1.show_status() +tv1.set_channel(51) +tv1.show_status() \ No newline at end of file diff --git a/10-ObjectOrientedProgramming/task11.py b/10-ObjectOrientedProgramming/task11.py new file mode 100644 index 000000000..9b0231faa --- /dev/null +++ b/10-ObjectOrientedProgramming/task11.py @@ -0,0 +1,35 @@ +class TV(): + def __init__(self): + self.is_on = False + self.channel_no = 1 + self.channel_list = [] + def turn_on(self): + self.is_on = True + + def turn_off(self): + self.is_on = False + + def set_channel(self,new_channel_no): + self.channel_no = new_channel_no + + def set_channels(self, channel_list): + self.channel_list = channel_list + + def show_chanels(self): + print(self.channel_list) + + + def show_status(self): + if self.is_on == True: + print("TV is on, channel", self.channel_no) + + else: + print("TV is off") + +tv1 = TV() +tv1.show_status() +tv1.turn_on() +tv1.show_status() +tv1.set_channel(51) +tv1.show_status(0) +tv1.show_chanels() diff --git a/10-ObjectOrientedProgramming/task12.py b/10-ObjectOrientedProgramming/task12.py new file mode 100644 index 000000000..187a3aa6b --- /dev/null +++ b/10-ObjectOrientedProgramming/task12.py @@ -0,0 +1,35 @@ +class TV(): + def __init__(self): + self.is_on = False + self.channel_no = 1 + self.channel_list = [] + def turn_on(self): + self.is_on = True + + def turn_off(self): + self.is_on = False + + def set_channel(self,new_channel_no): + self.channel_no = new_channel_no + + def set_channels(self, channel_list): + self.channel_list = channel_list + + + def show_chanels(self): + if self.is_on == True: + print(self.channel_list) + + def show_status(self): + if self.is_on == True: + print("TV is on, channel", self.channel_no, "and the name is", self.channel_list[self.channel_no -1]) + + else: + print("TV is off") + +tv1 = TV() +tv1.show_status() +tv1.turn_on() +tv1.show_status() +tv1.set_channel(3) +tv1.show_status() \ No newline at end of file diff --git a/10-ObjectOrientedProgramming/task8.py b/10-ObjectOrientedProgramming/task8.py new file mode 100644 index 000000000..8f57a512e --- /dev/null +++ b/10-ObjectOrientedProgramming/task8.py @@ -0,0 +1,24 @@ +class TV(): + def __init__(self): + self.is_on = False + + def turn_on(self): + self.is_on = True + + def turn_off(self): + self.is_on = False + + def show_status(self): + if self.is_on == True: + print("TV is on") + else: + print("TV is off") + + +tv1 = TV() +tv1.show_status() +tv1.turn_on() +tv1.show_status() +tv1.turn_off() +tv1.show_status() + diff --git a/10-ObjectOrientedProgramming/task9.py b/10-ObjectOrientedProgramming/task9.py new file mode 100644 index 000000000..ac9d8f1d1 --- /dev/null +++ b/10-ObjectOrientedProgramming/task9.py @@ -0,0 +1,23 @@ +class TV(): + def __init__(self): + self.is_on = False + self.channel_no = 1 + def turn_on(self): + self.is_on = True + + def turn_off(self): + self.is_on = False + + def show_status(self): + if self.is_on == True: + print("TV is on, channel", self.channel_no) + + else: + print("TV is off") + +tv1 = TV() +tv1.show_status() +tv1.turn_on() +tv1.show_status() +tv1.turn_off() +tv1.show_status() From 69be704a7984a345b9ba679ab43fe9977ce5244a Mon Sep 17 00:00:00 2001 From: s-013-19 Date: Wed, 21 Dec 2022 11:13:37 +0100 Subject: [PATCH 10/20] add --- 11-ObjectAttributesAndMethods/task4.py | 10 ++++++++++ 11-ObjectAttributesAndMethods/task5.py | 13 +++++++++++++ 11-ObjectAttributesAndMethods/task6.py | 23 +++++++++++++++++++++++ 11-ObjectAttributesAndMethods/task7.py | 15 +++++++++++++++ 11-ObjectAttributesAndMethods/task8.py | 9 +++++++++ 11-ObjectAttributesAndMethods/task9.py | 11 +++++++++++ 6 files changed, 81 insertions(+) create mode 100644 11-ObjectAttributesAndMethods/task4.py create mode 100644 11-ObjectAttributesAndMethods/task5.py create mode 100644 11-ObjectAttributesAndMethods/task6.py create mode 100644 11-ObjectAttributesAndMethods/task7.py create mode 100644 11-ObjectAttributesAndMethods/task8.py create mode 100644 11-ObjectAttributesAndMethods/task9.py diff --git a/11-ObjectAttributesAndMethods/task4.py b/11-ObjectAttributesAndMethods/task4.py new file mode 100644 index 000000000..90098db51 --- /dev/null +++ b/11-ObjectAttributesAndMethods/task4.py @@ -0,0 +1,10 @@ +class University(): + + def __init__(self, name): + self.name = name + + def __str__(self): + return self.name + "is the best!" + +my_university = University('UEK Kraków') +print(my_university) diff --git a/11-ObjectAttributesAndMethods/task5.py b/11-ObjectAttributesAndMethods/task5.py new file mode 100644 index 000000000..71e8259ba --- /dev/null +++ b/11-ObjectAttributesAndMethods/task5.py @@ -0,0 +1,13 @@ +class Pieces_of_music: + def __init__(self, artist, track_title, album, year): + self.artist = artist + self.track_title = track_title + self.album = album + self.year = year + def __str__(self): + return f" Performer: {self.artist}\n Song: {self.track_title}\n Album: {self.album}\n Year: {self.year}\n" + +music1 = Pieces_of_music("Ed Sheeran", "Hearts Don't Break Around Here" , "Divide", "2017") +music2 = Pieces_of_music("Michael Jackson", "Beat It", "Thriller", "1985") +print(music1) +print(music2) \ No newline at end of file diff --git a/11-ObjectAttributesAndMethods/task6.py b/11-ObjectAttributesAndMethods/task6.py new file mode 100644 index 000000000..01423abe2 --- /dev/null +++ b/11-ObjectAttributesAndMethods/task6.py @@ -0,0 +1,23 @@ +# class definition +class Film(): + + # class variables + cinema = "Multikino" + + def __init__(self, title): + self.title = title + + def __str__(self): + return f"{self.title} ({Film.cinema})" + +# program +film1 = Film("The Shawshank Redemption") +print(film1) +film2 = Film("Pulp Fiction") +print(film2) + +# renaming the cinema (changing the value +# of a class variable) +Film.cinema = "Cinema City " +print(film1) +print(film2) diff --git a/11-ObjectAttributesAndMethods/task7.py b/11-ObjectAttributesAndMethods/task7.py new file mode 100644 index 000000000..b829a7d17 --- /dev/null +++ b/11-ObjectAttributesAndMethods/task7.py @@ -0,0 +1,15 @@ +class Student(): + + id = 100000 + def __init__(self, name, surname, field_of_study): + self.name = name + self.surname = surname + self.field_of_study = field_of_study + Student.id += 1 + def __str__(self): + return f"{self.name} {self.surname}, ({Student.id}), {self.field_of_study}, UEK Krakow" + +student1 = Student("Anna", "MAJ", "Applied Informatics") +print(student1) +student2 = Student("Adam", "Nowak", "Applied Informatics") +print(student2) \ No newline at end of file diff --git a/11-ObjectAttributesAndMethods/task8.py b/11-ObjectAttributesAndMethods/task8.py new file mode 100644 index 000000000..fd15f2b02 --- /dev/null +++ b/11-ObjectAttributesAndMethods/task8.py @@ -0,0 +1,9 @@ +class Arrays(): + + @staticmethod + def print_in_col(array): + for c in array: + print(c) + +my_array = [4,1,8,7,2] +Arrays.print_in_col(my_array) diff --git a/11-ObjectAttributesAndMethods/task9.py b/11-ObjectAttributesAndMethods/task9.py new file mode 100644 index 000000000..92a3c7fd7 --- /dev/null +++ b/11-ObjectAttributesAndMethods/task9.py @@ -0,0 +1,11 @@ +class Arrays(): + list= [] + @staticmethod + def creating_array(number_of_array_elements, value_of_array_elements): + for i in number_of_array_elements: + if i< number_of_array_elements: + list.append(value_of_array_elements) + + @staticmethod + def c_array(number_of_array_elements, value_from, value_to): + From d0feb09280a7a04a4892583366112c394fcb081b Mon Sep 17 00:00:00 2001 From: kulpiq Date: Fri, 20 Oct 2023 09:53:17 +0200 Subject: [PATCH 11/20] tasks1 --- 02-TypesAndVariables/t18.py | 10 ++++++++++ 02-TypesAndVariables/t19.py | 4 ++++ 02-TypesAndVariables/t20.py | 4 ++++ 02-TypesAndVariables/t21.py | 5 +++++ 02-TypesAndVariables/t22.py | 3 +++ 02-TypesAndVariables/t23.py | 7 +++++++ 02-TypesAndVariables/t24.py | 2 ++ 7 files changed, 35 insertions(+) create mode 100644 02-TypesAndVariables/t18.py create mode 100644 02-TypesAndVariables/t19.py create mode 100644 02-TypesAndVariables/t20.py create mode 100644 02-TypesAndVariables/t21.py create mode 100644 02-TypesAndVariables/t22.py create mode 100644 02-TypesAndVariables/t23.py create mode 100644 02-TypesAndVariables/t24.py diff --git a/02-TypesAndVariables/t18.py b/02-TypesAndVariables/t18.py new file mode 100644 index 000000000..7b7c168fe --- /dev/null +++ b/02-TypesAndVariables/t18.py @@ -0,0 +1,10 @@ +x = 7 +y = 34 +print(f'Value of x: {x}') +print(f'Value of y: {y}') +z = 0 +z = x +x = y +y = z +print(f'Value of x after swapping: {x}') +print(f'Value of y after swapping; {y}') \ No newline at end of file diff --git a/02-TypesAndVariables/t19.py b/02-TypesAndVariables/t19.py new file mode 100644 index 000000000..3755a1eeb --- /dev/null +++ b/02-TypesAndVariables/t19.py @@ -0,0 +1,4 @@ +side = int(input("Enter cube side: ")) +print(f"Cube side: {side}") +print(f'Cube volume: {side**3}') +print(f"Cube surface area: {side**2*6}") \ No newline at end of file diff --git a/02-TypesAndVariables/t20.py b/02-TypesAndVariables/t20.py new file mode 100644 index 000000000..747d9f0b1 --- /dev/null +++ b/02-TypesAndVariables/t20.py @@ -0,0 +1,4 @@ +a = int(input("Number one: ")) +b = int(input("Number two: ")) +print(f"Division result: {a/b}") +print(f"Remainder: {a%b}") \ No newline at end of file diff --git a/02-TypesAndVariables/t21.py b/02-TypesAndVariables/t21.py new file mode 100644 index 000000000..db76bce63 --- /dev/null +++ b/02-TypesAndVariables/t21.py @@ -0,0 +1,5 @@ +import math +height = int(input("Ender your height: ")) +feet = int(height/30.48) +inches = math.ceil((height-30.48*feet)*0.39) +print(f'I am {height}cm tall, i.e {feet} feet and {inches} inches') \ No newline at end of file diff --git a/02-TypesAndVariables/t22.py b/02-TypesAndVariables/t22.py new file mode 100644 index 000000000..dd2198fb4 --- /dev/null +++ b/02-TypesAndVariables/t22.py @@ -0,0 +1,3 @@ +a = 3 +b = 5 +print(f'{a} - {b} = {a-b}') \ No newline at end of file diff --git a/02-TypesAndVariables/t23.py b/02-TypesAndVariables/t23.py new file mode 100644 index 000000000..cf751f53b --- /dev/null +++ b/02-TypesAndVariables/t23.py @@ -0,0 +1,7 @@ +a = float(input("Enter a:")) +b = float(input("Enter b:")) +c = float(input("Enter c:")) +s = (a+b+c)/2 +area = (s*(s - a)*(s - b)*(s - c))**(1/2) +print(f'Triangle area: {area}') +print(f'Triangle cimcumference: {a+b+c}') \ No newline at end of file diff --git a/02-TypesAndVariables/t24.py b/02-TypesAndVariables/t24.py new file mode 100644 index 000000000..c63591cc4 --- /dev/null +++ b/02-TypesAndVariables/t24.py @@ -0,0 +1,2 @@ +regnum = input('Enter vehicle registration number: ') +print(regnum[:2] == 'KR') \ No newline at end of file From 9d9090e9832a0f438e36859a1b2f0de8334e93e9 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Wed, 25 Oct 2023 19:56:05 +0200 Subject: [PATCH 12/20] tasks --- 04-Subroutines/__pycache__/t19.cpython-311.pyc | Bin 0 -> 657 bytes 04-Subroutines/__pycache__/t20.cpython-311.pyc | Bin 0 -> 152 bytes 04-Subroutines/t12.py | 5 +++++ 04-Subroutines/t13.py | 6 ++++++ 04-Subroutines/t14.py | 5 +++++ 04-Subroutines/t15.py | 9 +++++++++ 04-Subroutines/t16.py | 7 +++++++ 04-Subroutines/t17.py | 7 +++++++ 04-Subroutines/t18.py | 14 ++++++++++++++ 04-Subroutines/t19.py | 14 ++++++++++++++ 04-Subroutines/t19i.py | 6 ++++++ 04-Subroutines/t20.py | 8 ++++++++ 12 files changed, 81 insertions(+) create mode 100644 04-Subroutines/__pycache__/t19.cpython-311.pyc create mode 100644 04-Subroutines/__pycache__/t20.cpython-311.pyc create mode 100644 04-Subroutines/t12.py create mode 100644 04-Subroutines/t13.py create mode 100644 04-Subroutines/t14.py create mode 100644 04-Subroutines/t15.py create mode 100644 04-Subroutines/t16.py create mode 100644 04-Subroutines/t17.py create mode 100644 04-Subroutines/t18.py create mode 100644 04-Subroutines/t19.py create mode 100644 04-Subroutines/t19i.py create mode 100644 04-Subroutines/t20.py diff --git a/04-Subroutines/__pycache__/t19.cpython-311.pyc b/04-Subroutines/__pycache__/t19.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1c1ee767a1e1d1b6e02eeb11342ae5b29110ddd5 GIT binary patch literal 657 zcmY*Wze^)g5T3X1ZP;vn6*l>Cg^fj&RU-;2Vk0&O3KFl8g(bR+w|H6O+e9!Zq_B7^ z78b(&2Y1Ld_opOBim;V%mEA%*E9b2m-C<|=zBk|O%)IwIm(v05``(%Z1mM3U@20+i z@jZf{V8b;WfJ1C@qR0&2RKQWt!B&1@?H}}4OELlz9ZhDE?30cqGf76kR_n1>Q%94Y z*qOfhcmn~>ORmTz#uFx|;!~HBDcux6HwO^slx_hLe5n4Sst#4U`y^|gJ%R&vQrX<~QHrzUdparJAw0Vzyc}b8*?IcMkb!r|o)Bw~+#`(R3^;R9oEj+FZUTmn(4%!?U*0JheMN zoK2ob8c%hBAfkkjNKr{4f=S2&%ZlzlTI$o%BTM(T#jKdU+aKuVp>P{wCAAY(d13PUi1CZpd`7k%3-8Bam&;sY}yBjX1K7*WIw6axUvZ6Esp literal 0 HcmV?d00001 diff --git a/04-Subroutines/t12.py b/04-Subroutines/t12.py new file mode 100644 index 000000000..c118a05b9 --- /dev/null +++ b/04-Subroutines/t12.py @@ -0,0 +1,5 @@ +print(max(7,5,6,3,8,2)) +print(bin(304)) +print(hex(304)) +print(ord('€')) +print(abs(-17)) diff --git a/04-Subroutines/t13.py b/04-Subroutines/t13.py new file mode 100644 index 000000000..9b43add13 --- /dev/null +++ b/04-Subroutines/t13.py @@ -0,0 +1,6 @@ +import math + +print(math.log(5)) +print(math.exp(3)) +print(math.sqrt(7)) +print(math.sin(math.radians(90))) diff --git a/04-Subroutines/t14.py b/04-Subroutines/t14.py new file mode 100644 index 000000000..5adfcc911 --- /dev/null +++ b/04-Subroutines/t14.py @@ -0,0 +1,5 @@ +def display_program_name(): + print('Applied informatics') + +for i in range(4): + display_program_name() diff --git a/04-Subroutines/t15.py b/04-Subroutines/t15.py new file mode 100644 index 000000000..c61e16d6d --- /dev/null +++ b/04-Subroutines/t15.py @@ -0,0 +1,9 @@ +def phone_keyboard(): + for i in range(1,10): + if i%3 ==0: + print(i) + else: + print(i, end = " ") + + +phone_keyboard() \ No newline at end of file diff --git a/04-Subroutines/t16.py b/04-Subroutines/t16.py new file mode 100644 index 000000000..9ea3616c7 --- /dev/null +++ b/04-Subroutines/t16.py @@ -0,0 +1,7 @@ +def product(x,y): + return x*y + +a = 3 +b = 4 + +print(f"The product of {a} and {b} is {product(a,b)}") diff --git a/04-Subroutines/t17.py b/04-Subroutines/t17.py new file mode 100644 index 000000000..bc33da5c5 --- /dev/null +++ b/04-Subroutines/t17.py @@ -0,0 +1,7 @@ +def different(n1,n2,n3): + return(n1 != n2 and n1 !=n3 and n2 != n3) + +n1 = int(input("Enter first num: ")) +n2 = int(input("Enter second num: ")) +n3 = int(input("Enter third num: ")) +print(different(n1,n2,n3)) \ No newline at end of file diff --git a/04-Subroutines/t18.py b/04-Subroutines/t18.py new file mode 100644 index 000000000..58fedf54c --- /dev/null +++ b/04-Subroutines/t18.py @@ -0,0 +1,14 @@ +def numbers(n): + arr = [] + for i in range(n): + arr.append(str(i+1)) + return " ".join(arr) +print(numbers(9)) + +def number(n): + num = '' + for m in range(1, n+1): + num+=str(m) + num+= ' ' + return num +print(number(6)) \ No newline at end of file diff --git a/04-Subroutines/t19.py b/04-Subroutines/t19.py new file mode 100644 index 000000000..4fd3c6fb1 --- /dev/null +++ b/04-Subroutines/t19.py @@ -0,0 +1,14 @@ +def sum_digits(n): + sum = 0 + while n > 0: + sum += n % 10 + n //= 10 + return sum + +if __name__ == "__main__": + # check if function works + print(sum_digits(7182)) + print(sum_digits(0)) + print(sum_digits(333)) + + diff --git a/04-Subroutines/t19i.py b/04-Subroutines/t19i.py new file mode 100644 index 000000000..d8357e463 --- /dev/null +++ b/04-Subroutines/t19i.py @@ -0,0 +1,6 @@ +import t19 + +number = int(input("Enter a number: ")) +sum_d = t19.sum_digits(number) +msg = f"Sum of digits {number} is {sum_d}" +print(msg) diff --git a/04-Subroutines/t20.py b/04-Subroutines/t20.py new file mode 100644 index 000000000..794afe6a7 --- /dev/null +++ b/04-Subroutines/t20.py @@ -0,0 +1,8 @@ +def read_number(): + a = int(input("Enter number: ")) + return a + + + +if __name__ == '__main__': + print(read_number()) \ No newline at end of file From c937fb27a7d6c59812ff012536ebd9934e30fa2d Mon Sep 17 00:00:00 2001 From: kulpiq Date: Wed, 1 Nov 2023 18:06:35 +0100 Subject: [PATCH 13/20] =?UTF-8?q?=C5=9Broda?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-TypesAndVariables/t35.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 02-TypesAndVariables/t35.py diff --git a/02-TypesAndVariables/t35.py b/02-TypesAndVariables/t35.py new file mode 100644 index 000000000..886f8bcec --- /dev/null +++ b/02-TypesAndVariables/t35.py @@ -0,0 +1,12 @@ +def tree_cut(): + circumference = float(input("Enter tree circumference: ")) + diameter = circumference/3.14 + if diameter >= 50: + check = True + else: + check = False + result = f"Tree can be cut down: {check}" + + return result + +print(tree_cut()) \ No newline at end of file From df02f699e0cf7f8cf2d0c48348780a8618b433ad Mon Sep 17 00:00:00 2001 From: kulpiq Date: Wed, 1 Nov 2023 18:15:49 +0100 Subject: [PATCH 14/20] wtorek --- 02-TypesAndVariables/{ => stare}/task10.py | 0 02-TypesAndVariables/{ => stare}/task11.py | 0 02-TypesAndVariables/{ => stare}/task7.py | 0 02-TypesAndVariables/{ => stare}/task8.py | 0 02-TypesAndVariables/{ => stare}/task9.py | 0 02-TypesAndVariables/t24.py | 2 +- 02-TypesAndVariables/t25.py | 8 ++++++++ 02-TypesAndVariables/t26.py | 11 +++++++++++ 02-TypesAndVariables/t27.py | 10 ++++++++++ 02-TypesAndVariables/t28.py | 17 +++++++++++++++++ 02-TypesAndVariables/t29.py | 9 +++++++++ 02-TypesAndVariables/t30.py | 15 +++++++++++++++ 02-TypesAndVariables/t31.py | 14 ++++++++++++++ 02-TypesAndVariables/t32.py | 9 +++++++++ 02-TypesAndVariables/t33.py | 10 ++++++++++ 02-TypesAndVariables/t34.py | 12 ++++++++++++ 02-TypesAndVariables/t36.py | 9 +++++++++ 02-TypesAndVariables/t37.py | 14 ++++++++++++++ 02-TypesAndVariables/t38.py | 7 +++++++ 02-TypesAndVariables/t39.py | 12 ++++++++++++ 02-TypesAndVariables/t40.py | 7 +++++++ 02-TypesAndVariables/t41.py | 8 ++++++++ 02-TypesAndVariables/t42.py | 16 ++++++++++++++++ 02-TypesAndVariables/t43.py | 10 ++++++++++ 24 files changed, 199 insertions(+), 1 deletion(-) rename 02-TypesAndVariables/{ => stare}/task10.py (100%) rename 02-TypesAndVariables/{ => stare}/task11.py (100%) rename 02-TypesAndVariables/{ => stare}/task7.py (100%) rename 02-TypesAndVariables/{ => stare}/task8.py (100%) rename 02-TypesAndVariables/{ => stare}/task9.py (100%) create mode 100644 02-TypesAndVariables/t25.py create mode 100644 02-TypesAndVariables/t26.py create mode 100644 02-TypesAndVariables/t27.py create mode 100644 02-TypesAndVariables/t28.py create mode 100644 02-TypesAndVariables/t29.py create mode 100644 02-TypesAndVariables/t30.py create mode 100644 02-TypesAndVariables/t31.py create mode 100644 02-TypesAndVariables/t32.py create mode 100644 02-TypesAndVariables/t33.py create mode 100644 02-TypesAndVariables/t34.py create mode 100644 02-TypesAndVariables/t36.py create mode 100644 02-TypesAndVariables/t37.py create mode 100644 02-TypesAndVariables/t38.py create mode 100644 02-TypesAndVariables/t39.py create mode 100644 02-TypesAndVariables/t40.py create mode 100644 02-TypesAndVariables/t41.py create mode 100644 02-TypesAndVariables/t42.py create mode 100644 02-TypesAndVariables/t43.py diff --git a/02-TypesAndVariables/task10.py b/02-TypesAndVariables/stare/task10.py similarity index 100% rename from 02-TypesAndVariables/task10.py rename to 02-TypesAndVariables/stare/task10.py diff --git a/02-TypesAndVariables/task11.py b/02-TypesAndVariables/stare/task11.py similarity index 100% rename from 02-TypesAndVariables/task11.py rename to 02-TypesAndVariables/stare/task11.py diff --git a/02-TypesAndVariables/task7.py b/02-TypesAndVariables/stare/task7.py similarity index 100% rename from 02-TypesAndVariables/task7.py rename to 02-TypesAndVariables/stare/task7.py diff --git a/02-TypesAndVariables/task8.py b/02-TypesAndVariables/stare/task8.py similarity index 100% rename from 02-TypesAndVariables/task8.py rename to 02-TypesAndVariables/stare/task8.py diff --git a/02-TypesAndVariables/task9.py b/02-TypesAndVariables/stare/task9.py similarity index 100% rename from 02-TypesAndVariables/task9.py rename to 02-TypesAndVariables/stare/task9.py diff --git a/02-TypesAndVariables/t24.py b/02-TypesAndVariables/t24.py index c63591cc4..d7c867d07 100644 --- a/02-TypesAndVariables/t24.py +++ b/02-TypesAndVariables/t24.py @@ -1,2 +1,2 @@ regnum = input('Enter vehicle registration number: ') -print(regnum[:2] == 'KR') \ No newline at end of file +print(regnum[:2] == 'KR' or regnum[:2] == 'KK') \ No newline at end of file diff --git a/02-TypesAndVariables/t25.py b/02-TypesAndVariables/t25.py new file mode 100644 index 000000000..7bf97310f --- /dev/null +++ b/02-TypesAndVariables/t25.py @@ -0,0 +1,8 @@ +def paying_taxes(): + taxes = True + age = int(input("Enter age: ")) + if age > 26: + taxes = False + return f"Exemption from paying taxes: {taxes}" + +print(paying_taxes()) \ No newline at end of file diff --git a/02-TypesAndVariables/t26.py b/02-TypesAndVariables/t26.py new file mode 100644 index 000000000..62faa5c14 --- /dev/null +++ b/02-TypesAndVariables/t26.py @@ -0,0 +1,11 @@ +def is_even(): + number = int(input("Enter number: ")) + if number%2 == 0: + check = True + else: + check = False + + return f"Number is even: {check}" + + +print(is_even()) \ No newline at end of file diff --git a/02-TypesAndVariables/t27.py b/02-TypesAndVariables/t27.py new file mode 100644 index 000000000..ac762a9e1 --- /dev/null +++ b/02-TypesAndVariables/t27.py @@ -0,0 +1,10 @@ +def in_range(): + num = int(input("Enter number: ")) + if num >= -10 and num<= 10: + result = True + else: + result = False + + return f'Number ub range <-10, 10>: {result}' + +print(in_range()) \ No newline at end of file diff --git a/02-TypesAndVariables/t28.py b/02-TypesAndVariables/t28.py new file mode 100644 index 000000000..e3ae80f08 --- /dev/null +++ b/02-TypesAndVariables/t28.py @@ -0,0 +1,17 @@ +def cBMI(): + height = float(input("Enter your height: ")) + weight = float(input("Enter your weight: ")) + bmiindex = weight/(height/100)**2.0 + if bmiindex >=18.5 and bmiindex <= 24.99: + correct_weight = True + else: + correct_weight = False + result = f'Your BMI index: {bmiindex}\nCorrect weight: {correct_weight}' + + return result + + + + + +print(cBMI()) \ No newline at end of file diff --git a/02-TypesAndVariables/t29.py b/02-TypesAndVariables/t29.py new file mode 100644 index 000000000..3e7cc7124 --- /dev/null +++ b/02-TypesAndVariables/t29.py @@ -0,0 +1,9 @@ +import random +def rand(): + roll_one = random.randint(1,6) + roll_two = random.randint(1,6) + roll_three = random.randint(1,6) + sum = roll_one + roll_two + roll_three + result = f'roll one = {roll_one}\nroll two = {roll_two}\nroll three = {roll_three}\nsum = {sum}' + return result +print(rand()) \ No newline at end of file diff --git a/02-TypesAndVariables/t30.py b/02-TypesAndVariables/t30.py new file mode 100644 index 000000000..ab66b70e7 --- /dev/null +++ b/02-TypesAndVariables/t30.py @@ -0,0 +1,15 @@ +import random + + +def is_special(): + number = random.randint(1,6) + if number == 1 or number == 6: + special_num = True + else: + special_num = False + result = f'Dice rolled: {number}\nSpecial number: {special_num}' + + return result + + +print(is_special()) \ No newline at end of file diff --git a/02-TypesAndVariables/t31.py b/02-TypesAndVariables/t31.py new file mode 100644 index 000000000..5c1f1103a --- /dev/null +++ b/02-TypesAndVariables/t31.py @@ -0,0 +1,14 @@ +import random + +def challange(): + number = int(input("Guess number: ")) + randnum = random.randint(1,6) + if randnum == number: + result = True + else: + result = False + + return result + + +print(challange()) \ No newline at end of file diff --git a/02-TypesAndVariables/t32.py b/02-TypesAndVariables/t32.py new file mode 100644 index 000000000..01c17e492 --- /dev/null +++ b/02-TypesAndVariables/t32.py @@ -0,0 +1,9 @@ +def cVAT(): + amount = float(input("Enter amount: ")) + vat = round(0.23 * amount, 2) + result = f"Amount: {amount} \nVAT 23%: {vat}" + + return result + + +print(cVAT()) \ No newline at end of file diff --git a/02-TypesAndVariables/t33.py b/02-TypesAndVariables/t33.py new file mode 100644 index 000000000..64823503c --- /dev/null +++ b/02-TypesAndVariables/t33.py @@ -0,0 +1,10 @@ +def password(): + password = input('Enter password: ') + if len(password) < 8: + reslt = False + else: + reslt = True + result = f"Password is valid: {reslt}" + return result + +print(password()) \ No newline at end of file diff --git a/02-TypesAndVariables/t34.py b/02-TypesAndVariables/t34.py new file mode 100644 index 000000000..d9d5e3b77 --- /dev/null +++ b/02-TypesAndVariables/t34.py @@ -0,0 +1,12 @@ +def check_speed(): + speed = int(input("Enter vehicle speed: ")) + if speed <= 140 and speed >= 40: + check = True + else: + check = False + + result = f"Speed is valid: {check}" + + return result + +print(check_speed()) \ No newline at end of file diff --git a/02-TypesAndVariables/t36.py b/02-TypesAndVariables/t36.py new file mode 100644 index 000000000..3ab34a8bf --- /dev/null +++ b/02-TypesAndVariables/t36.py @@ -0,0 +1,9 @@ +def spread(): + buyeur = round(float(input("Bank buys EUR: ")), 4) + selleur = round(float(input("Bank sell EUR: ")), 4) + spread = round(selleur - buyeur, 4) + result = f'Spread: {spread}' + + return result + +print(spread()) diff --git a/02-TypesAndVariables/t37.py b/02-TypesAndVariables/t37.py new file mode 100644 index 000000000..728909d69 --- /dev/null +++ b/02-TypesAndVariables/t37.py @@ -0,0 +1,14 @@ +def slicing(): + personel_data = "Mr. John May, born on 1998-02-16" + name = personel_data[4:8] + surname = personel_data[9:12] + initials = personel_data[4] + personel_data[9] + born = personel_data[22:] + result = f'Name: {name}\nSurname: {surname}\nInitials: {initials}\nBorn: {born}' + + return result + + + + +print(slicing()) \ No newline at end of file diff --git a/02-TypesAndVariables/t38.py b/02-TypesAndVariables/t38.py new file mode 100644 index 000000000..1c4a4536f --- /dev/null +++ b/02-TypesAndVariables/t38.py @@ -0,0 +1,7 @@ +def telephone(): + num = input("Enter phone number: ") + result = num[:3]+"-"+ num[3:6]+"-"+num[6:] + return result + + +print(telephone()) \ No newline at end of file diff --git a/02-TypesAndVariables/t39.py b/02-TypesAndVariables/t39.py new file mode 100644 index 000000000..a35efacd7 --- /dev/null +++ b/02-TypesAndVariables/t39.py @@ -0,0 +1,12 @@ +def discount(): + price = float(input("Enter price: ")) + discount = int(input("Enter discount: ")) + price_with = round(price - price*(discount/100), 2) + reduction = round(price - price_with, 2) + + result = f'Price with discount: {price_with}\nReduction: {reduction}' + + return result + + +print(discount()) \ No newline at end of file diff --git a/02-TypesAndVariables/t40.py b/02-TypesAndVariables/t40.py new file mode 100644 index 000000000..090ed7861 --- /dev/null +++ b/02-TypesAndVariables/t40.py @@ -0,0 +1,7 @@ +def credit_num(): + number = input("Enter credit card number: ") + card_number = number[:4]+" "+number[4:8]+" "+number[8:12]+" "+number[12:] + + return f'Card number: {card_number}' + +print(credit_num()) \ No newline at end of file diff --git a/02-TypesAndVariables/t41.py b/02-TypesAndVariables/t41.py new file mode 100644 index 000000000..dd4b310ef --- /dev/null +++ b/02-TypesAndVariables/t41.py @@ -0,0 +1,8 @@ +def binandhex(): + num = int(input("Enter number: ")) + bina = bin(num) + hexa = hex(num) + return f'Binary number: {bina}\nHexadecimal number: {hexa}' + + +print(binandhex()) \ No newline at end of file diff --git a/02-TypesAndVariables/t42.py b/02-TypesAndVariables/t42.py new file mode 100644 index 000000000..5f8bc1afb --- /dev/null +++ b/02-TypesAndVariables/t42.py @@ -0,0 +1,16 @@ +def btod(): + binary = input("Enter binary number: ") + result = 0 + if binary[0] == '1': + result+= 8 + if binary[1] == '1': + result+= 4 + if binary[2] == '1': + result+= 2 + if binary[3] == '1': + result+= 1 + + return f'Binart number in decimal notation: {result}' + + +print(btod()) \ No newline at end of file diff --git a/02-TypesAndVariables/t43.py b/02-TypesAndVariables/t43.py new file mode 100644 index 000000000..331d53b38 --- /dev/null +++ b/02-TypesAndVariables/t43.py @@ -0,0 +1,10 @@ +def unicode(): + name = input("Enter name: ") + result = "" + for i in name: + result += i+"("+str(ord(i))+ ") " + + return result + + +print(unicode()) \ No newline at end of file From 18acadaab07065ab50c9cef7a878b0306daae878 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Tue, 7 Nov 2023 15:15:14 +0100 Subject: [PATCH 15/20] dsg --- 03-ControlStructures/t13.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 03-ControlStructures/t13.py diff --git a/03-ControlStructures/t13.py b/03-ControlStructures/t13.py new file mode 100644 index 000000000..b9b742a9b --- /dev/null +++ b/03-ControlStructures/t13.py @@ -0,0 +1,12 @@ +def nonnegative(): + num1 = int(input("Enter numner 1: ")) + num2 = int(input("Enter number 2: ")) + if num1 > 0 or num2 > 0: + result = f'At least one of entered numbers {num1} and {num2} is not negative' + else: + result = f"{num1} and {num2} are negative numbers!!!!" + + return result + + +print(nonnegative()) \ No newline at end of file From 48df0819231e903dc6b997a499756f92b101c180 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Tue, 7 Nov 2023 16:03:21 +0100 Subject: [PATCH 16/20] aaaa --- 03-ControlStructures/t14.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 03-ControlStructures/t14.py diff --git a/03-ControlStructures/t14.py b/03-ControlStructures/t14.py new file mode 100644 index 000000000..6095c6f61 --- /dev/null +++ b/03-ControlStructures/t14.py @@ -0,0 +1,10 @@ +def text(): + i = 1 + result = "" + while i <= 4: + result += "Practice makes perfect!\n" + i += 1 + + return result + +print(text('ala ma koa')) \ No newline at end of file From ea8515231928ff1be6a3da2999f9a4150f426317 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Tue, 7 Nov 2023 16:03:59 +0100 Subject: [PATCH 17/20] fff --- 04-Subroutines/stare/mocktest2.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 04-Subroutines/stare/mocktest2.py diff --git a/04-Subroutines/stare/mocktest2.py b/04-Subroutines/stare/mocktest2.py new file mode 100644 index 000000000..f6d6b8fba --- /dev/null +++ b/04-Subroutines/stare/mocktest2.py @@ -0,0 +1,15 @@ +def f(binary_number): + length = len(binary_number) + binary= None + for i in range(0,length): + if binary_number[i] == "0" or binary_number[i] == "1": + pass + else: + binary = False + print(binary) + return False + binary = True + print(binary) + +f("101101") +f("1311a10100") From df67e04ed367b4da5758499f9bb90df21b0f9257 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Tue, 7 Nov 2023 16:04:15 +0100 Subject: [PATCH 18/20] dtg --- 03-ControlStructures/t21.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 03-ControlStructures/t21.py diff --git a/03-ControlStructures/t21.py b/03-ControlStructures/t21.py new file mode 100644 index 000000000..8f053350f --- /dev/null +++ b/03-ControlStructures/t21.py @@ -0,0 +1,13 @@ +def order(): + n1 = int(input("Enter first number: ")) + n2 = int(input("Enter second number: ")) + result = "Numbers in ascending order: " + if n1 >= n2: + result += f"{n2}, {n1}" + else: + result += f'{n1}, {n2}' + + return result + + +print(order()) \ No newline at end of file From 6faf2060dba50c757ebed503b70df86cb4fd8746 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Tue, 7 Nov 2023 16:04:46 +0100 Subject: [PATCH 19/20] zsxf --- 04-Subroutines/stare/mocktest1.py | 5 +++++ 04-Subroutines/stare/mocktest3.py | 16 ++++++++++++++++ 04-Subroutines/stare/mocktest4.py | 25 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 04-Subroutines/stare/mocktest1.py create mode 100644 04-Subroutines/stare/mocktest3.py create mode 100644 04-Subroutines/stare/mocktest4.py diff --git a/04-Subroutines/stare/mocktest1.py b/04-Subroutines/stare/mocktest1.py new file mode 100644 index 000000000..aac91876c --- /dev/null +++ b/04-Subroutines/stare/mocktest1.py @@ -0,0 +1,5 @@ +def f(card_number): + card_number= card_number[0:2] + "**********" + card_number[12:16] + print(card_number) + +f("5290312400019022") \ No newline at end of file diff --git a/04-Subroutines/stare/mocktest3.py b/04-Subroutines/stare/mocktest3.py new file mode 100644 index 000000000..dbd275183 --- /dev/null +++ b/04-Subroutines/stare/mocktest3.py @@ -0,0 +1,16 @@ +def f(amount): + rem = amount % 5 + zl5 = (amount - rem)/5 + rem = amount % 2 + zl2 = (amount - rem)/2 + zl1 = rem + + print(int(zl5 + zl2 + zl1)) + + + +f(8) +f(2) +f(0) + +#jest źle:) diff --git a/04-Subroutines/stare/mocktest4.py b/04-Subroutines/stare/mocktest4.py new file mode 100644 index 000000000..9c2dc8f4d --- /dev/null +++ b/04-Subroutines/stare/mocktest4.py @@ -0,0 +1,25 @@ +def f(number,even): + sum = 0 + length = len(str(number)) + if even == True: + for i in range(0, length): + if number[i]%2 == 0: + sum+= int(str(number[i])) + else: + pass + + if even == False: + for i in range(0, length): + if int(str(number)[i])%2 == 1: + sum = sum +int(str(number)[i]) + else: + pass + + print(sum) + +f(3124,True) +f(3124,False) +f(20576,False) +f(20576,True) +f(13115,True) + From 840ded35a527fa5984262f9c25cf260093e39e41 Mon Sep 17 00:00:00 2001 From: kulpiq Date: Tue, 7 Nov 2023 16:05:31 +0100 Subject: [PATCH 20/20] sfg --- 03-ControlStructures/t15.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 03-ControlStructures/t15.py diff --git a/03-ControlStructures/t15.py b/03-ControlStructures/t15.py new file mode 100644 index 000000000..5ccab2e63 --- /dev/null +++ b/03-ControlStructures/t15.py @@ -0,0 +1,8 @@ +def text2(): + result = "" + for i in range(4): + result += 'Practice makes perfect!\n' + + return result + +print(text2()) \ No newline at end of file