0% found this document useful (0 votes)
27 views9 pages

Function

The document discusses Python programs to encrypt names, count strings in a list based on start and end characters, create a dictionary from a list with elements as keys and their division by 3 as values, and define a function to add two numbers.

Uploaded by

Deepak S
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)
27 views9 pages

Function

The document discusses Python programs to encrypt names, count strings in a list based on start and end characters, create a dictionary from a list with elements as keys and their division by 3 as values, and define a function to add two numbers.

Uploaded by

Deepak S
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
You are on page 1/ 9

l} encryptname.py - C:/Usersjbabua/App0ata/Local/Programs/Python/Python39/encryptname.py (L. D X Ll IDLE Shell 3.9.

13 D X
File Edit Format Run Options Wmdow Hel p File Edit Shell Debug Options Window Help
texercise 1 • Pytho n 3_9 . 13 (tags/ v3 . 9 . 13 : 6de2ca 5, May 17 2022 , 16 : 36 :42) [MSC v. 1929 64 bit (AMD64 )J on wi n32
n=input ("E:nte r The Name ") T ype "help" , " copyright" , " credit s " or " l i cense () " f or mor e i n f ormation .
e ="" »>
for i in n : = RESTART : C : / Users / babua/ AppData/ Loca l/P r ograms/Pyt hon/Pyt hon39/encr yptname . py
if i . i s alpha () : Ente r The Name anandu babu
if i. isuppe r () : Partly Encrypted name : nanaqh onoh
e +=chr ( (ord (i) - 65+13 ) 1:26+65) »>
else :
e +=chr ( (ord ( i ) - 97+13 ) \26+97 )
else :
e+=i
print ("Pa rtl y Encrypted name : " , e )

~
Ln: 12 Col:3 Ln: 7 Col: 4

D Q Search ~ 1.. O O ID il rzsl @J


L.l countpy - C:/Users/babua/AppData/local/ProgramsfPYthon,IPython39/countpy (3.9.13) D X 11, IDLE Shell 3.9.13 D X
File Edit Format Run Options Windo_w_ H_e..:.
IP_ _ _ _ _ _ _ _ _ _ __ __ File Edit Shell Debug Options _ w_c,n...:c.
do,_v _ Hc_
el:::_
p _ _ _ _ _ __ _ _ __ _ _ _ _ _ _ _ __
texercise 2 • Python 3 . 9 . 13 (tags/v3.9.13:6de2ca5, May 17 2022, 16 : 36 : 42) (MSC v . 1929 64 bit (AMD64)]
n=i nt (input ( "enter the number of strings • )) on win32
s ~ [J Type "help", " copyright", " credits" o r " license() " for more information.
for i in r a nge (n)I: >»
k=input ( "enter the string ") = RESTART : C: /Osers/babua/AppData/Local/Programs / Pyt.hon /Python39/count . py =
s. append I k) enter the number o f strings : 4
print (s ) enter the string abc
c =O enter the s t ring : xyz
for j ...n s: enter the string : aba
if l e n (j)>2 a1 j(O)••j(-1] : enter the s tring : 1221
c•c+l [ 'abc', ' xyz', ' a ba ' , ' 1221 ' )
print ( "count of strings : • ,c ) count o f strings : 2
»>

ln:4 Col: 18 Ln: 12 Col: 4

II Q Search
l) list_dictpy - C:/Users/babua/AppData/local/Programs/Python/Python39/list_dlcLpy (3.9.13) - D X t_.l IDLE Shell 3.9.13 - D X
File Edit Format
lexercise 3
n'=input ( " enc.er
Run Options Wmdow Help

the elements f o r lis t s e parated by space ")


. File Edit Shell Debug Options Window Help

win32
----
Pytho n 3 . 9 . 13 (tags/ v 3. 9 .13: 6de2ca5 , May 17 2022, 16 , 36 , 42) [MSC v.1 929 64 bit (AM064) I on .
l = [int (i) for i in n.split()] ' Type '"he lp'", '"copyright '", "credits " o r "license()" f o r more informatio n.
d = {x : x/3 f r X 1.n l} >»
print (!) = RESTART : c : /Users/babua/AppData/Local/Programs/Python/Py thon39 / list_diet . py •
print. (d) ente r t he elements f or list separated by space 30 15 9 6 12 33 300
(30, 15, 9, 6 , 12 , 33, 300) '
(30 , 10 . 0 , 15 , 5 . 0 , 9 , 3.0, 6, 2 . 0, 12 , 4 . 0 , 33 , 11.0 , 300 , 100 . 0)
>>> I

.
l.lt8 Col:O l.lt8 Col:4
.
ENG
II Q Search IN
l_.l list_dictpy - C:/Users/babua/AppDataflocal/Programs/Python/Python39/list_dlcLpy (3.9.13) D X I) IDLE Shell 3.9.13 D X
File Edit Form at Run Opt1ons_ W __
_on_d_ow H_el~p_ __ _ _ _ __ _ _ _ _ __ File Edit Shell Debug Options Window ;H-e~lpc-------c=-c=c----c-c---ccc-cc--,-----c:-:-:-:--=,-:--7:""-:-,-.
#e xercise 4 ..a Python 3 . 9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16 : 36 : 42) [MSC v. 1929 64 bit (AM064)) on •
def s um(a,b): win32
return (a+b) "copyright'", " credits " or " license()'" f o r more information .
Type "he l p " ,

def mult (a, b) : = RESTART: c : /Users/babua/Appoata/Local/Programs/Python/Python39/list diet . py ,.,
return (a•b) Enter 1st number: 10 -
Enter 2nd number: 20
def div (a,b): press 1 f or sum
return (a/b) press 2 for mul
press 3 f or div
def sub (a,b): press 4 f or sub
r turn (a-b) 1
30
»>
x =int (input ( ' Enter 1st numbe-r : ' I)
y =int (input ( 'Ent er 2nd number : ' ))
c•int (input ( ' pr ess 1 !or sum \n press 2 for mu l \n press J !or d i v \n press 4 !or sub \n ' ) I
if (c==l I :
f=-:,wn (x, y)
print (fl
ellf (c••2 ) :
g=mul t (X, y )
print (g)
e_if (c••3 ):
h ::zdiv (X, y)
print (h i
e.1..i.f (c• •4):
k::zsub (X, y )
print (k)

e ... ,e :
print ( " inw11id" )

.
Ln: 17 Col: 81 Ln: 13 Col: 4

ENG
II Q Search 0 IN
l) list_dictpy - C:/Users/babua/AppData/local/Programs/Python/Python39/list_dlCt.py (3.9.13) D X l) IDLE Shell 3.9.13 D X

File Edit Format Run i ,o


Op_ d_
_n_s_ W_m_ow He
__ ~ -- - - - -- - - - - - - - -
_ lp File Edit Shell Debug Options Window Help _ __
lexercise 5 • Python 3 . 9 . 13 (tags/ v3.9.13:6de2ca5 , May 17 2022, 16 : 36 : 42) [MSC v.1929 64 bit. (AM064)) o •
def aargument s (a , b=lO,c=N ne ): n win32
if c =Nrine : Type •help• , " copyright.•, "credit.s " o r "license()" for more inform.at.ion.
s=a+b >»
print ( •sum of n ~ r s = " , s ) = RESTART : c: /users/babua/AppDat.a/Local/Programs/Pyt.hon/Py t.hon39 / list. dict.py •
~lse : sum o f numbers = 4 4 -
d=a•b•c product o f numben: ::: 126
print. ( •product. of n~t.s = " ,d) »> I

aarguments (5, b-39)


aargument.s (3, b•6, c•7)

ln: 12 Col: 19 Ln: 7 Col:4

ENG
Q Search IN
l) list_dictpy - C:/Users/babua/AppData/local/Programs/Python/Python39/list_dlcLpy (3.9.13) D X I) IDLE Shell 3.9.13 D X

File Format
Edit Run Op_ ow
_n_s_ W_m_d_
i ,o He_l ~
__ p -- - - - -- - - - - - - - - File Edit Shell Debug Options Wir'ldow c-
He - ,---,-=-=-=----c-cc-=-c--c--cc--;:-=-=::-c--:-:---:--,-
_lp
lexercise 6 .. Pytho n 3 . 9 .13 (tags/v3.9.13:6de2ca5, May 17 2022 , 16 : 36 :42) (MSC v. 1929 64 b it (AM064) ] on •
def e ve n (•a): win32
o =O Type "he lp•, " copyright•, "credits " or "lic ense ()" f o r mo re information.
tor i in a: »>
if i\:2=0: = RESTART : C : /Osers/babua/AppData/Local/Programs/Python/Python39/list diet .py ,.
c:c+i s um o f even numbers = 20 -
print ( "sum of e ven numbers= " ,c) sum o f even numbers "" 0
»> I

even(l,2, 3,4,S, 6, 7,8)


even(l , 3,5,7 , 9)

ln: 3 Col: 7 Ln: 7 Col: 4

ENG
Q Search
IN
l) list_dictpy - C:/Users/babua/AppData/local/Programs/Python/Python39/list_dlCt.py (3.9.13) - D X l) IDLE Shell 3.9.13 - D X
File Edit Format Run Options
#exercise 7
d e f product (a, b , c=l, td) :
Wmdow Help
. FileEdit Shell Debug Options Window Help
Python 3.9. 1 3 (tags/v3. 9.13: 6de2ca5, May 17 2022 , 16 , 36 , 42) [MSC v.1929 64 bit (AM064) I on
win32
.
c""atb•c Type "he lp", "copyr ight", "credits" o r "license() " for more information .
for i in d: »>
c=cti = RESTART : C: /Users/babua/AppData/Local/Program.s/Python/Python39/ list_diet. py •
product o f numbers = 40320
print ( "product of numbers = " ,c) product o f numbers = 3
»>

product (1, 2, 3 , 4, 5, 6, 7 , 8)
product(l,3)

-
ln: 13 Col: 11
. .
Ln: 7 Col:4

ENG
Q Search O O ID B l25J r® IN
l) list_dictpy - C:/Users/babua/AppData/local/Programs/Python/Python39/list_dlcLpy (3.9.13) D X ~ IDLE Shell 3.9.13 D X
File Format
Edit Run Op_ d_
_n_s_ W_m_
i,o ow__ ~ -- - - - -- - - - - - - - -
_ lp
He File Edit Shell Debug Options H_
Window c:- p-
el',, --c-=---cc=-----ccc---=-c--c-=-,----= -::----:-=:-:-:-:--
lexercis e 8 _. Python 3 . 9.13 (tags / v 3.9.13 : 6de2ca5, Hay 17 2022, 16 : 36 : 42) [MSC v. 1929 64 bit (AH064)] on •
d e f strings (a) : win32
b = [i for i J.n a . f len (i)>:::5] Type "he lp", " copy right." , "credits " o r " license() " f o r more informa tion .
return (b) >»
= RESTART : c : / Users / babua / Appoata /Local / Programs/ Python/ Python39/ list diet . py -=
enter the list. by space : qgssg gxh xhh shsh shs xhxhxxh -
[ • qgssg •, • shshshs ' , 'xhxhxxh ' J
n=input ( " ent.er the list. b y space ") »> I
l:::[i hr i .1,.n n.split() J
r=strings (l)
print (r)

Ln: 1 Col: 11 Ln: 7 Col: 4

ENG
II Q Search
o o ■ B l25J r® IN
l) list_dictpy · C:/Users/babua/AppData/local/Programs/Python/Python39/list_dlcLpy (3.9.13) D X t_.l IDLE Shell 3.9.13 D X

File Edit Format Run d_


_n_s_ W_m_
i ,o
Op_ ow He
__ ~ -- - - - -- - - - - - - - -
_ lp File Edit Shell Debug Options ,.
Window -=H_el_P,----c-cc--==,--c-=--c-c--cc,,.-=c::------:=-=-::-:--:-,-
lexercise 9 • Python 3 . 9 .13 (tags/ v 3.9. 1 3:6de2ca5 , May 17 2022, 16 : 36 : 42) [MSC v.1 929 64 bit (AM064)] on •
def vowel (a) : win32
v= [ 'a' , ' e •, ' i ' , ' o ' , 'u' , 'A' , 'E' , ' I • , ' O' , ' U ' J Type "he lp", " copyright ", "credits " o r "license()" f o r more informatio n.
b = [ "" . join (i f r i ..n k .. f i n,t .. n v ) f r k in a ) >»
return (b) = RESTART : c : /Users/babua/AppData/Local/Programs/Python/Py thon39 / list dict . py •
ente r the list by space : apple c ar book cat -
list after removed vowels: ( ' ppl ' , ' er ' , ' bk ' , ' ct ' ]
»> I
n=i nput ( "e nter the list b y space ")
l = [i f·,r i in n . split()}
r=vowel Ill
print ( " list after removed vowels • ,r)

ln:4 Col:53 Ln: 7 Col:4

Q Search O O ID B l25J r@ ENG


IN

You might also like