Saturday, 3 July 2021

Python if / else

 Python if / else

a1=int(input("Enter the number:\n"))
a2=int(input("Enter the number:\n"))
a3=int(input("Enter the number:\n"))
a4=int(input("Enter the number:\n"))
if((a1>a2)and(a1>a3)and(a1>a4)):
    print(a1,"is greater than ",a2,a3,a4)
elif((a2>a1)and(a2>a3)and(a2>a4)):
    print(a2," is greater than",a1,a3,a4)
elif((a3>a1)and(a3>a2)and(a3>a4)):
    print(a3," is greater than",a2,a1,a4)
else:
    print(a4," is greater than",a2,a3,a1)
    

a1=int(input("Enter the number:\n"))
a2=int(input("Enter the number:\n"))
a3=int(input("Enter the number:\n"))
a4=int(input("Enter the number:\n"))
if(a1>a4):
    f1=a1
else:
    f1=a4
if(a2>a3):
    f2=a2
else:
    f2=a3
if(f1>f2):
    print(f1,"is a greater")
else:
    print(f2,"is a greater")


comment=input("Enter the comment :\n")
Spam=False
if("make a lot of moneyin comment):
    Spam=True
elif("buy nowin comment):
    Spam=True
elif("subcribe thisin comment):
    Spam=True
elif("click thisin comment):
    Spam=True
else:
    Spam=False
if(Spam):
    print("text is a spam")
else:
    print("text is not a spam")



Username=input("Enter the user name :\n")
a=int(len(Username))
# print(a)
if(a<10):
    print("Yes")
else:
    print("NO")



l1=["ram","shaam","upendra","nitesh","maya"]

name=input("Enter the name U want:\n")
if(name in l1):
    print("yes")
else:
    print("No")

marks=int(input("Enter the marks obtained :\n"))
if(marks>=90 and marks<=100):
    pgrade='Ex'
elif(marks>=80 and marks<=90):
    grade='A'
elif(marks>=70 and marks<=80):
    grade='B'
elif(marks>=60 and marks<=70):
    grade='C'
elif(marks>=50 and marks<=60):
    grade="D"
else:
    grade="F"

print("Your grade is "+grade)



post=input("Enter the post:\n")
if("harryin post):
    print("yes")
elif("Harryin post):
    print("yes")
elif("HaRRyin post):
    print("yes")
elif("HArryin post):
    print("yes")
elif("HArrYin post):
    print("yes")
elif("HARRYin post):
    print("yes")
else:
    print("no")


age=int(input("Enter the age:\n"))
if(age>=18):
    print("yes")
else:
    print("no")



a=20
if(a>10):
    print(,"is greater than 10")
elif(a>5):
    print("a is greater than 20")
else:
    print("a is not greater than 20 nor equal to 20")




Python Sets and Dictonaries

 Python Sets and Dictonaries 

HindiDic={
    "kaam":"work",
    "aam":"mango",
    "kitab":"book",
    "naam":"name"
}
print("Option are",HindiDic.keys())
print("the value of the dictionary is ",HindiDic.values())
a=input("Enter the hindi words:\n")
print("English meaning is :",HindiDic.get(a))


n1=int(input("Enter the  number1:\n"))
n2=int(input("Enter the  number2:\n"))
n3=int(input("Enter the  number3:\n"))
n4=int(input("Enter the  number4:\n"))
n5=int(input("Enter the  number5:\n"))
n6=int(input("Enter the  number6:\n"))
n7=int(input("Enter the  number7:\n"))
n8=int(input("Enter the  number8:\n"))

number_set={n1,n2,n3,n4,n5,n6,n7}
print(number_set)
number_set.add(200)
number_set.add((25,50,150,456))
print(number_set)


a=int(input("Enter the value :\n"))
b=input("Enter the values:\n")
ab_set={a,b}
print(ab_set)
s={18,'18'}
print(s)


s=set()
s.add(20)
s.add("20")
s.add(20.0)

print(len(s))
print(s)


myfriend={}
languague1 = input("Enter yours fav computer languague:\n")
languague2 = input("Enter yours fav computer languague:\n")
languague3 = input("Enter yours fav computer languague:\n")
languague4 = input("Enter yours fav computer languague:\n")
myfriend["upendra"]=languague1
myfriend["ram"]=languague2
myfriend["shaam"]=languague3
myfriend["upendra"]=languague1
print(myfriend)
myfriend["upendra"]="c++"
myfriend.update({"nitesh":"cout"})
print(myfriend)


Python List and Tuple

 f1=input("Enter the name of fruits 1: \n")

f2=input("Enter the name of fruits 2: \n")
f3=input("Enter the name of fruits 3: \n")
f4=input("Enter the name of fruits 4: \n")
f5=input("Enter the name of fruits 5: \n")
f6=input("Enter the name of fruits 6: \n")
f7=input("Enter the name of fruits 7: \n")
fruit_list=[f1,f2,f3,f4,f5,f6,f7]
print(fruit_list)



marks_student1=input("Enter the marks of student 1:\n")
marks_student2=input("Enter the marks of student 2:\n")
marks_student3=input("Enter the marks of student 3:\n")
marks_student4=input("Enter the marks of student 4:\n")
marks_student5=input("Enter the marks of student 5:\n")
marks_student6=input("Enter the marks of student 6:\n")
marks_lists=[marks_student1,marks_student2,marks_student3,marks_student4,marks_student5,marks_student6]
print(marks_lists)
marks_lists.sort()
print(marks_lists)
print(marks_lists[0])

t=(1,2,3,4,8,10,35,1,1,"upendra")
print(t)
# t[3]=12
print(t.index(10))


l1=["upendra",12,1,45,14.02,True,"harry"]
print(l1)
l1.append(4)
print(l1)


a=[1,45,85,785]
print(a[0]+a[1]+a[2]+a[3])
a[3]=456230
print(a[0]+a[1]+a[2]+a[3])
print(sum(a))


t1=(1,"hello",12,1,0,0,456.2,0,"harry")
print(t1.count(0))

Python if / else

 Python if / else a1 = int ( input (" Enter the number: \n ")) a2 = int ( input (" Enter the number: \n ")) a3 = int ( i...