0% found this document useful (0 votes)
25 views7 pages

PYTHON PROGRAMMING Notes

My notes for python programming

Uploaded by

Trap Remix
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)
25 views7 pages

PYTHON PROGRAMMING Notes

My notes for python programming

Uploaded by

Trap Remix
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

18CSE028J

PYTHON
PROGRAMMING
 Python Programming using Input and Output function
 Python Programming using Control Flow Statements and Functions
 Python Programming to implement various operations on String
 Python Programming to implement various operations on List
 Python Programming to implement various operations on Set
 Python Programming to implement various operations on Dictionary
 Python Programming to implement various operations on Tuples
 Python Programming using Database Connectivity
 GUI Programming using Tkinter
 Program using Numpy and Pandas
Input and Output function
print()
a=5
print('The value of a is', a)
print(*objects, sep=' ', end='\n', file=[Link], flush=False)
 Here, objects is the value(s) to be printed.
 The sep separator is used between the values. It defaults into a space
character.
 After all values are printed, end is printed. It defaults into a new line.
 The file is the object where the values are printed and its default
value is [Link] (screen).
print(1, 2, 3, 4)
print(1, 2, 3, 4, sep='*')
print(1, 2, 3, 4, sep='#', end='&')
Output formatting
>>> x = 5; y = 10
>>> print('The value of x is {} and y is {}'.format(x,y))
The value of x is 5 and y is 10
 curly braces {} are used as placeholders.
 We can specify the order in which they are printed by using numbers
(tuple index).
print('I love {0} and {1}'.format('bread','butter'))
print('I love {1} and {0}'.format('bread','butter'))
use keyword arguments to format the string
>>> print('Hello {name}, {greeting}'.format(greeting = 'Goodmorning',
name = 'John'))
Hello John, Goodmorning
 use the % operator
>>> x = 12.3456789
>>> print('The value of x is %3.2f' %x)
The value of x is 12.35
>>> print('The value of x is %3.4f' %x)
The value of x is 12.3457
Python Input
input() function
>>> num = input('Enter a number: ')
Enter a number: 10
>>> num
'10‘
>>> int('10')
10
>>> float('10')
10.0
 same operation can be performed using the eval() function
int('2+3')
eval('2+3')
Python Import
import math
print([Link])
>>> from math import pi
>>> pi

You might also like