“Python Switch Case 3.10” Kod odpowiedzi

Python Switch Case 3.10

grade = 92
category = grade//10  # Well above average grade
match category:
	case 10:
		print("Excellent")
	case 9:
		print("Well above average")
	case 8:
		print("Above average")
	case 7:
		print("Average")
	case 6:
		print("Below average")
	case _:
		print("Not passing")
Wissam

przełącznik Python 3.10

def my_function(status):
    match status:
        case 400:
            return "Bad request"
        case 404:
            return "Not found"
        case 418:
            return "I'm a teapot"
        case _:
            return "Something's wrong with the internet"

# No need of break after case
Frustrated Developer

Odpowiedzi podobne do “Python Switch Case 3.10”

Pytania podobne do “Python Switch Case 3.10”

Więcej pokrewnych odpowiedzi na “Python Switch Case 3.10” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu