Browse Source

Final assignmetn 8 almost done

master
Marcel Haazen 4 years ago
parent
commit
1042a5d8ea
3 changed files with 55 additions and 0 deletions
  1. +19
    -0
      les 8/8-1.py
  2. +30
    -0
      les 8/8-4.py
  3. +6
    -0
      les 8/tickers.txt

+ 19
- 0
les 8/8-1.py View File

@ -0,0 +1,19 @@
#!/usr/bin/env python3
#title :8-1.py
#description :Opdracht 8.1 - While-loop & numbers
#author :Marcel Haazen
#email :marcel@haazen.xyz
#date :28-10-2019 - 13:10
#version :0.1
#usage :python3 8-1.py
#notes :
#python_version :3.7.3
#==============================================================================
nl = []
n = None
i = 0
while n != 0:
n = int(input("Voer een nummer in: "))
nl.append(n)
i += 1
print("er zijn", i-1 ,"getallen ingevoerd, de som is:", sum(nl))

+ 30
- 0
les 8/8-4.py View File

@ -0,0 +1,30 @@
#!/usr/bin/env python3
#title :8-4.py
#description :Opdracht 8.4 - File & dict
#author :Marcel Haazen
#email :marcel@haazen.xyz
#date :28-10-2019 - 13:20
#version :0.1
#usage :python3 8-4.py
#notes :
#python_version :3.7.3
#==============================================================================
def ticker():
filename = 'tickers.txt'
tickers = {}
with open(filename) as fh:
for line in fh:
company, ticker = line.strip().split(':', 1)
tickers[company] = ticker.strip()
return tickers
try:
comp = str(input("Enter Company name: ")).upper()
print((ticker())[comp])
except KeyError as identifier:
print("Dit bedrijf in onbekend.")
try:
tick = comp = str(input("Enter Ticker symbol: ")).upper()
print([key for key in ticker().items() if key[1] == tick][0][0])
except StopIteration as identifier:
print("Dit bedrijf in onbekend.")

+ 6
- 0
les 8/tickers.txt View File

@ -0,0 +1,6 @@
YAHOO:YHOO
GOOGLE INC:GOOG
Harley-Davidson:HOG
Yamana Gold:AUY
Sotheby's:BID
inBev:BUD

Loading…
Cancel
Save