228122, 950 PM
In [6]:
In [8]:
out[8]:
In [3]:
In [4]:
4141 Stings -Jupyter Notebook
Paramaters of print function
Use of raw string
file_path = 'C:\Users\Pratik\19 Feb 2022'
file_path
File "cipython-input-6-4e97375a084e>", line 1
file_path = ‘C:\Users\Pratik\19 Feb 2022"
syntaxError: (unicode error) ‘unicodeescape’ codec can't decode bytes in positi
fon 2-3: truncated \UXKKXXXXX escape
file_path = r'C:\Users\Pratik\19 Feb 2022"
print(file_path)
file_path
C:\Users\Pratik\19 Feb 2022
“Cs\\Users\\Pratik\\19 Feb 202°
print(‘this is not 2 new Line \n rather it is just \ & n‘)
‘this is not a new line
rather it is just \ &n
print(r'this is not a new line \n rather it is just \ & n')
‘this is not a new line \n rather it is just \ &n
Comments in Python
define:
used to explain the code
sometimes it is also used to stop the execution of the code lines while
testing/running.
not use a line as code
using # we can comment a line
shortcut - ctrl + /
locahost 8888inotebooks/Downloads/1.4.1 Stings Joynb228122, 950 PM
In [13]:
out [13]:
In [ ]:
In [14]:
In [15]:
In [22]:
In ]:
41.44 Stings - Jupyter Notebook
# We are writing a code of variables below:
variable = ‘Hello’
print (variable)
variable+’ World’
"Hello World’
Indentation Error
Unexpected spaces causes Indentation error
a=10
b= 20
a=10
b= 20
File "", line 2
b= 20
IndentationError: unexpected indent
if a == 10:
print(a)
File "", line 2
print(a)
IndentationError: expected an indented block
locahost 8888inotebooks/Downleads/1.4.1 Stings ioynb