input and output:
Monday, May 30, 2022
creating function and arguments
what is function :
a function is a block of code which only runs when is called.
you can pass data , known as parameters , into function .
a function can return data as result.
creating a fuction
in python a fuction is defined using the def keyword :
EXAMPLE:
Arguments
information can be passed into function as arguments
EXAMPLE:
Sunday, May 29, 2022
the while loops , break statement,continue statement
the while loops :
with the while loops we can execute a set of statement as long as condidtion is true
example:
a = 1
while a < 10:
print(a)
a = a+1
output:
the break statement:
i = 1
while i < 6:
print(i)
if i == 3:
break
i += 1
output:
the continue statement:
i = 0
while i < 6:
i += 1
if i == 3:
continue
print(i)
output:
lamda syntax and example
lambda:
lamda suction take take any type of arguments
syntax:
lambda arguments: expression
example:
x = lambda a:a+50
print(x(12))
x = lambda a ,b: a*b
print(x(20,2))
x = lambda a,b,c,d : a-b*c+d
print(x(20,2,2,15))
outout:
Friday, May 27, 2022
break statement
input:
fruits=["apple","pineapple","mango","python","C++"]
for b in fruits:
print(b)
if b == "python":
break
output:
phython built in data types
thislist=["apple","pineapple","mango"]
print(thislist)
thistuple=("apple","pineapple","mango")
print(thistuple)
thistuple=("apple","mango","apple","pineapple")
print(len(thistuple))
thisset={"apple","pineapple","mango"}
print(thisset)
output:
Wednesday, May 25, 2022
Python If...else Statement
1) simple if statement
2) if ...else statement
Tuesday, May 24, 2022
Python Username and Password using if .. else
python type and type casting
Check user is eligible for voting in python
print("Check user is eligible for voting")
x = int(input("enter your age - "))
if x < 18:
print(" sorry you'r under 18 ")
else:
print("you are eligable for voting..")
output