Monday, May 30, 2022

insta profile download

 input and output:



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

dictionary and dictionary items

input:

 thisdict={

  "brand":"ford",

  "model":"musstang",

  "year":"1964"

}

print(thisdict)

output:



looping through a string

input:

 fruits=["apple","pineapple","mango"]

for b in fruits:

 print(b)

output:



 

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:

Python Identity Operators









x=10

y=20

a=x+y

print(a)

b=x-y

print(b)

c=x*y

print(c)

d=x/y

print(d)

e=x**y

print(e) 

output:



Wednesday, May 25, 2022

Python If...else Statement


1) simple if statement

x = 23

if x > 0:

print("x is positive value")

print("this is always printed")


x = -1

if x > 0:

print(x, "is positive number")

print("this is also always printed")

output:

2) if ...else statement

a = -7

if a > 0:

print(a, " is positive")

else:

print(a," is Negative")

output:





Swap two variables in one line

input:

x=45
 y=89 
x,y=y,x
 print("after swaping x values and y is-",x,y)

output:


Tuesday, May 24, 2022

Python Username and Password using if .. else

input:

 username ="shraddha"

password ="shraddha30"

x=input("enter your user name-")

y=input("enter ypur password-")

if x==username:

  if y==password:

    print("okay done!!")

else:

  print("enter your correct username and password.")

output:


python type and type casting




Main Key Points

  • input() // for get userinput value
  • int()    // 
  • eval() //
  • float()  //

 x=input("enter your age -")

print(x)

y=int(input("enter your age -"))

print(y)

z=float(input("enter your age-"))

print(z)

s=eval(input("ente your age-"))

print(s)


output:



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