Skip to main content

Python : If Else (CWH)



 #Program to find out whether a student is pass or fail,if it requires total 40% and at least 33%,in each subject to

pass.Assume 3 subject and take marks as an input from the user


sub1=int(input("Enter first subjrct marks \n"))
sub2=int(input("Enter second subjrct marks \n"))
sub3=int(input("Enter third subjrct marks \n"))

if(sub1<33 or sub2<33 or sub3<33):
    print("You are fail marks is less then 33")
elif((sub1+sub2+sub3)/3 <40):
    print("You are fail total is less then 40")
else:
    print("You are pass :)")

#Program to find a spam comment is defined as a text containing following keywords : make a lot of money,buy now,
    subscribe this,click this

comment =input("Enter the text \n")
if("make a lot of money" in comment):
    spam = True
elif("buy now" in comment):
    spam = True
elif("click this" in comment):
    spam = True
elif("subscribe this" in comment):
    spam = True
else:
    spam= False

if(spam):
    print("text have spam")
else:
    print("No Spam")

#Program to find whether a given username contains less than 10 characters or not

username=input("Enter Username \n")
length=len(username)
if(length<10):
    print("Length is less then 10")
else:
    print("Length is more then 10")


#Program to find out whether a given name is present in a list or not

names=["Animesh","rohit","Vikas"]
name=input("Enter the name to check \n")

if (name in names):
    print("Your name is present in the list")
else:
    print("Your name is not present in the list")

#Program to calculate the grade of a student from his marks the following scheme:
        90-100 -> Ex        80-90 -> A        70-80 ->B        60-70 ->C        50-60 -> D        <50 ->F

marks = int(input("Enter total marks \n"))
if(marks>100 or marks<0):
    print("Marks is Incorrect")
elif(marks<=100 and marks>=90):
    print("Grade is Ex")
elif(marks<90 and marks>=80):
    print("Grade is A")
elif(marks<80 and marks>=70):
    print("Grade is B")
elif(marks<70 and marks>=60):
    print("Grade is C")
elif(marks<60 and marks>=50):
    print("Grade is D")
else:
    print("Grade is F")

#Program to find out whether a given post is talking about "Animesh" or not

rawpost = input("enter post \n")
post=rawpost.lower()
if("animesh" in post):
    print("Found")
else:
    print("Not Found")

Popular posts from this blog

C++ : Calculator

  # include < iostream > using namespace std ; int main () {     int a , b ;     char o ;     float c ;     cout << " Enter Value of A \n " ;     cin >> a ;     cout << " Enter Value of B \n " ;     cin >> b ;     cout << " Enter Operation \n " << " + for Addition \n - for substration \n * for multiplication \n / for division \n " ;     cin >> o ;     switch ( o )     {         case ' + ' :       {            c = a + b ;             break ;       }       case ' - ' :       {           c = a - b ;           break ;       }       case ' / ' :       {         ...

C++ : Pointer Program

# include < iostream > using namespace std ; int main () {     int a = 4 ;     int * b =& a ;     // & is address of operator     cout << " Thr address of a is " << & a << endl ;     cout << " Thr address of a is " << b << endl ;     // * is value at dereference operator     cout << " Thr value of a is " << * b << endl ;           // Pointer to pointer     int ** c =& b ; cout << " The adress of b is " << & b << endl ;     cout << " The adress of b is " << c << endl ;     cout << " The value at address c is " << * c << endl ;     cout << " The value at address value_at (value_at( c )) is " << ** c << endl ;     } OUTPUT =>           Thr address of...

Python : Small Projects (CWH)

  # Project 1 : Snake, Water, Game OR Rock,Paper,Scissor import random def game ( comp , you ) :     if comp == you :         return 2     elif comp == " s " :         if you == " w " :             return 0         elif you == " g " :             return 1     elif comp == " w " :         if you == " g " :             return 0         elif you == " s " :             return 1     elif comp == " g " :         if you == " w " :             return 0         elif you == " s " :             return 1 print ( " Computer turn : Snake(s),Water(w) or Gun(g) " ) randno = random . randint ( 1 , 3 ) if randno == 1 :  ...