According to Data Science Topic-12 If else program examples

 # email- abhayprasad.36480@gmail.com

# password-1234


email = input('Enter your email: ')

password = input('Enter your password: ')


if email == 'abhayprasad.36480@gmail.com' and password == '1234':

  print('Welcome')

elif email == 'abhayprasad.36480@gmail.com' and password != '1234':

  # tell the user

  print('Incorrect password')

  password = input('enter password again')

  if password == '1234':

    print('Welcome,finally!')

  else:

    print('beta tumse na ho payega!')

else:

  print('Not correct')


Result: Enter your email: abcd

Enter your password: 7689

Not correct


Enter your email: abhayprasad.36480@gmail.com

Enter your password: 1234

Welcome

Enter your email: abhayprasad.36480@gmail.com
Enter your password: 4567
Incorrect password
enter password again9000
beta tumse na ho payega!

Enter your email: abhayprasad.36480@gmail.com
Enter your password: 4567
Incorrect password
enter password again1234
Welcome, finally!

# min of 3 number

a = int(input('first num'))
b = int(input('second num'))
c = int(input('third num'))

if a<b and a<c:
  print('smallest is',a)
elif b<c:
  print('smallest is',b)
else:
  print('smallest is',c)

Result: first num4

second num1

third num10

smallest is 1

# menu driven calculator

fnum = int(input('enter the 1st number'))

snum = int(input('enter the 2nd number'))


op = input('Enter the operation')


if op == '+':

  print(fnum+ snum)

elif op == '-':

  print(fnum-snum)

elif op== '*':

  print(fnum*snum)

else:

  print(fnum/snum)

Result: enter the 1st number45

enter the 2nd number34

Enter the operation+

79

enter the 1st number67

enter the 2nd number56

Enter the operation

1.1964285714285714

#  menu driven calculator

menu = input("""

Hi!How can i help you.

1. Enter 1 for pin check

2. Enter 2 for balance check

3. Enter 3 for withdrawal

4. Enter 4 for exit

""")


if menu== '1':

  print('pin change')

elif menu== '2':

  print('balance check')

elif menu== '3':

  print('withdrawal')

else:

  print('exit')

Result: Hi! How can i help you.

1. Enter 1 for pin check

2. Enter 2 for balance check

3. Enter 3 for withdrawal

4. Enter 4 for exit

3

withdrawal

  










Comments

Popular posts from this blog

According to Data Science Topic-13 Modules

Functions in Python: