Compare commits
5 Commits
1c7f6684dc
...
master
Author | SHA1 | Date | |
---|---|---|---|
452659706e | |||
1fa3869c6c | |||
5368be695f | |||
9e928bbec7 | |||
9f5acc3f58 |
34
2.Erste Programme/15. String Vergleich/Quiz.py
Normal file
34
2.Erste Programme/15. String Vergleich/Quiz.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
punkte=0
|
||||||
|
|
||||||
|
#Frage 1
|
||||||
|
korrekt="c"
|
||||||
|
print("Welchees ist die größte Wüste")
|
||||||
|
print("a-Gobi\nb-Sahra\nc-Antarktis\nd-Arktis")
|
||||||
|
|
||||||
|
antwort = str(input("Ihre Antwort:"))
|
||||||
|
#str sthet für String, also eine Zeichenkette aus einem oder mehreren Buchstaben
|
||||||
|
|
||||||
|
if antwort==korrekt:
|
||||||
|
print ('Die Antowrt: "%s" ist richtig.'%(antwort))
|
||||||
|
punkte=punkte+1
|
||||||
|
print("Sie haben jetzt %sPunkte."%(punkte))
|
||||||
|
else:
|
||||||
|
print ('Die Antwort: "%s" ist falsch.'%(antwort))
|
||||||
|
print("Sie haben jetzt %sPunkte."%(punkte))
|
||||||
|
|
||||||
|
|
||||||
|
#Frage 2
|
||||||
|
korrekt="c"
|
||||||
|
print("")
|
||||||
|
print("a-\nb-\nc-\nd-")
|
||||||
|
|
||||||
|
antwort = str(input("Ihre Antwort:"))
|
||||||
|
#str sthet für String, also eine Zeichenkette aus einem oder mehreren Buchstaben
|
||||||
|
|
||||||
|
if antwort==korrekt:
|
||||||
|
print ('Die Antowrt: "%s" ist richtig.'%(antwort))
|
||||||
|
punkte=punkte+1
|
||||||
|
print("Sie haben jetzt %sPunkte."%(punkte))
|
||||||
|
else:
|
||||||
|
print ('Die Antwort: "%s" ist falsch.'%(antwort))
|
||||||
|
print("Sie haben jetzt %sPunkte."%(punkte))
|
14
2.Erste Programme/15. String Vergleich/Quiz_Philipp.py
Normal file
14
2.Erste Programme/15. String Vergleich/Quiz_Philipp.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Make a programm which asks Quiz Questions, which are stored in a database
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
punkte=0
|
||||||
|
i=0
|
||||||
|
con = sqlite3.connect('questions.db')
|
||||||
|
cur = con.cursor()
|
||||||
|
# Fetch Questions
|
||||||
|
while(True):
|
||||||
|
i+1
|
||||||
|
question=cur.execute("SELECT QUESTION FROM QUESTIONS WHERE NUMBER is %s"%(i))
|
||||||
|
print(question)
|
||||||
|
break
|
||||||
|
# @Philipp: fortsetzen
|
BIN
2.Erste Programme/15. String Vergleich/questions.db
Normal file
BIN
2.Erste Programme/15. String Vergleich/questions.db
Normal file
Binary file not shown.
19
2.Erste Programme/16. Funktionen/Funktionen.py
Normal file
19
2.Erste Programme/16. Funktionen/Funktionen.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Programm, welches die Funktion(Programmierung) in Python einführt.
|
||||||
|
|
||||||
|
def summe(summand1,summand2): #Funktion Summe
|
||||||
|
return summand1+summand2
|
||||||
|
|
||||||
|
def potenz(basis,exponent): # Funktion Potenz
|
||||||
|
ergebnis=1
|
||||||
|
for i in range(exponent):
|
||||||
|
ergebnis=ergebnis*basis
|
||||||
|
|
||||||
|
return ergebnis
|
||||||
|
|
||||||
|
|
||||||
|
# Beginn des eigentlichen Hauptprogramms
|
||||||
|
|
||||||
|
print(summe(3,5))
|
||||||
|
print(summe(233,87))
|
||||||
|
|
||||||
|
print(potenz(2,3))
|
20
3. Übungen/12.09.2022/Problem_48.py
Normal file
20
3. Übungen/12.09.2022/Problem_48.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Programm, welches das Problem "48" bearbeitet
|
||||||
|
# also überprüft, ob der Nachfolger einer zahl
|
||||||
|
# und der Nachfolger der Hälfte der Zahl jeweils Quadratzahlen sind
|
||||||
|
|
||||||
|
def ist_Quadratzahl(n):
|
||||||
|
if (n**(1/2)== int(n**(1/2))):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Hier ist normales Programm
|
||||||
|
|
||||||
|
i=1
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if ist_Quadratzahl(i+1) and ist_Quadratzahl(i/2+1):
|
||||||
|
print(i)
|
||||||
|
i+=1
|
34
3. Übungen/12.09.2022/Problem_48_home.py
Normal file
34
3. Übungen/12.09.2022/Problem_48_home.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Programm, welches das Problem "48" bearbeitet
|
||||||
|
# also überprüft, ob der Nachfolger einer zahl
|
||||||
|
# und der Nachfolger der Hälfte der Zahl jeweils Quadratzahlen sind
|
||||||
|
import logging
|
||||||
|
logging.basicConfig(filename='output.txt', level=logging.DEBUG, format='%(asctime)s: %(message)s')
|
||||||
|
|
||||||
|
def ist_Quadratzahl(n):
|
||||||
|
if (n**(1/2)== int(n**(1/2))):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
# Hier ist normales Programm
|
||||||
|
|
||||||
|
i=1
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if i%2==0:
|
||||||
|
if ist_Quadratzahl(i+1) and ist_Quadratzahl(i/2+1):
|
||||||
|
#print(i)
|
||||||
|
logging.debug(i)
|
||||||
|
i+=1
|
||||||
|
'''
|
||||||
|
|
||||||
|
i=2
|
||||||
|
|
||||||
|
while True:
|
||||||
|
iq = i**2
|
||||||
|
if (iq-1) % 2 == 0:
|
||||||
|
if ist_Quadratzahl((iq+1)/2):
|
||||||
|
logging.debug(iq-1)
|
||||||
|
i+=1
|
9
3. Übungen/16.06.2022/Insertionsort.py
Normal file
9
3. Übungen/16.06.2022/Insertionsort.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
data=[9,5,1,4,3]
|
||||||
|
for step in range (1, len(data)):
|
||||||
|
key=data[step]
|
||||||
|
j=step-1
|
||||||
|
while j>=0 and key < data[j]:
|
||||||
|
data[j+1]=data[j]
|
||||||
|
j=j-1
|
||||||
|
data[j+1]=key
|
||||||
|
print(data)
|
14
3. Übungen/16.06.2022/wiederholung_array.py
Normal file
14
3. Übungen/16.06.2022/wiederholung_array.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Wiederholung Array/Feld
|
||||||
|
|
||||||
|
zahlen=[4,6,3,9,12,1,8] # Array wird erzeugt, hat bereits 7 Elemente
|
||||||
|
|
||||||
|
# Tausch zweier Werte aus dem Array (4 und 6)
|
||||||
|
zahlen[0],zahlen[1]=zahlen[1],zahlen[0]
|
||||||
|
print(zahlen)
|
||||||
|
|
||||||
|
''' # Summe des Arrays
|
||||||
|
summe=0
|
||||||
|
for i in range(7):
|
||||||
|
summe=summe+zahlen[i]
|
||||||
|
print(summe)
|
||||||
|
'''
|
2
4. Theorie/Datentyp_str.md
Normal file
2
4. Theorie/Datentyp_str.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Neuer Datentyp:
|
||||||
|
str steht für String, also eine Zeichenkette asu einem oder mehreren Buchstaben
|
1
4. Theorie/Funktionen.md
Normal file
1
4. Theorie/Funktionen.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# Funktionen in Python
|
12
4. Theorie/Quicksort.md
Normal file
12
4. Theorie/Quicksort.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Quicksort
|
||||||
|
- Pivoelement muss zuerst bestimmt werden, idealerweise der Median (Median: nicht ohne Sortierung bestimmbar)
|
||||||
|
- Prinzip: Teile und herrsche
|
||||||
|
## Beipiel:
|
||||||
|
253 401 24 590 281
|
||||||
|
253 24 281 401 590
|
||||||
|
\\\\
|
||||||
|
- Elemente werden mit Pivoelement verglichen und avor oder dahinter einsortiert
|
||||||
|
- Vorgang wird wiederholt, bis nur einelemntigre Teilmengen über sind (Rekursion)
|
||||||
|
## Übung:
|
||||||
|
58 12 3 7 62
|
||||||
|
3 7 12 58 62
|
Binary file not shown.
26
Tools/median-getter/main.py
Normal file
26
Tools/median-getter/main.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from array import array
|
||||||
|
import numbers
|
||||||
|
import statistics
|
||||||
|
array=[]
|
||||||
|
|
||||||
|
def add_items_to_array():
|
||||||
|
print("Operations:\n1.Add numbers\n2.That are all numbers\n3.Exit\nThere are %s Elements in the array" %(len(array)))
|
||||||
|
operation=int(input("Operation:"))
|
||||||
|
if operation == 1:
|
||||||
|
numbers_to_add=float(input("Number:"))
|
||||||
|
array.append(numbers_to_add)
|
||||||
|
add_items_to_array()
|
||||||
|
elif operation == 2:
|
||||||
|
get_median()
|
||||||
|
elif operation == 3:
|
||||||
|
exit()
|
||||||
|
else:
|
||||||
|
print("Input the right operation")
|
||||||
|
add_items_to_array()
|
||||||
|
|
||||||
|
def get_median():
|
||||||
|
median_item=statistics.median(array)
|
||||||
|
print(median_item)
|
||||||
|
exit()
|
||||||
|
|
||||||
|
add_items_to_array()
|
23
output.txt
Normal file
23
output.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
2022-09-13 11:23:33,129: 48
|
||||||
|
2022-09-13 11:23:33,129: 1680
|
||||||
|
2022-09-13 11:23:33,129: 57120
|
||||||
|
2022-09-13 11:23:33,130: 1940448
|
||||||
|
2022-09-13 11:23:33,135: 65918160
|
||||||
|
2022-09-13 11:23:33,159: 2239277040
|
||||||
|
2022-09-13 11:23:33,306: 76069501248
|
||||||
|
2022-09-13 11:23:34,146: 2584123765440
|
||||||
|
2022-09-13 11:23:39,077: 87784138523760
|
||||||
|
2022-09-13 11:24:07,549: 2982076586042448
|
||||||
|
2022-09-13 11:32:51,334: 48
|
||||||
|
2022-09-13 11:32:51,334: 1680
|
||||||
|
2022-09-13 11:32:51,335: 57120
|
||||||
|
2022-09-13 11:32:51,336: 1940448
|
||||||
|
2022-09-13 11:32:51,341: 65918160
|
||||||
|
2022-09-13 11:32:51,366: 2239277040
|
||||||
|
2022-09-13 11:32:51,506: 76069501248
|
||||||
|
2022-09-13 11:32:52,320: 2584123765440
|
||||||
|
2022-09-13 11:32:57,098: 87784138523760
|
||||||
|
2022-09-13 11:33:24,936: 2982076586042448
|
||||||
|
2022-09-13 11:34:14,228: 17380816062160328
|
||||||
|
2022-09-13 11:35:05,575: 43707861882448008
|
||||||
|
2022-09-13 11:35:26,777: 58106601358565880
|
Reference in New Issue
Block a user