def sayHello():
print('Hello World!') # block belonging to the function
# End of function
sayHello() # call the function
def boogh():
print('biib!')
def run(x0,dx):
return dx+x0
def car(x,d,b=0):
if b==1:
boogh()
r=run(x,d)
return r
car(0,2,1)
def printMax(a, b):
if a > b:
print(a,'is maximum')
else:
print(b,'is maximum')
return
printMax(4, 4) # directly give literal values
x = 5.2
y = 5.1
printMax(x, y) # give variables as arguments
printMax(1,3) # directly give literal values
def printMax(a, b):
if a > b:
print(a,'is maximum')
elif a<b:
print(b,'is maximum')
else:
print(a,'=',b)
return
printMax(3,3)
def max_in_list(l1):
max=0
for i in range(0,len(l1),1):
if l1[i]>max:
max=l1[i]
print(max, 'is maximum')
return max
l=[0,2,8,6,7,5]
o=max_in_list(l)
o
ch=True
a=0
while ch:
print(a)
a=a+1
if a==5:
ch=False
number = 23
running = True
while running:
guess = int(input('Enter an integer : '))
if guess == number:
print('Congratulations, you guessed it.')
running = False # this causes the while loop to stop
elif guess < number:
print('No, it is a little higher than that.')
else:
print('No, it is a little lower than that.')
else:
print('The while loop is over.')
# Do anything else you want to do here
def s(a):
return a**0.5
l=5
i=1
x=8
l1=[]
while i<=l:
x=s(x)
l1.append(x)
i=i+1
print(x)
l=[9,8,0,5]
l.pop(2)
l
import numpy as np
np.sqrt?