File tree Expand file tree Collapse file tree 2 files changed +50
-7
lines changed
Expand file tree Collapse file tree 2 files changed +50
-7
lines changed Original file line number Diff line number Diff line change 6161 ],
6262 "metadata" : {
6363 "kernelspec" : {
64- "display_name" : " oop " ,
64+ "display_name" : " Python 3 (ipykernel) " ,
6565 "language" : " python" ,
6666 "name" : " python3"
6767 },
7575 "name" : " python" ,
7676 "nbconvert_exporter" : " python" ,
7777 "pygments_lexer" : " ipython3" ,
78- "version" : " 3.10.9 "
78+ "version" : " 3.12.11 "
7979 }
8080 },
8181 "nbformat" : 4 ,
Original file line number Diff line number Diff line change 196196 "metadata" : {},
197197 "outputs" : [
198198 {
199- "name" : " stdin " ,
199+ "name" : " stdout " ,
200200 "output_type" : " stream" ,
201201 "text" : [
202202 " John Smith\n "
516516 "metadata" : {},
517517 "outputs" : [
518518 {
519- "name" : " stdin " ,
519+ "name" : " stdout " ,
520520 "output_type" : " stream" ,
521521 "text" : [
522522 " Enter an integer: 10\n "
540540 " print(f'{num} is odd.')"
541541 ]
542542 },
543+ {
544+ "cell_type" : " markdown" ,
545+ "id" : " 71fb3cdd-7cb7-47bd-9698-2be3e1a0acda" ,
546+ "metadata" : {},
547+ "source" : [
548+ " ## Match statement\n " ,
549+ " \n " ,
550+ " - Python 3.10+ added switch like statement called math-case\n " ,
551+ " - match statement evaluates an expression and compares its value to successive patterns in the case blocks\n " ,
552+ " - the first pattern that matches is executed"
553+ ]
554+ },
555+ {
556+ "cell_type" : " code" ,
557+ "execution_count" : 1 ,
558+ "id" : " 61e75931" ,
559+ "metadata" : {},
560+ "outputs" : [
561+ {
562+ "name" : " stdin" ,
563+ "output_type" : " stream" ,
564+ "text" : [
565+ " Enter a character: a\n "
566+ ]
567+ },
568+ {
569+ "name" : " stdout" ,
570+ "output_type" : " stream" ,
571+ "text" : [
572+ " a is a vowel\n "
573+ ]
574+ }
575+ ],
576+ "source" : [
577+ " value: str = input(\" Enter a character: \" )\n " ,
578+ " \n " ,
579+ " match value:\n " ,
580+ " case 'a' | 'e' | 'i' | 'o' | 'u':\n " ,
581+ " print(f\" {value} is a vowel\" )\n " ,
582+ " case _:\n " ,
583+ " print(f\" {value} is a consonant\" )"
584+ ]
585+ },
543586 {
544587 "cell_type" : " markdown" ,
545588 "id" : " 3e0b561e" ,
586629 "metadata" : {},
587630 "outputs" : [
588631 {
589- "name" : " stdin " ,
632+ "name" : " stdout " ,
590633 "output_type" : " stream" ,
591634 "text" : [
592635 " Enter a number: 1\n "
600643 ]
601644 },
602645 {
603- "name" : " stdin " ,
646+ "name" : " stdout " ,
604647 "output_type" : " stream" ,
605648 "text" : [
606649 " Enter a number: 0\n "
16221665 "name" : " python" ,
16231666 "nbconvert_exporter" : " python" ,
16241667 "pygments_lexer" : " ipython3" ,
1625- "version" : " 3.12.2 "
1668+ "version" : " 3.12.11 "
16261669 }
16271670 },
16281671 "nbformat" : 4 ,
You can’t perform that action at this time.
0 commit comments