0% found this document useful (0 votes)
1 views5 pages

Def Funcitions

Uploaded by

hawk71443
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views5 pages

Def Funcitions

Uploaded by

hawk71443
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

'''

def fun(val1,val2=2):

if val1%val2==0:

val1 +=5

val2 +=5

else:

val2 +=val1

print(val1,val2,sep="@")

x=4

y=3

fun(x,y)

fun(x)

x=12

y=5

def fun(val1,val2=2):

if val1>val2:

return val1**2

else:

return val*2

x=fun(x,y)

print(x,"#",y)

y=fun(x)

print(x,"#",y)

a=100
b=200

def fun(x,y=20):

print(x+y)

fun(a,b)

fun(a,y=50)

fun(b,x=30) #error:TypeError: fun() got multiple values for argument 'x'

def changit(s):

a=""

for x in s:

if x in 'aeiou':

a=a+ x.upper()

elif x in 'ABCDE':

a=a+ x*2

else:

a=a+"#"

print("output=",a)

st='AraBian Sea'

changit(st)

s="Racecar car Radar"

l=s.split()

for w in l:

x=w.upper()

if x==x[::-1]:

for i in x:

print(i,end="*")
else:

for i in w:

print(i,end="#")

print()

a=10

def fun():

a=4

print(a**2)

a=a+5

print(a)

fun()

print(a)

fun()

print(a)

a=10

def fun():

a=4

print(a**2)

global a

a=a+5

print(a)

fun()

print(a)

fun()

print(a)
def fun(s):

m=""

for i in range(0,len(s)):

if i%2==0:

m=m + s[i]

else:

m=m - s[i-1]

print(m)

fun("Duffer One")

'''

You might also like