Tuesday, June 14, 2022

phython math

phython math :

x = min(5, 10, 25)
y = max(5, 10, 25)
print(x)
print(y)

x = abs(-7.25)
print(x)

x = pow(4, 3)
print(x)

import math
x = math.sqrt(64)
print(x)
x = math.ceil(1.4)
y = math.floor(1.4)
print(x) 
print(y)
x = math.pi
print(x)
output:

Wednesday, June 8, 2022

class and objects

 class and object example: 

class Person:

 def __init__(self,name,age,city):

  self.name = name 

  self.age = age

  self.city = city

p1 = Person ("shraddha",19,"babra")

print (p1.name)

print(p1.age)

print(p1.city)




Tuesday, June 7, 2022

array

what is an array?

array is special variable ,which can hold more than one value at a time.

example:

car1 = " ford "

car2 = "bmw"

car3 ="volvo"

EXAMPLE:

modify the value of the first array item:

cars[0] = "toyota"



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: