Skip to content

Commit 33dbf9e

Browse files
committed
Basics
1 parent b7f6b38 commit 33dbf9e

File tree

1 file changed

+340
-0
lines changed

1 file changed

+340
-0
lines changed

Diff for: 01.Python Basics.ipynb

+340
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,346 @@
634634
" return pi*r*r"
635635
]
636636
},
637+
{
638+
"cell_type": "code",
639+
"execution_count": 39,
640+
"metadata": {},
641+
"outputs": [
642+
{
643+
"name": "stdout",
644+
"output_type": "stream",
645+
"text": [
646+
"25\n"
647+
]
648+
}
649+
],
650+
"source": [
651+
"numcalls = 0\n",
652+
"def square(x):\n",
653+
" global numcalls\n",
654+
" numcalls = numcalls + 1\n",
655+
" return(x*x)\n",
656+
"print(square(5))"
657+
]
658+
},
659+
{
660+
"cell_type": "code",
661+
"execution_count": 41,
662+
"metadata": {},
663+
"outputs": [
664+
{
665+
"name": "stdout",
666+
"output_type": "stream",
667+
"text": [
668+
"1\n",
669+
"1\n"
670+
]
671+
}
672+
],
673+
"source": [
674+
"x = 1\n",
675+
"def f():\n",
676+
" return x\n",
677+
"print(x)\n",
678+
"print(f())"
679+
]
680+
},
681+
{
682+
"cell_type": "code",
683+
"execution_count": 42,
684+
"metadata": {},
685+
"outputs": [
686+
{
687+
"data": {
688+
"text/plain": [
689+
"7"
690+
]
691+
},
692+
"execution_count": 42,
693+
"metadata": {},
694+
"output_type": "execute_result"
695+
}
696+
],
697+
"source": [
698+
"max(1,2,3,4,5,6,7)"
699+
]
700+
},
701+
{
702+
"cell_type": "code",
703+
"execution_count": 43,
704+
"metadata": {},
705+
"outputs": [
706+
{
707+
"data": {
708+
"text/plain": [
709+
"1"
710+
]
711+
},
712+
"execution_count": 43,
713+
"metadata": {},
714+
"output_type": "execute_result"
715+
}
716+
],
717+
"source": [
718+
"min(1,2,3,4,5,6)"
719+
]
720+
},
721+
{
722+
"cell_type": "code",
723+
"execution_count": 44,
724+
"metadata": {},
725+
"outputs": [
726+
{
727+
"data": {
728+
"text/plain": [
729+
"11"
730+
]
731+
},
732+
"execution_count": 44,
733+
"metadata": {},
734+
"output_type": "execute_result"
735+
}
736+
],
737+
"source": [
738+
"len(\"hello world\")"
739+
]
740+
},
741+
{
742+
"cell_type": "code",
743+
"execution_count": 45,
744+
"metadata": {},
745+
"outputs": [
746+
{
747+
"data": {
748+
"text/plain": [
749+
"50"
750+
]
751+
},
752+
"execution_count": 45,
753+
"metadata": {},
754+
"output_type": "execute_result"
755+
}
756+
],
757+
"source": [
758+
"int(\"50\")"
759+
]
760+
},
761+
{
762+
"cell_type": "code",
763+
"execution_count": 46,
764+
"metadata": {},
765+
"outputs": [
766+
{
767+
"data": {
768+
"text/plain": [
769+
"5"
770+
]
771+
},
772+
"execution_count": 46,
773+
"metadata": {},
774+
"output_type": "execute_result"
775+
}
776+
],
777+
"source": [
778+
"int(5.22222)"
779+
]
780+
},
781+
{
782+
"cell_type": "code",
783+
"execution_count": 48,
784+
"metadata": {},
785+
"outputs": [],
786+
"source": [
787+
"k=\"Hellow\""
788+
]
789+
},
790+
{
791+
"cell_type": "code",
792+
"execution_count": 49,
793+
"metadata": {},
794+
"outputs": [],
795+
"source": [
796+
"j=str(\"Python\")"
797+
]
798+
},
799+
{
800+
"cell_type": "code",
801+
"execution_count": 50,
802+
"metadata": {},
803+
"outputs": [
804+
{
805+
"data": {
806+
"text/plain": [
807+
"'HellowPython'"
808+
]
809+
},
810+
"execution_count": 50,
811+
"metadata": {},
812+
"output_type": "execute_result"
813+
}
814+
],
815+
"source": [
816+
"k+j"
817+
]
818+
},
819+
{
820+
"cell_type": "code",
821+
"execution_count": 54,
822+
"metadata": {},
823+
"outputs": [],
824+
"source": [
825+
"x = \"hello\""
826+
]
827+
},
828+
{
829+
"cell_type": "code",
830+
"execution_count": 55,
831+
"metadata": {},
832+
"outputs": [
833+
{
834+
"data": {
835+
"text/plain": [
836+
"'HELLO'"
837+
]
838+
},
839+
"execution_count": 55,
840+
"metadata": {},
841+
"output_type": "execute_result"
842+
}
843+
],
844+
"source": [
845+
"x.upper()"
846+
]
847+
},
848+
{
849+
"cell_type": "code",
850+
"execution_count": 56,
851+
"metadata": {},
852+
"outputs": [
853+
{
854+
"data": {
855+
"text/plain": [
856+
"'hello'"
857+
]
858+
},
859+
"execution_count": 56,
860+
"metadata": {},
861+
"output_type": "execute_result"
862+
}
863+
],
864+
"source": [
865+
"x.lower()"
866+
]
867+
},
868+
{
869+
"cell_type": "code",
870+
"execution_count": 59,
871+
"metadata": {},
872+
"outputs": [
873+
{
874+
"data": {
875+
"text/plain": [
876+
"True"
877+
]
878+
},
879+
"execution_count": 59,
880+
"metadata": {},
881+
"output_type": "execute_result"
882+
}
883+
],
884+
"source": [
885+
"2 < 3"
886+
]
887+
},
888+
{
889+
"cell_type": "code",
890+
"execution_count": 60,
891+
"metadata": {},
892+
"outputs": [
893+
{
894+
"data": {
895+
"text/plain": [
896+
"False"
897+
]
898+
},
899+
"execution_count": 60,
900+
"metadata": {},
901+
"output_type": "execute_result"
902+
}
903+
],
904+
"source": [
905+
"2 > 3"
906+
]
907+
},
908+
{
909+
"cell_type": "code",
910+
"execution_count": 61,
911+
"metadata": {},
912+
"outputs": [],
913+
"source": [
914+
"x = 5"
915+
]
916+
},
917+
{
918+
"cell_type": "code",
919+
"execution_count": 62,
920+
"metadata": {},
921+
"outputs": [
922+
{
923+
"data": {
924+
"text/plain": [
925+
"True"
926+
]
927+
},
928+
"execution_count": 62,
929+
"metadata": {},
930+
"output_type": "execute_result"
931+
}
932+
],
933+
"source": [
934+
"2 < x < 10"
935+
]
936+
},
937+
{
938+
"cell_type": "code",
939+
"execution_count": 63,
940+
"metadata": {},
941+
"outputs": [
942+
{
943+
"data": {
944+
"text/plain": [
945+
"True"
946+
]
947+
},
948+
"execution_count": 63,
949+
"metadata": {},
950+
"output_type": "execute_result"
951+
}
952+
],
953+
"source": [
954+
"2 < 3 < 4 < 5 < 6"
955+
]
956+
},
957+
{
958+
"cell_type": "code",
959+
"execution_count": 64,
960+
"metadata": {},
961+
"outputs": [
962+
{
963+
"data": {
964+
"text/plain": [
965+
"True"
966+
]
967+
},
968+
"execution_count": 64,
969+
"metadata": {},
970+
"output_type": "execute_result"
971+
}
972+
],
973+
"source": [
974+
"\"python\" > \"perl\""
975+
]
976+
},
637977
{
638978
"cell_type": "code",
639979
"execution_count": null,

0 commit comments

Comments
 (0)