66 "source" : [
77 " # Python 101 - An Introduction to Python\n " ,
88 " \n " ,
9- " Created by Joachim Krois, 2020-10-23 \n "
9+ " Created by Joachim Krois, 2020-12-08 \n "
1010 ]
1111 },
1212 {
7373 " print(a,b,c,d,e)"
7474 ]
7575 },
76- {
77- "cell_type" : " code" ,
78- "execution_count" : null ,
79- "metadata" : {},
80- "outputs" : [],
81- "source" : [
82- " print(\n " ,
83- " type(a),\n " ,
84- " type(b),\n " ,
85- " type(c),\n " ,
86- " type(d),\n " ,
87- " type(e),\n " ,
88- " )"
89- ]
90- },
9176 {
9277 "cell_type" : " markdown" ,
9378 "metadata" : {},
164149 " # \" Hello \" **4"
165150 ]
166151 },
167- {
168- "cell_type" : " code" ,
169- "execution_count" : null ,
170- "metadata" : {},
171- "outputs" : [],
172- "source" : [
173- " # Boolean operators compare two things\n " ,
174- " a = (1 > 3)\n " ,
175- " a"
176- ]
177- },
178- {
179- "cell_type" : " code" ,
180- "execution_count" : null ,
181- "metadata" : {},
182- "outputs" : [],
183- "source" : [
184- " b = (3 == 3)\n " ,
185- " b"
186- ]
187- },
188152 {
189153 "cell_type" : " markdown" ,
190154 "metadata" : {},
236200 "metadata" : {},
237201 "outputs" : [],
238202 "source" : [
239- " round(3 .3)"
203+ " round(45 .3)"
240204 ]
241205 },
242206 {
358322 " syntax `variable.method(arguments)`."
359323 ]
360324 },
325+ {
326+ "cell_type" : " code" ,
327+ "execution_count" : null ,
328+ "metadata" : {},
329+ "outputs" : [],
330+ "source" : [
331+ " a = \" hello world\" "
332+ ]
333+ },
361334 {
362335 "cell_type" : " code" ,
363336 "execution_count" : null ,
519492 " a"
520493 ]
521494 },
522- {
523- "cell_type" : " code" ,
524- "execution_count" : null ,
525- "metadata" : {},
526- "outputs" : [],
527- "source" : [
528- " a.pop()\n " ,
529- " a.pop()\n " ,
530- " a.pop()"
531- ]
532- },
533- {
534- "cell_type" : " code" ,
535- "execution_count" : null ,
536- "metadata" : {},
537- "outputs" : [],
538- "source" : [
539- " a"
540- ]
541- },
542- {
543- "cell_type" : " code" ,
544- "execution_count" : null ,
545- "metadata" : {},
546- "outputs" : [],
547- "source" : [
548- " a.sort()"
549- ]
550- },
551- {
552- "cell_type" : " code" ,
553- "execution_count" : null ,
554- "metadata" : {},
555- "outputs" : [],
556- "source" : [
557- " a"
558- ]
559- },
560- {
561- "cell_type" : " code" ,
562- "execution_count" : null ,
563- "metadata" : {},
564- "outputs" : [],
565- "source" : [
566- " a.reverse()"
567- ]
568- },
569- {
570- "cell_type" : " code" ,
571- "execution_count" : null ,
572- "metadata" : {},
573- "outputs" : [],
574- "source" : [
575- " a"
576- ]
577- },
578495 {
579496 "cell_type" : " markdown" ,
580497 "metadata" : {},
584501 " We won't say a whole lot about tuples except to mention that they basically work just like lists, with\n " ,
585502 " two major exceptions:\n " ,
586503 " \n " ,
587- " 1. You declare tuples using () instead of [] \n " ,
588- " 1 . Once you make a tuple, you can't change what's in it (referred to as immutable)\n " ,
504+ " 1. You declare tuples using `()` instead of `[]` \n " ,
505+ " 2 . Once you make a tuple, you can't change what's in it (referred to as immutable)\n " ,
589506 " \n " ,
590507 " You'll see tuples come up throughout the Python language, and over time you'll develop a feel for when\n " ,
591508 " to use them. \n " ,
592509 " \n " ,
593510 " In general, they're often used instead of lists:\n " ,
594511 " \n " ,
595512 " 1. to group items when the position in the collection is critical, such as coord = (x, y)\n " ,
596- " 1 . when you want to make prevent accidental modification of the items, e.g. shape = (12, 23)\n " ,
597- " 1 . when we need a *hashable* object (as key in a mapping/dict) (explained later)"
513+ " 2 . when you want to make prevent accidental modification of the items, e.g. shape = (12, 23)\n " ,
514+ " 3 . when we need a *hashable* object (as key in a mapping/dict) (explained later)"
598515 ]
599516 },
600517 {
845762 "metadata" : {},
846763 "outputs" : [],
847764 "source" : [
848- " x = 0 \n " ,
765+ " x = 7 \n " ,
849766 " \n " ,
850767 " if x > 0:\n " ,
851768 " print(\" x is positive\" )\n " ,
856773 ]
857774 },
858775 {
776+ "cell_type" : " markdown" ,
777+ "metadata" : {},
859778 "source" : [
860779 " ## 8. Functions (UDFs)"
861- ],
862- "cell_type" : " markdown" ,
863- "metadata" : {}
780+ ]
864781 },
865782 {
866783 "cell_type" : " code" ,
869786 "outputs" : [],
870787 "source" : [
871788 " def my_func(a, b, c=10):\n " ,
789+ " \"\"\" This is an example of a basic function in Python\"\"\" \n " ,
872790 " rv = (a - b) * c\n " ,
873791 " return rv"
874792 ]
907825 "name" : " python" ,
908826 "nbconvert_exporter" : " python" ,
909827 "pygments_lexer" : " ipython3" ,
910- "version" : " 3.7.8 "
828+ "version" : " 3.7.6 "
911829 }
912830 },
913831 "nbformat" : 4 ,
914832 "nbformat_minor" : 4
915- }
833+ }
0 commit comments