master
Dr. Sascha Woitschetzki 2024-03-07 12:39:20 +07:00
parent d97c6ac931
commit be314fd496
14 changed files with 103 additions and 0 deletions

@ -0,0 +1,6 @@
s = input("s? ")
t = s.capitalize()
print(f"s: {s}")
print(f"t: {t}")

@ -0,0 +1,10 @@
import sys
if len(sys.argv) < 2:
print("Missing command-line argument!")
sys.exit(1)
for arg in sys.argv[1:]:
print(f"Hello {arg}!")
sys.exit(0)

@ -0,0 +1,7 @@
from sys import argv
if len(argv) > 1:
for arg in argv[1:]:
print(f"Hello {arg}!")
else:
print("Hello World!")

@ -0,0 +1,15 @@
def main():
height = get_height()
for i in range(height):
print("#")
def get_height():
while True:
try:
n = int(input("Height?: "))
except ValueError:
print("ValueError: Not an integer!")
else:
if n > 0: return n
main()

@ -0,0 +1,4 @@
from cs50 import get_int
width = get_int("Width?: ")
print("?" * width)

@ -0,0 +1,7 @@
from cs50 import get_int
height = get_int("Height?: ")
width = get_int("Width?: ")
for i in range(height):
print("#" * width)

@ -0,0 +1,12 @@
import sys
names = ["Bill", "Charlie", "Fred", "George", "Ginny", "Percy", "Ron"]
name = input("Name: ")
if name in names:
print("found")
sys.exit(0)
print("not found")
sys.exit(1)

@ -0,0 +1,6 @@
name,number
David,+1-949-468-2750
Carter,+1-617-495-1000
Sascha,+49-163-9681131
Ina,+49-175-4038108
Agilent,+49-176-22285334
1 name number
2 David +1-949-468-2750
3 Carter +1-617-495-1000
4 Sascha +49-163-9681131
5 Ina +49-175-4038108
6 Agilent +49-176-22285334

@ -0,0 +1,9 @@
import csv
with open("phonebook.csv", "a") as file:
name = input("Name: ")
number = input("Number: ")
writer = csv.DictWriter(file, fieldnames=["name", "number"])
writer.writerow({"name": name, "number": number})

@ -0,0 +1,12 @@
from cs50 import get_int
scores = []
while True:
score = get_int("Score?: ")
if score == 0: break
scores.append(score)
print(f"Scores: {scores}")
average = sum(scores) / len(scores)
print(f"Average: {average}")

@ -0,0 +1,6 @@
import pyttsx3
engine = pyttsx3.init()
name = input("Name: ")
engine.say(f"hello {name}!")
engine.runAndWait()

@ -0,0 +1,6 @@
x = 1
y = 2
print(f"x is {x}, y is {y}")
x, y = y, x
print(f"x is {x}, y is {y}")

@ -0,0 +1,3 @@
before = input("Before: ")
after = before.upper()
print(f"After: {after}")