0% found this document useful (0 votes)
8 views2 pages

Python Code Examples and Errors

The document shows examples of Python code for basic data types, string operations, and variable assignments. It demonstrates printing strings with newlines and escape characters. It also shows that strings and integers are assigned by reference, while string and integer variables contain the same values but have different ids. The document restarts the Python file multiple times, each time adding additional print outputs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Python Code Examples and Errors

The document shows examples of Python code for basic data types, string operations, and variable assignments. It demonstrates printing strings with newlines and escape characters. It also shows that strings and integers are assigned by reference, while string and integer variables contain the same values but have different ids. The document restarts the Python file multiple times, each time adding additional print outputs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python 3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.

1916 64 bit (AMD64)] on win32


Type "help", "copyright", "credits" or "license()" for more information.
>>> 6
6
>>> print()

>>> print('lpu')
lpu
>>> print('LPU\N')
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 3-4:
malformed \N character escape
>>> print('LPU\n')
LPU

>>> type('')
<class 'str'>
>>> type('56')
<class 'str'>
>>> name = 'Vinay'
>>> name2 = name
>>> id(name)
2484240266416
>>>
>>>
>>>
>>> id(name2)
2484240266416
>>> age1 = 18
>>> age2 = age1
>>> id(age1)
2484194077520
>>> id(age2)
2484194077520
>>>
============================================================= RESTART:
E:/Python/Python [Link]
============================================================
Vinay Kumar
>>>
================================================================ RESTART:
C:/Python/[Link]
================================================================
Vinay Kumar
LPU University
>>>
========================== RESTART: C:/Python/[Link] =========================
Vinay Kumar
LPU University
LPUUniversity
>>>
========================== RESTART: C:/Python/[Link] =========================
Vinay Kumar
LPU University
LPUUniversity
LPU*University
>>>
========================== RESTART: C:/Python/[Link] =========================
Vinay Kumar
LPU University
LPUUniversity
LPU*University
Bihar*Vinay
>>>

You might also like