Session 2
Session 2
ipynb - Colaboratory
Basics
First Program
Arithmetic Operation
Variables
Strings
Comments
List
Tuple
Dictionary
Set
HI this is Vishwas
book
Arithmatic Operation
5+5 = 10
5+17834
17839
5/2
2.5
1435//4
https://colab.research.google.com/drive/14imixDGR-Y7pS2OnNRLUrPiVREKCpkiu#scrollTo=rUtC01FuNSVx&printMode=true 1/9
15/05/2021 Python Crash Course.ipynb - Colaboratory
358
2**4
16
Variables
Variables are the names you give to computer
memory locations which are used to store values
in a computer program.
Python is Great!
a = 2
b = 3
sum = a+b
print(sum)
5
a = '34.5'
print(type(a))
<class 'str'>
https://colab.research.google.com/drive/14imixDGR-Y7pS2OnNRLUrPiVREKCpkiu#scrollTo=rUtC01FuNSVx&printMode=true 2/9
15/05/2021 Python Crash Course.ipynb - Colaboratory
Enter a number: 7
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-17-562e36f0664a> in <module>()
1 x = input("Enter a number: ")
----> 2 y = x + 5
3 print(y)
https://colab.research.google.com/drive/14imixDGR-Y7pS2OnNRLUrPiVREKCpkiu#scrollTo=rUtC01FuNSVx&printMode=true 3/9
15/05/2021 Python Crash Course.ipynb - Colaboratory
print(type(x))
<class 'str'>
Enter a number: 3
8
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-21-c8f2adeaed02> in <module>()
1 message = "Hello Python Crash Course reader!"
----> 2 print(mesage)
String
A string is simply a series of characters.
Anything inside quotes is considered a string in Python,
and you can use single or double quotes around your strings like this:
"This is a string."
'This is also a string.'
https://colab.research.google.com/drive/14imixDGR-Y7pS2OnNRLUrPiVREKCpkiu#scrollTo=rUtC01FuNSVx&printMode=true 4/9