Python for Go Developers
Bring Go experience to Python: compare slices and lists, maps and dicts, errors and exceptions, structs and classes, and interfaces and duck typing. Practice in multi-file tasks and build an order processor.
Go and Python side by side
The same program in Go and in Python, from the lessons of this course.
Printing, Quotes, and Comments
Go programs enter through main in package main. Python can execute statements at file scope. Both calls below separate arguments with a space and end with a newline. In Python both single and double quotes create strings; a Go single-quoted literal represents…
Go1// Inside main:2// A comment3fmt.Println("Status:", "ready")4fmt.Println("Don't stop")Python1# A comment2print("Status:", "ready")3print("Don't stop")None, nil, and Zero Values
Go nil applies to pointer, slice, map, function, channel, and interface types. A zero-valued Go int is 0, not nil. Python None is a singleton object used to represent absence; it is not the same value as zero or False. Use is None to test it. Python boolean…
Go1// Inside main:2var seats *int3fmt.Println(seats == nil)4fmt.Println(false)Python1seats = None2print(seats is None)3print(False)4zero = 05print(zero is None)Slices Versus Python Lists
A Go slice describes a segment of a backing array; slicing normally shares that array. In the example b has spare capacity, so append reuses the array and overwrites a[2]. A Python list slice instead makes a new outer list. Its elements are still shared…
Go1// Inside main:2a := []int{4, 8, 12}3b := a[:2]4b[0] = 95fmt.Println(a[0], len(b))6b = append(b, 7)7fmt.Println(a[2])Python1a = [4, 8, 12]2b = a[:2]3b[0] = 94print(a[0], len(b))5result = b.append(7)6print(a[2], result)range and Value Iteration
Go range over a slice supplies index and a copy of the element. Python for binds the element directly; it does not yield an index by default. For integer counting, Python range(start, stop, step) excludes stop and produces a reusable range object, not a list…
Go1// Inside main:2values := []int{4, 8}3for _, value := range values { fmt.Println(value) }4for i := 1; i < 4; i++ { fmt.Print(i) }5fmt.Println()Python1values = [4, 8]2for value in values:3 print(value)4print(list(range(1, 4)))Functions and Tuple Returns
Both languages allow functions outside classes. Go declares parameter and return types in its function signature; Python def names parameters and uses return for a result. A comma-separated Python return builds one tuple object, unlike Go multiple results. A…
Go1func splitTime(total int) (int, int) { return total / 60, total % 60 }2// Inside main:3h, m := splitTime(125)4fmt.Println(h, m)Python1def split_time(total):2 return total // 60, total % 603result = split_time(125)4print(result)5h, m = result6print(h, m)Text and Exact Output
Python input() reads a line and removes its line-ending newline; it does not strip surrounding spaces from the remaining text. Use strip() only when the contract asks for it. Go fmt.Scan scans whitespace-delimited tokens, so it would split this label; use…
Go1// Inside main:2label := strings.TrimSpace(" team blue ")3cents := 5074fmt.Printf("%s: %d.%02d\n", label, cents/100, cents%100)Python1label = " team blue ".strip()2cents = 5073print(f"{label}: {cents // 100}.{cents % 100:02d}")
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFrom Go to Python
6 lessonsValues, Absence, and Branches
5 lessonsSlices, Maps, and Sharing
5 lessonsIteration and Transformations
5 lessonsFunctions and Call Contracts
5 lessonsErrors, Modules, and Hints
5 lessonsStructs to Python Classes
6 lessonsInterfaces and Object Design
5 lessonsProject: An Order Processor
4 lessonsApply Your Go Experience
2 lessonsFrequently asked questions
Who is Python for Go Developers for?
For people who already write Go and want to learn Python. Each lesson starts from Go you know and shows how Python does the same thing, so you skip the beginner basics.
Do I need to know Python already?
No. The course starts with your first Python program. You need Go basics: variables, conditions, loops, functions and collections.
How many lessons does Python for Go Developers have?
Python for Go Developers contains 48 interactive lessons you can complete at your own pace.
What does Python for Go Developers cover?
The course is organized into chapters covering: From Go to Python, Values, Absence, and Branches, Slices, Maps, and Sharing, Iteration and Transformations, and more.
Is Python for Go Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.