Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Adobe Connect-koodipaja, 7.10.2021
- print("Tervetuloa!")
- # tämän voisi kysyä käyttäjältä
- score = 50
- # if-elif on kätevä, koska sen avulla vain
- # YKSI "if" -lause käynnistyy tarvittaessa!
- if 0 < score < 20:
- print("Ensimmäinen if-lause")
- elif 20 < score < 40:
- print("Toinen if-lause")
- elif 40 < score < 60:
- print("Kolmas if-lause")
- print("Ohjelma loppui!")
- # UUSI TIEDOSTO
- year = 2018
- print(f"Vuosiluku sulkeissa ({year})")
- print("Vuosiluku sulkeissa " + "(" + str(year) + ")")
- # UUSI TIEDOSTO
- # jos teksti on sama oikeinpäin ja väärinpäin, kyseessä on palindromi
- text = "niin niin"
- reversed = text[::-1]
- print(text)
- print(reversed)
- if text == reversed:
- print("Tekstit ovat samoja!")
- else:
- # ei ole palindromi
- print("Ei ole ei...")
- # UUSI TIEDOSTO
- # booleanit on hyvä alustaa ohjelman alussa
- freezing = False
- heatwave = False
- raining = False
- hailstorm = False
- # nämä käyttäjältä
- temperature = 15
- humidity = 75
- # tähän tulee kaikki if-lause -logiikka mikä muuttaa ylläolevia booleaneja!
- if temperature > 20:
- heatwave = True
- # lopuksi käytetään booleanien tuloksia hyödyksi!
- if freezing:
- print("Kylymä!")
- if heatwave:
- print("KUUMA!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement