In [1]:
1+1


Out[1]:
2

In [2]:
1*3


Out[2]:
3

In [3]:
5/5


Out[3]:
1.0

In [4]:
1/2.0


Out[4]:
0.5

In [5]:
2**3


Out[5]:
8

In [6]:
(2 + 3) * (5 + 5)


Out[6]:
50

In [7]:
4%2


Out[7]:
0

In [8]:
5%2


Out[8]:
1

In [9]:
var x = 4
var y = 16
var z = y/x


  File "<ipython-input-9-f0d39d35afaa>", line 1
    var x = 4
        ^
SyntaxError: invalid syntax

In [10]:
y/x


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-10-f6d34690dbb9> in <module>()
----> 1 y/x

NameError: name 'y' is not defined

In [16]:
x = 2 
y = 10
z = y/x
print(z)


5.0

In [12]:
y


Out[12]:
8

In [13]:
x


Out[13]:
2

In [14]:
y/x


Out[14]:
4.0

In [17]:
# strings
name = "shashank ragireddy"
print(name)


shashank ragireddy

In [21]:
course = "Engineering"
print("My name is {} and i'am an student of {}".format(name,course))


My name is shashank ragireddy and i'am an student of Engineering

In [24]:
s =  "shashank"

In [25]:
s[0]


Out[25]:
's'

In [26]:
s[0:]


Out[26]:
'shashank'

In [27]:
S[:3]


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-27-0e2e752712d2> in <module>()
----> 1 S[:3]

NameError: name 'S' is not defined

In [28]:
s[:4]


Out[28]:
'shas'

In [29]:
s[0:2]


Out[29]:
'sh'

In [30]:
s[3:5]


Out[30]:
'sh'

In [31]:
s[5:7]


Out[31]:
'an'

In [35]:
my_list = ["a","b","c"]

In [39]:
my_list


Out[39]:
['a', 'b', 'c', 'd']

In [ ]:
my_list.append('d')

In [40]:
my_list[0:3]


Out[40]:
['a', 'b', 'c']

In [41]:
my_list[:4]


Out[41]:
['a', 'b', 'c', 'd']

In [42]:
my_list[3:4]


Out[42]:
['d']

In [43]:
my_list[2:4]


Out[43]:
['c', 'd']

In [44]:
my_list[0:3]


Out[44]:
['a', 'b', 'c']

In [45]:
my_list[1:3]


Out[45]:
['b', 'c']

In [46]:
nest=[1,2,[3,4],[5,6],7,8,[9,10],[11,12],13,[14,15,16,17]]
nest


Out[46]:
[1, 2, [3, 4], [5, 6], 7, 8, [9, 10], [11, 12], 13, [14, 15, 16, 17]]

In [47]:
nest[1]


Out[47]:
2

In [48]:
nest[3]


Out[48]:
[5, 6]

In [49]:
nest[3[1]]


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-49-ef4ff7bf11b8> in <module>()
----> 1 nest[3[1]]

TypeError: 'int' object is not subscriptable

In [50]:
nest[3][1]


Out[50]:
6

In [51]:
1 > 3


Out[51]:
False

In [52]:
1 == 1


Out[52]:
True

In [53]:
1 != 4


Out[53]:
True

In [54]:
1==1 and 2 >3


Out[54]:
False

In [55]:
1==1 and 2>4


Out[55]:
False

In [56]:
1==1 and 2>1


Out[56]:
True

In [58]:
if 2 > 1:
    print('2 is greater than 1')


2 is greater than 1

In [67]:


In [ ]:


In [71]:
2>4


Out[71]:
False

In [72]:
if 10 > 5:
    print('greater')


greater

In [77]:



The value is greater than 5
The value is equal

In [81]:
x = 5

if x > 5:
    print('The value is greater than 5')
if x < 5: 
    print('The value is less than 5')
else:
    print('The value is equal')


The value is equal

In [ ]:
x = 5

if x > 5:
    print('The value is greater than 5')
if x < 5: 
    print('The value is less than 5')
else:
    print('The value is equal')

In [ ]: