Python notes
Print (max (3,4)) for 4
Same can be applied as
Min
Round
Abs for absolute negative will become positive
% between 3 numbers for the remainder
For more math functions
from math import *
print(floor(3.7))= 3
similar ceil for opposite
sqrt for squire root
for take the input from the customer
name = input("Enter you name: " )
age = input("Enter you age: " )
print("Hello " + name+ "! you are " +age+ " year old")
Joining two lists
lucky_numbers = ["2","35","35", "33"]
friends= ["hero","zero","ajay","raju", "viraj"]
[Link](lucky_numbers)
print(friends)
we can use [Link] to add the new friend in the list but it will
add in the end only
to add in between we can use
[Link](1,”Dinesh”) where 1 shows position and second friends
name
[Link](“name”) to remove the specific friends and
[Link] to delete all the friends
[Link]() to remove last person of the list
print([Link](“name”)) it gonna tell index of the person
print([Link](“name”)) to know the number of same name in the
list.
print([Link]()) to short the list according to name
friends2 = [Link]()
Tuple
coordinates= (4,5)
print(coordinates)
in list
coordinates= [4,5]
coordinates[1] = 15
print(coordinates)
the main difference in tuple and list is that data in tuple cannot be
changes but can be done in case of list.
functions
def say_hi(name, age):
print("Hello " + name + ", you are " + age +",")
say_hi("mike", "35")
say_hi("hero", "15")
def cube(num):
return num*num*num
print(cube(5))
if statement
is_Nidhi = True
is_Neha = False
if is_Nidhi or is_neha:
print("You are great women")
else:
print("you r bad women")
if and or statement
is_Nidhi = True
is_Neha = False
if is_Nidhi and not(is_Neha):
print("you are my women")
elif not(is_Nidhi) and is_Neha:
print("you are my Di")
else:
print("you r bad women")
Calculator of better level
num1 = float(input("Enter your first number: "))
op = input("Enter your first number: ")
num2 = float(input("Enter your second number: "))
if op == "+":
print(num1 + num2)
elif op == "-":
print(num1 - num2)
elif op == "*":
print(num1 * num2)
elif op == "/":
print(num1 / num2)
else:
print("Invalid input")
while loop