浏览代码

upload assignments

master
Marcel Haazen 5 年前
父节点
当前提交
07482cc97e
共有 8 个文件被更改,包括 173 次插入2 次删除
  1. +86
    -0
      Final Assignment/FA-2.py
  2. +5
    -0
      Final Assignment/kluizen.txt
  3. 二进制
      Untitled Diagram.jpg
  4. +2
    -2
      les 6/6-2.py
  5. +25
    -0
      les 6/6-3.py
  6. +19
    -0
      les 6/6-4.py
  7. +8
    -0
      les 6/Hardlopers.txt
  8. +28
    -0
      les 7/7-3.py

+ 86
- 0
Final Assignment/FA-2.py 查看文件

@ -0,0 +1,86 @@
#!/usr/bin/env python3
#title :FA-2.py
#description :Final Assignment: Bagagekluizen
#author :Marcel Haazen
#email :marcel@haazen.xyz
#date :04-10-2019 - 21:25
#version :0.1
#usage :python3 FA-2.py
#notes :
#python_version :3.7.4
#==============================================================================
exit = False
def find_missing(lst):
return [x for x in range(lst[0], lst[-1]+1)
if x not in lst]
def toon_aantal_kluizen_vrij():
num_lines = sum(1 for line in open("kluizen.txt"))
free = 12 - num_lines
return free
def nieuwe_kluis():
file = open("kluizen.txt", "r+")
gebruikt = []
rules = file.readlines()
for x in rules:
y = x.split(";")
gebruikt.append(int(y[0]))
gebruikt.sort()
kluisnummers = find_missing(gebruikt)
for rule in rules:
y = rule.split(";")
if (len(kluisnummers)) > 0:
kluis_code = str(input("Geef een code op voor uw kluis (minimaal 4 karakters):"))
if len(kluis_code) >= 4:
toegewezen_kluisnummer = str(kluisnummers[0])
file.write(toegewezen_kluisnummer + ";" + kluis_code + "\n")
return "\nJe nieuwe kluisnummer is: " + str(toegewezen_kluisnummer) + "\n"
else:
print("De opgegeven code is te kort (minimaal 4 karakters)")
else:
return "\ner is niks meer vrij\n"
file.close()
def kluis_openen(kluisnummer,code):
file = open("kluizen.txt", "r+")
rules = file.readlines()
for rule in rules:
if str(kluisnummer) + ";" + code + "\n" == rule:
return "\nDe kluis is geopend\n"
else:
return "\nDe ingevoerde gegevens zijn niet correct\n"
file.close()
def kluis_teruggeven(kluisnummer,code):
file = open("kluizen.txt", "r+")
rules = file.readlines()
file.close()
for rule in rules:
if str(kluisnummer) + ";" + code + "\n" == rule:
rules.remove(str(kluisnummer) + ";" + code + "\n")
file = open("kluizen.txt", "w")
file.writelines(rules)
file.close()
return "\nDe kluis is vrijgegeven\n"
return "\nDe ingevoerde gegevens zijn niet correct\n"
while exit != True:
print("1: Ik wil weten hoeveel kluizen nog vrij zijn \n2: Ik wil een nieuwe kluis \n3: Ik wil even iets uit mijn kluis halen \n4: Ik geef mijn kluis terug\n5: ik wil stoppen")
num = int(input("Kies wat je wilt doen: "))
if num == 5:
exit = True
elif num == 1:
print("\nEr zijn",toon_aantal_kluizen_vrij(),"kluizen vrij \n")
elif num == 2:
print(nieuwe_kluis())
elif num == 3:
kn = input("wat is je kluisnummer? ")
kc = input("wat is je code? ")
print(kluis_openen(kn,kc))
elif num == 4:
kn = input("wat is je kluisnummer? ")
kc = input("wat is je code? ")
print(kluis_teruggeven(kn,kc))

+ 5
- 0
Final Assignment/kluizen.txt 查看文件

@ -0,0 +1,5 @@
11;6754
1;geheim
5;kluisvanpietje
12;z@terd@g
2;sdfa

二进制
Untitled Diagram.jpg 查看文件

之前 之后
宽度: 758  |  高度: 1009  |  大小: 57 KiB

+ 2
- 2
les 6/6-2.py 查看文件

@ -12,5 +12,5 @@
file = open("kaartnummers.txt", "r")
for line in file:
fields = line.split(", ")
print(fields[1], "Heeft kaartnummer:", fields[0])
fields = line.split(",")
print(fields[1]o">.rstrip(), "Heeft kaartnummer:", fields[0])

+ 25
- 0
les 6/6-3.py 查看文件

@ -0,0 +1,25 @@
#!/usr/bin/env python3
#title :6-3.py
#description :Opdracht 6.3 - Files Lezen
#author :Marcel Haazen
#email :marcel@haazen.xyz
#date :04-10-2019 - 08:21
#version :0.1
#usage :python3 6-3.py
#notes :
#python_version :3.7.4
#==============================================================================
file = open("kaartnummers.txt", "r")
n = 0
i = 0
li = 0
for line in file:
i = i+1
fields = line.split(",")
if n < int(fields[0]):
n = int(fields[0])
li = li+1
print("Deze file telt",i,"regels")
print("Het grootste kaartnummer is:",n,"en dat staat op regel",li+1)
file.close

+ 19
- 0
les 6/6-4.py 查看文件

@ -0,0 +1,19 @@
#!/usr/bin/env python3
#title :6-4.py
#description :Opdracht 6.4 - Files schrijven
#author :Marcel Haazen
#email :marcel@haazen.xyz
#date :04-10-2019 - 20:43
#version :0.1
#usage :python3 6-4.py
#notes :
#python_version :3.7.4
#==============================================================================
import datetime
while 1 == 1:
vandaag = datetime.datetime.today()
s = vandaag.strftime("%a %d %b %Y, %H:%M:%S")
naam = input("Naam renner:")
file = open("Hardlopers.txt", "a+")
file.write(s+", "+naam+"\n")
file.close

+ 8
- 0
les 6/Hardlopers.txt 查看文件

@ -0,0 +1,8 @@
Thu 10 Mar 2016, 10:45:52, Miranda
Thu 10 Mar 2016, 10:46:04, Piet
Thu 10 Mar 2016, 10:47:27, Sacha
Thu 10 Mar 2016, 10:48:33, Karel
Thu 10 Mar 2016, 10:48:42, Kemal
Fri 04 Oct 2019, 20:55:36, geert
Fri 04 Oct 2019, 20:55:38, henk
Fri 04 Oct 2019, 20:55:41, adolf

+ 28
- 0
les 7/7-3.py 查看文件

@ -0,0 +1,28 @@
#!/usr/bin/env python3
#title :7-3.py
#description :Opdracht 7.3 - Two-dimensional lists
#author :Marcel Haazen
#email :marcel@haazen.xyz
#date :04-10-2019 - 21:25
#version :0.1
#usage :python3 7-3.py
#notes :
#python_version :3.7.4
#==============================================================================
import numpy as np
studentencijfers = [[95, 92, 86],[66, 75, 54],[89, 72, 100],[34, 0, 0]]
def gemiddelde_per_student(studentencijfers):
antw = np.array(studentencijfers)
antw = antw.mean(axis=1, dtype=np.float64)
return antw
def gemiddelde_van_alle_studenten(studentencijfers):
antw = np.array(studentencijfers)
antw = antw.mean(axis=1)
antw = np.array(antw)
antw = antw.mean()
return antw
print(gemiddelde_per_student(studentencijfers))
print(gemiddelde_van_alle_studenten(studentencijfers))

正在加载...
取消
保存