In [1]:
vak = "Python"
print(type(vak))
<class 'str'>
In [2]:
aantal_lln = 24
print(type(aantal_lln))
<class 'int'>
In [3]:
gemiddelde = 7.5
print(type(gemiddelde))
<class 'float'>
In [4]:
score = 8.9
print(int(score))
8
In [5]:
deel1 = "leer"
deel2 = "kracht"
print(deel1 + deel2)
leerkracht
In [6]:
klas = "3A"
aantal = 22
print(klas, aantal)
3A 22
In [7]:
klas = "3A"
aantal = 22
print(klas + aantal)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[8], line 3 1 klas = "3A" 2 aantal = 22 ----> 3 print(klas + aantal) TypeError: can only concatenate str (not "int") to str
In [8]:
cijfer_tekst = "15"
cijfer_getal = int(cijfer_tekst)
print(cijfer_getal + 5)
20
In [9]:
punten = 18
zin = "Je hebt " + str(punten) + " punten."
print(zin)
Je hebt 18 punten.
In [10]:
antwoord = input("Wat is je lievelingskleur? ")
print(type(antwoord))
Wat is je lievelingskleur? blauw <class 'str'>
In [11]:
leeftijd = int(input("Hoe oud ben je? "))
print(type(leeftijd))
Hoe oud ben je? 16 <class 'int'>
In [12]:
a = 12
b = 7
print(a > b)
True
In [13]:
woord = "python"
print(woord == "Python")
False
In [14]:
print(True + True)
2
In [15]:
print(False == 0)
True
In [16]:
resultaat = 10 != 10
print(resultaat, type(resultaat))
False <class 'bool'>
In [17]:
uitkomst = None
print(type(uitkomst))
<class 'NoneType'>
In [18]:
uitkomst = None
print(uitkomst == None)
True
In [19]:
print(type(20 / 4))
print(type(20 // 4))
<class 'float'> <class 'int'>
In [ ]: