# Oppgave 1 def storst_av_to(tall1, tall2): if tall1 > tall2: return tall1 # return -> g?r ut av funksjon (med verdi) else: return tall2 def storst_av_to(tall1, tall2): if tall1 > tall2: return tall1 return tall2 def main(): storste = storst_av_to(3,6) print(storste) main() # Oppgave 2 fil = open("historie.txt", "r") historie_liste = [] linje = fil.readline() while linje != "": historie_liste.append(linje) linje = fil.readline() print(historie_liste) # Oppgave 3 def is_true(verdi1, verdi2): # verdiene True/False if verdi1 and verdi2: return 1 if not verdi1 and not verdi2: return 0 return -1 # Ulike verdier # Oppgave 5 liste = [2, 3, 6, 8] for tall in liste: print(tall) def skriver_ut(liste): for tall in liste: print(tall) def finn_minste(liste): minst = liste[0] for tall in liste: if tall < minst: minst = tall return minst print(finn_minste(liste)) # Oppgave 6 def ta_oppmote(filnavn): navn_fil = open(filnavn, "r") oppmote_fil = open("oppmote.txt", "w") for navn in navn_fil: navn = navn.strip() print(navn) erHer = input("Til stede? (x): ") if erHer == "x": oppmote_fil.write(navn + " - x\n") else: oppmote_fil.write(navn+"\n") navn_fil.close() oppmote_fil.close() ta_oppmote("klasse.txt")