Created directories for the chapters

This commit is contained in:
2022-01-08 20:58:38 +01:00
parent aecb16fe01
commit f83d307a1e
59 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
x = 10
if not (x > 15):
print ("Sant, eftersom 10 INTE är större än 15")

11
kapitel7/sidan_103_ex1.py Normal file
View File

@@ -0,0 +1,11 @@
x = 10
y = 15
if ((x > 5) and (y < 10)):
print ("Jag kommer aldrig skrivas ut")
if ((x > 5) or (y < 10)):
print ("Däremot kommer jag att skrivas ut")
if ((x == 10) and (y > 12)):
print ("Jag kommer också att skrivas ut")

View File

@@ -0,0 +1,3 @@
namn = input("Ange namn: ")
print ("Hej " + namn)
print (type(namn))

View File

@@ -0,0 +1,7 @@
x = input("Ange basen: ")
y = input("Ange exponenten: ")
x = float(x)
y = float(y)
s = x**y
print (str(x) + " upphöjt till " + str(y) + " blir " + \
str(s))

View File

@@ -0,0 +1,6 @@
x = input("Ange basen: ")
y = input("Ange exponenten: ")
x = float(x)
y = float(y)
s = x**y
print ("%.1f upphöjt till %.1f blir %.1f" %(x, y, s))

View File

@@ -0,0 +1,6 @@
a = "Hej"
b = "Kalle"
x = 5
y = 4
print ("%s %s" %(a, b))
print ("%d+%d=%d" %(x, y, x+y))

View File

@@ -0,0 +1,3 @@
lista = ["Kalle", "Lisa", "Linda"]
for namn in lista:
print ("Hej %s, hur är läget?" %namn)

View File

@@ -0,0 +1,3 @@
celsius = [10, 15, 20, 25, 30]
for c in celsius:
print ("%dC = %dF" %(c, (c*1.8)+32))

View File

@@ -0,0 +1,2 @@
for c in range(-20, 30, 3):
print ("%dC = %dF" %(c, (c*1.8)+32))

15
kapitel7/sidan_116_ex1.py Normal file
View File

@@ -0,0 +1,15 @@
konton = {"Kalle": 300, "Joakim": 1800, "Lisa": 900}
hogst = 0
rikast = str()
for i, j in konton.items():
print(i, j)
if (hogst == 0):
hogst = j
rikast = i
if (j > hogst):
hogst = j
rikast = i
print (rikast, "är rikast!")

View File

@@ -0,0 +1,4 @@
counter = 5
while counter > 0:
print (counter)
counter = counter - 1

View File

@@ -0,0 +1,5 @@
while True:
text = input("Skriv något: ")
if (text == "klar"):
break
print (text)

View File

@@ -0,0 +1,4 @@
for i in [1, 2, 3, 4, 5]:
if (i == 3):
continue
print (i)

View File

@@ -0,0 +1,9 @@
a = [1, 2, 3, 4]
b = [5, 6, 7, 8]
for i in a:
print ("\n" + str(i))
for j in b:
print (" " + str(j))
if j == 6:
break

12
kapitel7/sidan_124_ex1.py Normal file
View File

@@ -0,0 +1,12 @@
antal = 0
summa = 0
while True:
x = input("Ange tal: ")
if (x == "klar"):
break
x = float(x)
summa = summa + x
antal = antal + 1
print ("Medelvärdet är %.1f" %(summa/antal))

5
kapitel7/sidan_99_ex1.py Normal file
View File

@@ -0,0 +1,5 @@
x = 50
if (x > 20):
print (str(x) + " är större än 20")
if (x > 10):
print (str(x) + " är större än 10")

8
kapitel7/sidan_99_ex2.py Normal file
View File

@@ -0,0 +1,8 @@
namn = "Karin"
if (namn == "Karin"):
print ("Hej Karin, välkommen till systemet")
inloggad = 1
x = 9**2
print (x)
print ("Nu är vi utanför if och denna meningen skrivs \
alltid")