add lab 7

This commit is contained in:
sys_32
2023-10-06 10:17:28 -07:00
committed by GitHub
parent 387de0f5e7
commit 432510d9fe
5 changed files with 104 additions and 0 deletions

BIN
lab7/flowchart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

63
lab7/lab7-1.py Normal file
View File

@@ -0,0 +1,63 @@
# Edwin Hui
import time
import random
print("this")
time.sleep(1)
print("is")
time.sleep(2)
print("a")
time.sleep(4)
print("test")
time.sleep(3)
print("message")
print("----------------------------------")
print(time.time())
time.sleep(0.5)
print(time.time())
time.sleep(1)
print(time.time())
print("----------------------------------")
loops = 9
while loops > -1:
print(10-loops)
loops = loops - 1
print("----------------------------------")
loops = 9
while loops > -1:
print(10-loops, end=" - ")
loops = loops - 1
print("----------------------------------")
loops = 4
while loops > -1:
print(5-loops)
loops = loops - 1
time.sleep(0.5)
print("----------------------------------")
loops = 10
while loops <= 20:
print(loops)
loops = loops + 2
if loops == 22:
break
print("----------------------------------")
loops = 20
while loops <= 20:
print(loops)
loops = loops - 3
if loops <= 0:
break
print("----------------------------------")
loops = 10
while loops > 0:
print(random.randint(1,100), end=" ")
loops = loops - 1
print("----------------------------------")
nbr = int(input("Enter a number greater than 100: "))
while nbr <= 100:
print("Number too low!")
nbr = int(input("Enter a number greater than 100: "))
if nbr > 100:
print("Number is greater than 100, thank you!")
break
print("----------------------------------")

10
lab7/lab7-2.py Normal file
View File

@@ -0,0 +1,10 @@
# Edwin Hui
loop = 0
result = 0
while loop >= 0:
add = loop + 1
print(result, "+", add, "=", result + add)
result = result + add
loop = loop + 1
if loop == 100:
break

15
lab7/lab7-3.py Normal file
View File

@@ -0,0 +1,15 @@
# Edwin Hui
usr = input("enter a number or q to quit: ")
if usr == "q":
print("you have no total")
else:
print("your subtotal is", usr)
while usr != "q":
usr2 = input("enter a number or q to quit: ")
if usr2 == "q":
print("your grand total is", subtotal)
break
subtotal = int(usr) + int(usr2)
print("your subtotal is", subtotal)
usr = subtotal

16
lab7/lab7-4.py Normal file
View File

@@ -0,0 +1,16 @@
# Edwin Hui
loop = 0
while loop < 6:
print("#" * loop)
loop += 1
print("----------------------------------")
loop = input("Enter number of lines: ")
nbr = int(loop)
loop = 0
while loop <= nbr:
chara = 0
print("")
while chara < loop:
print("#", end="")
chara += 1
loop += 1