From 9cf297f8fc7a5dd0c64fb464e02e821ae3b0d460 Mon Sep 17 00:00:00 2001 From: pasi kanto <68000803+Pkanto@users.noreply.github.com> Date: Tue, 15 Sep 2020 12:21:25 +0300 Subject: [PATCH] =?UTF-8?q?teht=C3=A4v=C3=A4t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- harj9/eka.py | 13 +++++++++++++ harj9/kolmas.py | 12 ++++++++++++ harj9/toka.py | 11 +++++++++++ harj9/viides.py | 8 ++++++++ 4 files changed, 44 insertions(+) create mode 100644 harj9/eka.py create mode 100644 harj9/kolmas.py create mode 100644 harj9/toka.py create mode 100644 harj9/viides.py diff --git a/harj9/eka.py b/harj9/eka.py new file mode 100644 index 0000000..667377a --- /dev/null +++ b/harj9/eka.py @@ -0,0 +1,13 @@ +summa = 0 +luku = 0 +while True: + x= input("Anna luku: ") + if x.isdigit(): + x=int(x) + summa = summa + x + luku = luku+1 + else: + break +print (luku) +print("lukujen summa on ") +print (summa) \ No newline at end of file diff --git a/harj9/kolmas.py b/harj9/kolmas.py new file mode 100644 index 0000000..337d2aa --- /dev/null +++ b/harj9/kolmas.py @@ -0,0 +1,12 @@ +tyhja=[] +luku=0 +while True: + nimi=input("Kerro nimesi") + if nimi !="": + tyhja.append(nimi) + luku = luku+1 + else: + break +tyhja.sort() +print(tyhja) +print("nimien määrä ", luku) \ No newline at end of file diff --git a/harj9/toka.py b/harj9/toka.py new file mode 100644 index 0000000..bbd09cc --- /dev/null +++ b/harj9/toka.py @@ -0,0 +1,11 @@ +tyhja=[] +luku=0 +while True: + nimi=input("Kerro nimesi") + if nimi !="": + tyhja.append(nimi) + luku = luku+1 + else: + break +print(tyhja) +print("nimien määrä ", luku) \ No newline at end of file diff --git a/harj9/viides.py b/harj9/viides.py new file mode 100644 index 0000000..545ded8 --- /dev/null +++ b/harj9/viides.py @@ -0,0 +1,8 @@ +import random +luku=0 +tyhja =[] +while luku <8: + x = random.randint(1,41) + tyhja.append(x) + luku =+1 +print(tyhja) \ No newline at end of file -- GitLab