0% found this document useful (0 votes)
3 views4 pages

Python Basics: Conditionals & Functions

Uploaded by

namahshivayao11
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Python Basics: Conditionals & Functions

Uploaded by

namahshivayao11
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import math

marks=(int)(input("enter marks"))

if marks >= 60:

print("first class")

elif marks >= 50:

print("second class")

elif marks>= 35:

print("third class")

else:

print("fail")

x = (int)(input("enter number"))

y = (int)(input("enter another"))

z = (int)(input("enter another"))

if x >= y and x >= z:

print(x , "is greatest")

elif y >=x and y >= z:

print(y, "is greatest")

else:

print(z, "is greatest")

uname = input("enter username ")

pwd = input("enter password ")

if uname != "barch" and pwd!= "2sem":

print("both username and password are wrong")

elif uname == "barch" and pwd != "2sem":

print("password is wrong")

elif uname != "barch" and pwd == "2sem":

print("wrong user name")

else:

print("login success")
ch = input("enter any alphabet")

if ch == 'A' or ch == 'E' or ch=='I' or ch == 'O' or ch == 'U':

print("it is a vowel")

else:

print("it is a consonant")

v = [ 'A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u']

if ch in v:

print("vowel")

else :

print("not a vowel")

import math

a = (float)(input("enter value for a"))

b = (float)(input("enter value for b"))

c = (float)(input("enter value for c"))

d=b*b-4*a*c

if d > 0:

r1 = (-b + [Link](d))/2*a

r2 = (-b - [Link](d))/2*a

print("root1 = ", r1)

print("root2 = ", r2)

elif d==0:

r1 = r2 = - b/2*a

print("root1= ", r1)

print("root2= ", r2)

else:

print("imaginary roots")
#mtable

num=(int)(input("enter any number"))

for h in range(1, 11):

print(num,'X',h,'=',num*h)

#factorial

num=(int)(input("enter any number"))

fact = 1

for h in range(1, 11):

fact = fact*h

print("the factorial is ", fact)

#sum of 1 to 100

sum = 0

for h in range(1, 11):

sum = sum + h

print("sum from 1 to 100 is ", sum)

#calculator

x = (int)(input("enter any number"))

y = (int)(input("enter another"))

ch=input("enter your choice + - * or /")

if ch=='+':

print(x ,'+', y, 'is', x+y)

elif ch=='-':

print(x ,'-', y, 'is', x-y)

elif ch=='*':

print(x ,'*', y, 'is', x*y)

elif ch=='/':

print(x ,'/', y, 'is', x/y)

else:

print("invalid choice")
#greatest of 3 numbers

a = (int)(input("enter any number"))

b = (int)(input("enter another number"))

c = (int)(input("enter anothet number"))

if a >=b and a>=c:

print(a ,"is greatest")

elif b >=a and b>=c:

print(b, "is greatest")

else:

print(c , "is greatest")

You might also like