filmov
tv
[Python Programming Basics to Advanced]: if and if else statements (Decision Making) | Lab 05 P-2
Показать описание
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 this lesson we will use the relational operators and logical operators with if and if else statement. If and if else statements are used for decision making in programming logic.
Complete Playlist:
If you have the basic programming knowledge and interested to learn Object-Oriented Programming in Python, check out this playlist:
Lab Manual 05 can be downloaded from here:
Review Questions:
1- Write a program that will display the roots of a quadratic equation. User will enter the values of a, b and c and the program will display the roots. The value of co-efficient *a* cannot be 0 for a quadratic equation. You will assume that the user will always enter non-zero value of co-efficient *a*.
After taking input from user, find the discriminant. Then apply the IF statement on that discriminant being positive or negative since we have to find the square root of that. Use the approach similar to the square root example shown in the video.
2-The Chinese zodiac assigns animals to years in a 12 year cycle. One such cycle is as:
2000 Dragon
2001 Snake
2002 Horse
2003 Sheep
2004 Monkey
2005 Rooster
2006 Dog
2007 Pig
2008 Rat
2009 Ox
2010 Tiger
2011 Hare
The pattern repeats from there, with 2012 being another year of the dragon, and 1999 being another year of the hare.
Write a program that reads a year from the user and displays the animal associated with that year. Your program should work correctly for any year.
You should take the year input, assuming that it is positive integer, do the required calculations and then use 12 IF statements to display the associated Animal.
#PythonProgramming #python #pythontutorial
In this lesson we will use the relational operators and logical operators with if and if else statement. If and if else statements are used for decision making in programming logic.
Complete Playlist:
If you have the basic programming knowledge and interested to learn Object-Oriented Programming in Python, check out this playlist:
Lab Manual 05 can be downloaded from here:
Review Questions:
1- Write a program that will display the roots of a quadratic equation. User will enter the values of a, b and c and the program will display the roots. The value of co-efficient *a* cannot be 0 for a quadratic equation. You will assume that the user will always enter non-zero value of co-efficient *a*.
After taking input from user, find the discriminant. Then apply the IF statement on that discriminant being positive or negative since we have to find the square root of that. Use the approach similar to the square root example shown in the video.
2-The Chinese zodiac assigns animals to years in a 12 year cycle. One such cycle is as:
2000 Dragon
2001 Snake
2002 Horse
2003 Sheep
2004 Monkey
2005 Rooster
2006 Dog
2007 Pig
2008 Rat
2009 Ox
2010 Tiger
2011 Hare
The pattern repeats from there, with 2012 being another year of the dragon, and 1999 being another year of the hare.
Write a program that reads a year from the user and displays the animal associated with that year. Your program should work correctly for any year.
You should take the year input, assuming that it is positive integer, do the required calculations and then use 12 IF statements to display the associated Animal.
#PythonProgramming #python #pythontutorial
Комментарии