Upload code

This commit is contained in:
2025-01-20 19:40:14 +01:00
parent 71625e3e41
commit 07809d7d77
66 changed files with 8917 additions and 0 deletions

66
IO/Calculator.py Executable file
View File

@@ -0,0 +1,66 @@
#Library import
import math
#Startup
out = 0
print("""
,--------. ,--. ,--.
'--. .--',--,--. ,---. ,---.| ,---. ,---. ,--,--, ,--.--. ,---. ,---.| ,---. ,--,--, ,---. ,--.--.
| | ' ,-. |( .-' | .--'| .-. || .-. :| \| .--'| .-. :| .--'| .-. || \| .-. :| .--'
| | \ '-' |.-' `)\ `--.| | | |\ --.| || || | \ --.\ `--.| | | || || |\ --.| |
`--' `--`--'`----' `---'`--' `--' `----'`--''--'`--' `----' `---'`--' `--'`--''--' `----'`--'
=================
Alpha 1.0
Build 1
28.05.21
""")
#Userinput
i = input("Rechung eingeben: ")
#Separation
l = i.split()
x1 = l.pop(0)
x = int(x1)
#Calculation
if len(l) == 1:
print("Wrong entry, retry, use spaces in between numbers and operands.")
else:
while len(l) > 1:
y1 = l.pop(1)
y = int(y1)
if "*" in l:
out = x * y
elif "+" in l:
out = x + y
elif "-" in l:
out = x - y
elif "/" or ":" in l:
out = x / y
elif "^" or "**" in l:
out = x ** y
elif "<>" in l:
math.sqrt(x)
else:
print("unkown operand, retry")
if len(l) != 0:
operand = l.pop(0)
x = out
else:
print("The result is:")
#Output
print(out)

40
IO/Coinflip.py Executable file
View File

@@ -0,0 +1,40 @@
import random
st1 = 0
st2 = 0
st3 = 3
st2a = 0
anzahl = 0
go = 1
while go == 1:
zahl = random.randint(1,2)
if st1 == st2:
if st2a == st3:
go = 0
else:
anzahl += 1
st3 = st2
st2 = st1
st2a = st1
st1 = zahl
if zahl == 1:
print("K")
else:
print("N")
else:
anzahl += 1
st3 = st2
st2 = st1
st2a = st1
st1 = zahl
if zahl == 1:
print("K")
else:
print("N")
print("Took", anzahl, "tries")

21
IO/Eingabe Umwandlung easy.py Executable file
View File

@@ -0,0 +1,21 @@
eingabe = int(input("Zahl im Dezimalsystem: "))
system = int(input("Zahlensystem: "))
if system == 2:
y = bin(eingabe)
print("Resultat:", y)
elif system == 16:
y = hex(eingabe)
print("Resultat:", y)
elif system == 8:
y = oct(eingabe)
print("Resultat:", y)
else:
print("wrong")

111
IO/Frankengewinnspiel.py Executable file
View File

@@ -0,0 +1,111 @@
#FRANKENGEWINNSPIEL
#-------------------------------------------------
#Import of Modules and setup variables
#import turtle
#Definition of Turtle instances
#Preparations, so setup of the game output window and choice of diffrent gamemodes
programchoice = 200
while (programchoice < 1) or (programchoice > 99):
programchoice = programchoice = int(input("Welcher Modus? 1 = Normales Spiel, 2 = Liste aller Gewinne mit angabe des Höchsten, 3 = angabe des höchsten Gewinnes, 4 = andgabe des höchsten erreichbaren Feldes: "))
if (programchoice < 1) or (programchoice > 99):
print("Number not within designated range. Try again")
print("Willkommen")
#MAINGAME
#-----------------------
def playgame(field):
global winning
winning = 0
while field > 1:
if (field % 2) == 1:
next = field * 3 + 1
winning += next
field = next
else:
next = field / 2
winning += next
field = next
#GAMEMODE 1
#-------------------------
def gamemode1():
s = 200
while (s < 1) or (s > 99):
s = int(input("Zahl: "))
if (s < 1) or (s > 99):
print("Number not within designated range. Try again")
print("Ok")
fieldint = s
playgame(fieldint)
global winning
print("Your winnings:", winning)
#GAMEMODE 2
#--------------------------
def gamemode2():
fieldascending = 1
for i in range(99):
playgame(fieldascending)
print("You win",winning,"with startpoint",fieldascending)
fieldascending += 1
#GAMEMODE 3
#--------------------------
def gamemode3():
fieldascending = 1
global winning
currentwinning = 0
currentfield = 0
for i in range(99):
playgame(fieldascending)
if winning > currentwinning:
currentwinning = winning
currentfield = fieldascending
fieldascending += 1
print("Biggest possible winning is", currentwinning,"on field", currentfield)
#GAMEMODE 4
#-----------------------------
def gamemode4():
fieldascending = 1
global winning
currentwinning = 0
currentfield = 0
biggestfield = 0
for i in range(99):
field = fieldascending
while field > 1:
if (field % 2) == 1:
next = field * 3 + 1
field = next
if next > biggestfield:
biggestfield = next
currentfield = fieldascending
else:
next = field / 2
field = next
fieldascending += 1
print("Biggest possible field is", biggestfield,"on startfield", currentfield)
#RUN
#-------------------------
if programchoice == 1:
gamemode1()
elif programchoice == 2:
gamemode2()
elif programchoice == 3:
gamemode3()
else:
gamemode4()

39
IO/Idioms.py Executable file
View File

@@ -0,0 +1,39 @@
#Idioms
import random
#Check user input
s = 200
while (s < 1) or (s > 99):
s = int(input("Zahl: "))
if (s < 1) or (s > 99):
print("Number not within designated range. Try again")
print("Ok")
#Find biggest number
output = 0
for i in range(100):
n = random.randint(1, 1000)
if n > output:
output = n
print(output)
#Summ up
summ = 0
for i in range(100):
n = random.randint(1, 1000)
summ += n
print(summ)
#even or uneven?
z = random.randint(1, 1000)
if (z % 2) == 1:
print("odd")
else:
print("even")

13
IO/Input + outupt.py Executable file
View File

@@ -0,0 +1,13 @@
import math
#Eingabe
s = int(input("Seitenlänge: "))
#Verarbeitung
for i in range(s):
print(s * "* ")

15
IO/Umwandlung Zahlensysteme.py Executable file
View File

@@ -0,0 +1,15 @@
eingabe = int(input("Zahl im Dezimalsystem: "))
system = int(input("Zahlensystem: "))
y = eingabe
out = 0
stelle = 1
while y > 0:
y = y // system
outadd = y % system
out += (outadd * stelle)
stelle *= 10
print(out)

3
IO/Zeit des Lichts zur Erde.py Executable file
View File

@@ -0,0 +1,3 @@
c = (1.4962375e8 / 2.99792458e5)/60
print(c)

10
IO/Zufall Not quite.py Executable file
View File

@@ -0,0 +1,10 @@
import time
a = 5
c = 1
m = 32
x = int(time.time()) % m
for i in range(10):
x = (a*x + c) % m
print(x)