summaryrefslogtreecommitdiff
path: root/comp/while
diff options
context:
space:
mode:
Diffstat (limited to 'comp/while')
-rwxr-xr-xcomp/while/1.py10
-rwxr-xr-xcomp/while/2.py13
2 files changed, 23 insertions, 0 deletions
diff --git a/comp/while/1.py b/comp/while/1.py
new file mode 100755
index 0000000..08a4e21
--- /dev/null
+++ b/comp/while/1.py
@@ -0,0 +1,10 @@
+num = 0
+highest = 0
+lowest = 0
+while num != -1:
+ num = int(input("num: "))
+ if num > highest:
+ highest = num
+ if num < lowest:
+ lowest = num
+print("the highest value was",highest,"and the lowest value was",lowest)
diff --git a/comp/while/2.py b/comp/while/2.py
new file mode 100755
index 0000000..7929862
--- /dev/null
+++ b/comp/while/2.py
@@ -0,0 +1,13 @@
+import random
+
+guess = -1
+ans = random.randint(1,100)
+
+while guess != ans:
+ guess = int(input("guess: "))
+ if guess < ans:
+ print("higher")
+ elif guess > ans:
+ print("lower")
+
+