Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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")
Comment

switch case 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
Comment

PREVIOUS NEXT
Code Example
Python :: extract images from pdf 
Python :: python collections to dictionary 
Python :: django query filter greater than or equal to 
Python :: python split range into n groups 
Python :: how to exit a loop in python 
Python :: Count Zero 
Python :: python vector class 
Python :: python import as 
Python :: pytest create server 
Python :: change a decimal to time in datetime python 
Python :: get table wikipedia 
Python :: Proj 4.9.0 must be installed. 
Python :: syntax of calloc 
Python :: assert with message python 
Python :: python how to make boxplots with jitter 
Python :: sorted string 
Python :: how to use for in python 
Python :: python add columns to dataframe without changing the original 
Python :: python convert string to float 
Python :: local time in python 
Python :: from random input python 
Python :: guessing game python 
Python :: python string: .format() 
Python :: created by and updated by in django 
Python :: adding numbers in python 
Python :: swap two lists without using third variable python 
Python :: matlab .* operator in python 
Python :: Python operator to use for set union 
Python :: pandas get rows which are NOT in other dataframe 
Python :: pyqt5 hide button 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =