Skip to content

Latest commit

 

History

History
32 lines (28 loc) · 1.46 KB

File metadata and controls

32 lines (28 loc) · 1.46 KB

If-else statements

Write a Python program to

  • Check if a number is positive/negative even/odd or zero E.g a = -5, Negative & Odd, a = 6 -> Positive & Even
  • Grade classification based on percentage. Get input scores from user and determine grade based on following logic -> S > 90, A > 80, B > 70, C > 50, F < 50
  • Check if a year is a leap year and if the month has 28/29, 30 or 31 days and the given day is valid
  • Check if a character is a vowel, consonant, or special character
  • Determine the season based on the month. Get month and show the season - Jan-Mar -> Spring, Apr-June -> Summer, July-Sept -> Autumn, Oct-Dec -> Winter

Errors and Exceptions

Write a Python program for

  • Handling division by zero error
  • Handling invalid input error
  • Handling index out of range error
  • Handling a ValueError when converting user inputs an integer
  • Handling multiple potential errors

Functions

Write a Python program using function

  • to find the maximum of three numbers
  • to calculate the factorial of a number

Functions with arugments

Write a Python program using function

  • To concatenate strings with dynamic arguments
  • To count the number of arguments passed
  • To format a person's name using keyword arguments. E.g. first name is John, last name is Smith, Ans -> John Smith
  • To create a dictionary using keyword arguments
  • To create a tuple using variable arguments
  • To concatenate strings with variable length arguments
  • To illustrate default arguments