| Koncept | Kod / Tips |
|---------|-------------|
| Indentering | Python använder mellanslag (4 st) inte tabb för block |
| Jämförelse | == (likhet), != (inte lika) |
| Tilldelning | = (ett likhetstecken) |
| Booleska uttryck | and, or, not |
| None | Representerar "inget värde" |
| break | Avbryter loop |
| continue | Hoppar till nästa iteration |
Not all PDFs are created equal. If you are hunting for the right resource, your exclusive PDF should contain the following chapters and features: programmering 1 med python pdf exclusive
Exclusive Digital Compendium
try:
tal = int(input("Ange ett heltal: "))
resultat = 100 / tal
print(f"Resultat: resultat")
except ValueError:
print("Det var inget giltigt heltal!")
except ZeroDivisionError:
print("Du kan inte dividera med noll!")
except Exception as e:
print(f"Något gick fel: e")
else:
print("Inga fel uppstod!")
finally:
print("Detta körs alltid.")