Match Case Statements in Python | Python Tutorial - Day #16
Python is one of the most demanded programming languages in the job market. Surprisingly, it is equally easy to learn and master Python. This python tutorial for absolute beginners in Hindi series will focus on teaching you python concepts from the ground up.
Access the Playlist: • Python for Beginners (...
Link to the Repl: replit.com/@codewithharry/16-...
Join Replit the browser-based IDE used in this course - join.replit.com/code-with-har...
►Checkout my English channel here: / @programmingwithharry
►Instagram: codewithharry
python, C, C++, Java, JavaScript and Other Cheetsheets [++]:
Playlist: • Coding CheatSheets 🧾 b...
►Learn in One Video[++]:
Python[15 Hr]: • Python Tutorial For Be...
Python Advance[3.5 Hr]: • Python Programming Cou...
Python[1 Hr]: • Learn Python In Hindi ...
Python[2 Hr]: • Python Tutorial In Hin...
Python[15 Min]: • 15 Minute Python Tutor...
JavaScript[1 Hr]: • JavaScript Tutorial
C[1.3 Hr]- • C Programming Tutorial...
php[1 Hr]: • Learn Php In One Video...
php[2.3 Hr]: • Php Tutorial for Begin...
php[Project]- • Login And Registration...
HTML[30 Min]: • HTML 5 Tutorial For Be...
CSS[8.5 Hr]: • CSS Tutorial In Hindi ...
CSS[1.4 Hr]: • CSS 3 Tutorial For Beg...
Wordpress[3.2 Hr]: • How To Make a WordPres...
Angular[2 Hr]: • Angular Tutorial in Hindi
Java[2.3 Hr]: • Java tutorial in hindi 🔥
Web Scraping[1 Hr]: • Web Scraping Tutorial ...
MongoDB[2 Hr]: • MongoDb Tutorial For B...
Numpy[1 Hr]: • Numpy Tutorial in Hindi
Android Dev[12 Hr]- • Android Development Tu...
Linux[1 Hr]: • Linux Tutorial For Beg...
JQuery[1.1 Hr]: • jQuery Tutorial For Be...
Git and GitHub[1.1 Hr]: • Git & GitHub Tutorial ...
►Complete course [playlist]:
React: • React Js Tutorials in ...
Python- • Python Tutorials For A...
OOP Python- • Object Oriented Progra...
Java: • Java Tutorials For Beg...
JavaScript- • JavaScript Tutorials I...
PHP- • PHP Tutorials in Hindi
C- • C Language Tutorials I...
C++- • C++ Tutorials In Hindi
Git & GitHub- • Git and GitHub Tutoria...
Android Dev- • Android Development Tu...
Python GUI- • Python GUI: Tkinter Tu...
Web Development- • Web Development Tutori...
Python Django: • Python Django Tutorial...
Projects Using HTML, CSS & Javascript- • Projects Using HTML, C...
Data Structure and Algo: • Data Structures and Al...
Follow Me On Social Media
►Website (created using Django Rest & Angular): www.codewithharry.com
►Facebook: / codewithharry
►Instagram: / codewithharry
Twitter: / codewithharry
Comment "#HarryBhai" if you read this 😉😉
Пікірлер: 885
Did you access the playlist?
@wecretion3504
Жыл бұрын
yep😁
@OneMinExplains
Жыл бұрын
Hji
@geetesh4542
Жыл бұрын
Yes 👍
@monxtaebi6309
Жыл бұрын
Bhai ap ek br khud check kri day 13 ki bud koe b replit available nhe ha check out kya issue ha?
@yesican_iwill5090
Жыл бұрын
Yess
Code Backup Repository: github.com/CodeWithHarry/100-days-of-code-youtube
@kamranamin2812
6 ай бұрын
sir ye replit 3.10 version show hi nahi kar raha ha can u guide please
Bhai mera ek simple request hai. At the end of every new session give us some questions based on what we have learned so far.
@itsatvick___2655
Жыл бұрын
Practise Set will come very soon 👍
@uyentertain2320
Жыл бұрын
Yes
@tejaskamat4528
Жыл бұрын
exactly youre right
@sujithnair9089
Жыл бұрын
@CodeWithHarry
@mujtabahussin6369
Жыл бұрын
i made this please try it import random a1 = int(input("From where to: ")) a2 = int(input("Where: ")) d = random.randint(a1, a2) def randomc(): # print(d) #can know what is the answer a = int(input("What is the value for Random?: ")) if a > d: print("Its bigger") e + 1 randomc() elif a print("Its Smaller") e + 1 randomc() else: print("YOU WON!! ") randomc()
@CodeWithHarry I think if/else statements and Match case statements are totally same because I made a simple calculator using both but found Match case to be more convenient to use.. # Using Match Case Statements ''' Simple Calculator ''' input1 = int(input("Enter first no. : ")) input2 = int(input("Enter second no. :")) op = input("Enter operator (+, - , *, /) : ") match op: case '+': print(input1+input2) case '-': print(input1+input2) case '*': print(input1*input2) case '/': if input2 == 0: print("Number cannot be divide by 0") else: print(input1/input2) # Using If/Else Statements int1 = int(input("Enter first no. : ")) int2 = int(input("Enter second no. :")) op1 = input("Enter operator (+, - , *, /) : ") if op1 == '+': print(int1+int2) elif op1 == '-': print(int1-int2) elif op1 == '*': print(int1*int2) elif op1 == '/': if int2 == 0: print("Number cannot be divide by 0") else: print(int1/int2) else: print("No other operators are allowed")
@Pythongirl_
9 ай бұрын
nice thanks for the code.
@iamtpk03
6 ай бұрын
op..good one
@Shortsfortheday21
2 ай бұрын
good observation you are right, but the difference between if else statements and match statements would be that it doesnt stop the script once criteria is met ie in if else statement all the criterias are checked and the correct one is ru, but in match case once the criteria is met the other stements are not run
@shahbaznoor8718
2 ай бұрын
@@Shortsfortheday21 they both run in same manner you can check it. Python runs according to the sequence of line, in both case (ie if-else and match case) once the condition is met, it break the script and shows the output. And completely ignores the condition present below them, even if those conditions are also true. Additionally, match-case can only be used to compared a single variable or object, whereas if-else condition can be used to compared multiple variables or objects at once, as far as I have understood. Correct me if I'm wrong. Cheers ✌️
@nabilsarwar
Ай бұрын
how to show else: print("invalid operator") in match case statement method
Such a Hardworking Mentor in coding courses in KZread ever...Respect Sir❤
anyone from 2024?
@Famoustvfaces
3 ай бұрын
Yes but can we get the job ?
@That_Deen_Dude
3 ай бұрын
@@Famoustvfaces yeahh, same!
@Yuvro_edits-vn6lk
3 ай бұрын
Same
@ishwarparihar3908
3 ай бұрын
Yes
@siddhurrr2422
3 ай бұрын
Yes
match case is available from python 3.10 onwards. _ is used for default. break is not required in python. case default can also have if statements. Syntax match (original argument) case condition: case _:
No one is like mr. harry. I have recently seen one of the youtube channel charging aroun 7K for 45days of python training. but here harry bhai giving 100days of trainning for free. some people are so stupid they are ready to pay for only 45days for code in python. harry bhai you're awesome. that is the reason this channel growth rate is so high as compare to other youtube channel. and harry bhai teaching style is fire. thank you for bringing awesome course harry bhai. after this soon please bring some cloud technology like DevOps tools. thank you so much. that youtube channel name is #WsCube Tech which has half subscriber than this. please dont be fool guy. get good and awesome content with codewithharry. thank you.
@AnuragMishra-ob1er
Ай бұрын
"Don't compare any KZread channel, bro. Everyone has their own perspective."
Day 4 of #100DaysOfCode. Today in this video 16, I learned about match case statements in Python, which provide switch-case-like functionality. I discovered how to compare a variable's value to different patterns using the match keyword, case clauses, and expressions. This will enable me to create more efficient and readable code when handling multiple conditions or patterns. Thank You Harry Bhaiya.
@KaushikNyaykare
Жыл бұрын
what a coincidence , even i am in my day 4 and 16th video is going on i guess u are also following 4 videos per day schedule like me right?
@himanshujain8068
5 ай бұрын
@@KaushikNyaykareme to day 4 vid 16 but
a = int(input("Enter a Valid Month Number: ")) match a: case 1: print("January") case 2: print("February") case 3: print("March") case 4: print("April") case 5: print("May") case 6: print("June") case 7: print("July") case 8: print("August") case 9: print("September") case 10: print("Octuber") case 11: print("November") case 12: print("December") case _: print("Please Enter a Valid Month Number")
@sparkcodez
Жыл бұрын
noice
@bhagwatipatel2266
Жыл бұрын
Please tell me how I could do it explain me do u use instagram ?
@AjaySharma-dd2nc
Жыл бұрын
Nice explanation brother , Thank you
@AjaySharma-dd2nc
Жыл бұрын
I copy your code in my python notebook
@Motivation1234j
Жыл бұрын
@@bhagwatipatel2266 it's easy, these are just like if else statements
Following this series and learing python from scratch
Thank you for free course ❤️🙏
a = int(input("Enter the first number: ")) b = int(input("Enter the Second number: ")) x = int(input("""1. Enter 1 for add 2. Enter 2 for Sub 3. Enter 3 for Div 4. Enter 4 for Mul """)) match x: case 1: c = a + b print ("Add is: ", c) case 2: c = a - b print ("Sub is: ", c) case 3: c = a / b print ("Div is: ", c) case 4: c = a * b print ("Mul is: ", c) case _: print("Enter the correct option")
@Im_entertainer
Ай бұрын
Your code is wrong
@amitkhare610
Ай бұрын
@@Im_entertainer No, it's correct, how it's wrong
@Im_entertainer
Ай бұрын
@@amitkhare610 coz it's not working I guess mne try kia ye code but output hi nh aa rha
@amitkhare610
Ай бұрын
@@Im_entertainer kaise try Kiya?
@amitkhare610
Ай бұрын
@@Im_entertainer kaise try kiya
App hamre liye bahut mehanat kar rahe ho harry bhai apko dil ❤se thanku mene coding ki duniya me apki ungali pakad kar kadam rakha he thanku so much
This course is awesome 🔥🔥
Thnx harry bhai for this wonderful content
PRESENT HARRY SIR!! #DAY16 DONE. THANK YOU. :)
My semester exam has scheduled in the first week of january... But i'm addicted to your's tutorial. So i can't delay to watch your any video.
@sandygaming4013
Жыл бұрын
From which university you are
@StreamingLivehere
Жыл бұрын
@@sandygaming4013 JUT
@shazam1334
Жыл бұрын
first year?
@StreamingLivehere
Жыл бұрын
@@shazam1334 3rd
@shazam1334
Жыл бұрын
@@StreamingLivehere 2 nd yr here bro...i thought python was only in first year
thank harry bhaiya. now day 16 also completed.😊😊
Hi harry sir, You're really appreciated you're doing good work but literally tell us about ChatGPT also...
Harry bhaiya ap to hero bangeye... Ginus bro.... Boom 💥
course is going nice and smooth. thanks #HarryBhai
Excellent! Need more like this.😊😊
@JohnFrost-gt1cs
Жыл бұрын
can you tell me what is the difference between match case statement and if statement?
Day 14, maine printing the days by their number try kiya and that worked!
thanks bro i have learnt many things in just 16 days
print("\tWelcome to the Voting") x = int(input("Do you want to vote? Enter 0 for Yes and 1 for No:")) match x: case 0: print("You want to vote!") age = int(input("Enter your age: ")) if (age >= 18): print("You can vote.") name = int(input("Whom do you want to vote: 1. John 2.Adam 3.Ash ")) if (name == 1): print("Your vote is registered for John!") elif (name == 2): print("Your vote is registered for Adam!") elif (name == 3): print("Your name is registered for Ash!") else: print("Invalid Entry! Try Again.") else: print("You cannot vote as your age is below 18.") case 1: print("As you wish")
@iwbmb3313
6 ай бұрын
when it asks that whom do you want to vote 1.john 2.adam 3.ash then if i write a string it crashes means invalid Entry ! Try again doesn't works!!!
@iwbmb3313
6 ай бұрын
it happens everytime when I insert srt instead of int? so fix it . I have an hint that you can use "try" .
Hi Harry Bhai, I love your courses and I learnt python from your channel. Currently I am learning react from you but I want to polish my python skills also with this 100 days channels. So should I continue it or will I go crazy if I put my mind in two different languages?
@tejaskamat4528
Жыл бұрын
You can just watch the videos to regain the concepts which you have been forgotten. And AFAIK it won't affect your mind. I'm doing the same thing. HTML + PYTHON together. Though I've learnt python from the olden course of harry bhai. I hope this helps you kudos
Harry bhai course bahut achhi hai or ye course karne me v achaa lag raha hai But aap theroy v saath me de dete to note v ban jata Harry bhai 👍
We love Sir's Style....😎😎
in c switch case exisits and we can just use if case one after another in a line it will also work
good evening, daily following 100days of code, bahot maja aa raha hai sir
Completed Day #16 😍
an example from my side,hope this will help also: a=int(input("enter the marks:")) match a: case _ if a>=0 and a=35 and a=50 and a=60 and a=70 and a=80 and a=90 and a
@vedanlkektokekto6872
8 ай бұрын
could have just written case 100 no
@user-yj1qo8ln4q
3 ай бұрын
AMAZING SIR
@user-ul3ms1og2f
3 ай бұрын
at this point it just better to use if and else, no point of match, case
Thank You Harry bhai 🌹💛
This is synonymous with the switch case statements of java programming language.
Sir please a full tutorial about (SEO) with notes
Thank you ❤️🙂
Thank you so much brother❤
finally caught up👍👍👍
Hi Harry, So May I know what is the key difference between If-Else & Match-Case pls?
# * match case is basically switch case you'd know if you come from different coding language age = int(input("Enter your age: ")) match age: case _ if age print("Not Legal to drive") case _ if age >= 18 and age print("Legal to drive") case _ if age >= 60 and age print("Legal to drive, but be cautious") case _ if age >= 80: print("Illegal to drive")
Today's class is very wow ❤️❤️ because Harry Bhai is wow 6 😀
Pranam bhrata 🙏 apka bahutt baht dhanyawad 😄🧡😇🙏
NIce Harry Sir!
# Match case of python print('USE 1 FOR "YES" AND 2 FOR "NO"') print("Do You Want To Cast Your Vote ?") x = int(input()) match x: case 1: print("So you want to cast your vote") y = int(input("Enter your age : ")) if(y>=18): print("You are eligible to vote") else: print("You are under age you can not cast your vote") case 2: print("As your wish")
@_itz.ricky._
Жыл бұрын
We can do make same script only with if else statement and also match function required if else. Then why use Match function?
@mujtabahussin6369
Жыл бұрын
i made this please try it import random a1 = int(input("From where to: ")) a2 = int(input("Where: ")) d = random.randint(a1, a2) def randomc(): # print(d) #can know what is the answer a = int(input("What is the value for Random?: ")) if a > d: print("Its bigger") e + 1 randomc() elif a print("Its Smaller") e + 1 randomc() else: print("YOU WON!! ") randomc()
@its.me.archit
Жыл бұрын
@@_itz.ricky._ yeah , I have the same doubt.... have you got the answer till now?? its been 3 months
Sir matchcase aur if else mein kya pharak kyuki same hee lg rhe hai dono
Op video Harry bhai
Then what is the difference between if-else and match case statements?
Playlist accessed Harry bhaiya
agar humko saare cases check karne like in c++, toh koi function hain or c++ main hi karna padega??
Can we use string in place of 0,1,2 to match string in variable
Bhaia is there any difference between 'if else ' statements and 'match case' statements?
harry bhai it is just like a if-else statement.
Nice harry bhai😍
sir, I got an error of expected an indented block after 'match' and I did in 3.10.0 python version
LOVE YOU HARRY BHAI❤
Present Harry bhaiya 🙂
Harry bro I have a request that please guide me which one is best for backend development javascript or php if javascript is good so will php be die in next couple of years?
Harry Bhai please also make a video on GSOC 2023 ( Google summer of code ) as it is coming soon and it's a good initiative to take participation , I am new to it please guide harry bhai
love your videos
THANKS, BHAI 🙏
you are great sir
MOJ KARDI HARRY BHAI MOJ
Hello sir, I was trying this program in Jupyter.. But that throws invalid syntax.. Now what to do
Thanks
Present harry bhaiya #codewithharry
Practice exercise for match Statement: 1 : Image File type classifier ( HINT: Enter the full path of the image and use match statement to find out the file type i.e .png, .jpg, etc)
@zuhaaismail1689
11 ай бұрын
file = input("Enter image full path: ") filetype = file.split(".") filetype = filetype[-1].lower() match filetype: case _ if filetype == 'jpg' or filetype == 'jpeg': print("This image is a JPEG image.") case _ if filetype == 'png': print("This image is a PNG image.") case _ if filetype == 'gif': print("This image is a GIF image.") case _ if filetype == 'tif' or filetype == 'tiff': print("This image is a TIFF image.") case _ if filetype == 'bmp': print("This image is a Bitmap image.") case _ if filetype == 'webp': print("This image is a WebP image.") case _: print("Unknown image type.") Kindly tell me is it good? By the way it is working fine
@FaceSenseAustralia
11 ай бұрын
Hi @@zuhaaismail1689 , Amazing😀, you can also make this as a function to make the code more affective. def fileExtension(): file = input("Enter image full path: ") filetype = file.split(".") filetype = filetype[-1].lower() match filetype: case _ if filetype == 'jpg' or filetype == 'jpeg': print("This image is a JPEG image.") case _ if filetype == 'png': print("This image is a PNG image.") case _ if filetype == 'gif': print("This image is a GIF image.") case _ if filetype == 'tif' or filetype == 'tiff': print("This image is a TIFF image.") case _ if filetype == 'bmp': print("This image is a Bitmap image.") case _ if filetype == 'webp': print("This image is a WebP image.") case _: print("Unknown image type.")
@junior._.4697
9 ай бұрын
@@zuhaaismail1689 till now he didn't told us this much to do a complex program like this😢
@junior._.4697
9 ай бұрын
@@zuhaaismail1689 but after analysing your program i gotta know about this very much...thanks bro 👍🏿
This video is helpfull
Thanks sir.
i have downloaded python 3.11 version but on replit it is saying that i'm having python 3.8 version how can i change it to python 3.10 or 3.11
HY! Harry bhai plz guide me about assignment 2 . mugh sa wo nhn bni......agr time stamp main A.M and P.M dana ho to kaya karin ga?? or sath specific time hour bhi dena ho to what i do??
Agar default case me if-else use kre to uski runtime complexity kya hogi ??
The question is why shouldn't we use if/else instead of matchcase like whats the reason of this new function.
Hello Harry sir, Video me jo harry sir tutoriyal use karte h side wo kaise milega plz tell me any one 🙏
a = int(input("enter a number")) mul = 1 match a: case _ if a 10: print("cant funtion") guys is this how u do it, if i do it without loops do i have to right all of the table together or is there any other way please help
bhai iam 15 years old i have study the c and c++ this was my third language python keep doing please make a video on python turtle
Love u harry bhai
Why we use this Match Case when we have If / ifelse function to use ? please someone reply who knows the answer
python 3.10 not showing in my repls templates
love it
Hlo harry bhaiya, can you please clear that when to use if else and when to use match case or what is the main difference between them.
I have a question, we can do the same things with if else elif command, then y we will use match case ? Like what is the need to use this above of elif statement?? Can someone please tell me.
Another example for understanding match case str = input("Which season of Anime do you want to watch ?") match str: case _ if (str=="Spring"): anime = int(input("Which anime to select: 1.Toradora 2.Noragami 3.Pokemon ")) match anime: case _ if ( anime == 1): print("Toradora is Currently playing") case _ if ( anime ==2 ): print("Noragami is Currently playing") case _ if (anime == 3): print("Pokemon is Currently playing") case _ if (str == "Winter"): anime2 = int(input("Which anime to select: 1.Barakamon 2.Vinland Saga 3.ReZero ")) match anime2: case _ if (anime2 == 1): print("Barakamon is Currently playing") case _ if (anime2 == 2): print("Vinland Saga is Currently playing") case _ if (anime2 == 3): print("ReZero is Currently playing") case _ if (str == "Summer"): anime3 = int(input("Which anime to select: 1.Attack on Titan 2.ReLife 3.Mushoku Tensei ")) match anime3: case _ if (anime3 == 1): print("Attack on Titan is Currently playing") case _ if (anime3 == 2): print("ReLife is Currently playing") case _ if (anime3 == 3): print("Mushoku Tensei is Currently playing")
Thanks Harry
sir, use visual studio. I can not understand when you use that website. I would be thankful for you.
Same chiz ham if else statement se bhi kar sakte hai toh difference kya hai ?
harry bhai ap kaha se knowledge gain karte ho. itna perfect hota hai
bhaiya bas ek doubt hai ki if-else statement ko match case statement ke sath ek hi variable ke liye kaise use karenge
Harry bhai, i have a question: What is the benefits of using "match case" statements instead of "if else statement". Harry vai please clearlify this..
@arpankarmakar16
Жыл бұрын
I am also new to this concept, Its functionality is similar to that of if-else but there is no advantage I guess
@singduniyaOfficial
Жыл бұрын
I am just waiting for harry vai's relply. We should not assume that thing before the reply
@drout526
Жыл бұрын
There is a small difference. In the match case statements, the programmer knows the input of the user. In the case of if else, nothing of that sort is known.
@arpankarmakar16
Жыл бұрын
@@drout526 Thanks
@sayamvatsa6113
Жыл бұрын
@@drout526 nhi yar aisa kuch nhi h.. if-else m b pata hota response. Tabi to isme m if else ki tarah end m ek else ka equivalent h ..
we can do this by if else statement
If else aur match case statement me kya difference hai?
bhaiya 1 issue aa raha h match case work nhi kar raha in version 2023
sir ap ne coding konse channel se sekhe
can i use case else and case elif in the code after case if
To Harry bhai ab if/else ka use better hai ya fir match/case ka
Vs code me update virsion download karne per bhi match case run nahi kar raha hai abhi error newer version ki bata raha h?
Bhai can you let me know when we upload image through Contact Form7 in wordpress and same image should be seen in another page . How it can be done. I have check all ur wordpress tutorial but not mention . Please teach how it is possible.
PRESENT BRO!
present Harry Bhai
Day 16 complete ✅