Match case or switch case in Python

0

 Match case or switch case in Python:-



It  is  used to solve option based or choice based program. it is similar to ladder if--else.


ch='i'

match ch:

 case 'a':

    print('vowel')

 case 'e':

    print('vowel')

 case 'i':

    print('vowel')

 case 'o':

    print('vowel')

 case 'u':

    print('vowel')

 case _:

    print('consonent')


var=value

match option:

    case optionvalue:

       statement

    ...

    ...

    case _:

      default statement



option==optionvalue


1)  WAP to check number is one digit or above one digit?


2)  WAP to check character is numeric or alphabet?


3)  WAP to check that char is in upper case or lower case?


4)  WAP to check Leap Year


5)  WAP to check greater number


6)  WAP to calculation addition, substration, multiplication and division when user press '+','-','*','/' and '%'


7) WAP to manage login operation?


8) Create horoscope 



Tags

إرسال تعليق

0تعليقات

POST Answer of Questions and ASK to Doubt

إرسال تعليق (0)