You are on page 1of 2

3/3/2021 DS_Program_File_2 - Jupyter Notebook

In [1]: # DS Excercise 1.3: printing exercises


print("hello world") #printing with double quotes

hello world

In [2]: print('hello world') #printing with single quote

hello world

In [3]: c=10;v=45
b=c+v;
print(b)

55

In [4]: c

Out[4]: 10

In [5]: v

Out[5]: 45

In [6]: b

Out[6]: 55

In [7]: # possible error


print "hello world" # printing without brackets is a error

File "<ipython-input-7-808901fb1223>", line 2


print "hello world" # printing without brackets is a error
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("hello world" # printing without bracket
r)?

In [8]: # indenting with white space (white space formatting)


for i in [1,2,3,4,5]:
print(i)

1
2
3
4
5

In [9]: # possible error without indenting


for i in [1,2,3,4,5]:
print(i)

File "<ipython-input-9-85286015f0c8>", line 3


print(i)
^
IndentationError: expected an indented block

localhost:8888/notebooks/DS_Program_File_2.ipynb 1/2
3/3/2021 DS_Program_File_2 - Jupyter Notebook

In [10]: # find the output of the code


for i in [1,2,3,4,5]:
print(i)
for j in [1,2,3,4,5]:
print(j)
print(i+j)
print(i)
print("looping completed")

1
2
3
4
5
1
6
5
looping completed
2
7
5
looping completed
3
8
5
looping completed
4
9
5
looping completed
5
10
5
looping completed

In [ ]:

localhost:8888/notebooks/DS_Program_File_2.ipynb 2/2

You might also like