filmov
tv
[Python Programming Basics to Advanced] : Nested if-else statement | Lab 06 P-1

Показать описание
This Python programming playlist is designed to take beginners with zero programming experience to an expert level. The course covers installation, basic syntax, practical scenarios, and efficient logic building. The course material includes PDF handouts, review questions, and covers a wide range of topics, from data types to advanced functions like Lambda and Recursive functions, Generators, and JSON data parsing.
In last lesson we studied about if and if-else statements. In this lesson we will study about Nested if-else statement in Python. Nested if-else means an if statement inside another if or else statement.
Complete Playlist:
If you have the basic programming knowledge and interested to learn Object-Oriented Programming in Python, check out this playlist:
Lab Manual 06 can be downloaded from here:
Review Questions:
1- Here is another version of the insurance problem:
s=input('Are you married? (m/u):')
g=input('Your gender? (m/f):')
a=int(input('Your age? :'))
if(s=='m'):
print('Eligible')
else:
if(g=='m' and a>30):
print('Eligible')
else:
print('Not Eligible')
if(g=='f' and a >25):
print('Eligible')
else:
print('Not Eligible')
When I gave these inputs: unmarried, male and 27, the output was "Not Eligible" but printed twice.
Use the debugging tool and identify the reason for 2-times display.
2- Write a program that asks the user to enter his or her month and day of birth (as in the last task discussed in video). Then your program should print the user’s zodiac sign as part of an appropriate output message. The detail of zodiac sign is as under:
Capricorn December 22 to January 19
Aquarius January 20 to February 18
Pisces February 19 to March 20
Aries March 21 to April 19
Taurus April 20 to May 20
Gemini May 21 to June 20
Cancer June 21 to July 22
Leo July 23 to August 22
Virgo August 23 to September 22
Libra September 23 to October 22
Scorpio October 23 to November 21
Sagittarius November 22 to December 21
#PythonProgramming #python #pythontutorial
In last lesson we studied about if and if-else statements. In this lesson we will study about Nested if-else statement in Python. Nested if-else means an if statement inside another if or else statement.
Complete Playlist:
If you have the basic programming knowledge and interested to learn Object-Oriented Programming in Python, check out this playlist:
Lab Manual 06 can be downloaded from here:
Review Questions:
1- Here is another version of the insurance problem:
s=input('Are you married? (m/u):')
g=input('Your gender? (m/f):')
a=int(input('Your age? :'))
if(s=='m'):
print('Eligible')
else:
if(g=='m' and a>30):
print('Eligible')
else:
print('Not Eligible')
if(g=='f' and a >25):
print('Eligible')
else:
print('Not Eligible')
When I gave these inputs: unmarried, male and 27, the output was "Not Eligible" but printed twice.
Use the debugging tool and identify the reason for 2-times display.
2- Write a program that asks the user to enter his or her month and day of birth (as in the last task discussed in video). Then your program should print the user’s zodiac sign as part of an appropriate output message. The detail of zodiac sign is as under:
Capricorn December 22 to January 19
Aquarius January 20 to February 18
Pisces February 19 to March 20
Aries March 21 to April 19
Taurus April 20 to May 20
Gemini May 21 to June 20
Cancer June 21 to July 22
Leo July 23 to August 22
Virgo August 23 to September 22
Libra September 23 to October 22
Scorpio October 23 to November 21
Sagittarius November 22 to December 21
#PythonProgramming #python #pythontutorial
Комментарии