2. predefined keywords.ipynb - Colab
2. predefined keywords.ipynb - Colab
ipynb - Colab
* Characters>> string
* True/false>> Boolean
* None>>none
a =2
print(type(a))
<class 'int'>
b = 2.3
print(type(b))
<class 'float'>
c = "hello"
print(type(c))
<class 'str'>
d = True
print(type(d))
<class 'bool'>
e = False
print(type(e))
<class 'bool'>
# True = 1
# False = 0
True + False
1
True - False
1
https://colab.research.google.com/drive/1cSb9jcxnbRw8G_PZZv69MfIq1oMieclh?authuser=2 1/5
2/5/25, 11:30 AM 2. predefined keywords.ipynb - Colab
True * False
0
f = None
f # nothing to print
print(type(f))
<class 'NoneType'>
g = 1 + 2j
print(type(g))
<class 'complex'>
print(g.real)
1.0
print(g.imag)
2.0
* For multiple line comments used- on the starting line use “““ or ‘‘‘(three open double or
single inverted commas) and on the ending line use ” ” ” or ’ ’ ’(three open double or
single inverted commas).
Keywords: keywords are predefined words that holds a special meaning and have
keyboard_arrow_down special purpose.
........
https://colab.research.google.com/drive/1cSb9jcxnbRw8G_PZZv69MfIq1oMieclh?authuser=2 2/5
2/5/25, 11:30 AM 2. predefined keywords.ipynb - Colab
keyboard_arrow_down Here is a list of the Python keywords. Enter any keyword to get more help.
greater
name = "Mohit"
a = 5 #assignment
b = 4 #assignment
print(name)
mohit
print(type(name))
<class 'str'>
https://colab.research.google.com/drive/1cSb9jcxnbRw8G_PZZv69MfIq1oMieclh?authuser=2 3/5
2/5/25, 11:30 AM 2. predefined keywords.ipynb - Colab
print(num)
print(type(num))
2
<class 'str'>
num = int(num)
print(type(num))
<class 'int'>
a = "3.5"
type(a)
str
print(float(a))
3.5
print(type(a))
<class 'str'>
b = "108"
print(type(b))
<class 'str'>
b = int(b)
print(b)
print(type(b))
108
<class 'int'>
bool(0)
False
bool(1)
True
https://colab.research.google.com/drive/1cSb9jcxnbRw8G_PZZv69MfIq1oMieclh?authuser=2 4/5
2/5/25, 11:30 AM 2. predefined keywords.ipynb - Colab
a = "Ajay"
int(a)
# error bcoz str alphabates does not convert in int
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-43-9981c55bfe95> in <cell line: 0>()
1 a = "Ajay"
----> 2 int(a)
3 # error bcoz str alphabates does not convert in int
https://colab.research.google.com/drive/1cSb9jcxnbRw8G_PZZv69MfIq1oMieclh?authuser=2 5/5