DEV Community

Cover image for The Bilingual Developer: Python and Go Primitive Data Types
Ezeana Micheal
Ezeana Micheal

Posted on

The Bilingual Developer: Python and Go Primitive Data Types

As discussed in the previous article on the variables about the need of programming languages to store information. This article will be about how the different data is stored. Let’s slow it down a bit and really think about it. If storage is where data lives… then data types are basically how that data is shaped inside memory. And depending on the language you’re using, that “shape” changes a lot. Primitive data types are the most basic building blocks used to represent values inside a program.

When learning both Python and Go, understanding their primitive data types is one of the fastest ways to understand the design philosophy behind each language.

Understanding Primitive Data Types

Primitive data types are the simplest forms of data a programming language can handle directly. They represent single values such as:

  • Text
  • Numbers
  • Boolean values (true or false)
  • Fixed constant values

Text and Characters

Strings in Python

In Python, text is represented using the str data type. A string, simply put, is a sequence of characters enclosed in quotation marks.

name = "Michael"  
message = 'Hello World'
Enter fullscreen mode Exit fullscreen mode

Python treats strings as Unicode by default, meaning they can store characters from different languages and symbols.

emoji = "😊"  
language = "Python"
Enter fullscreen mode Exit fullscreen mode

One of Python’s strengths is how simple string manipulation feels.

first_word = "Go"  
last_word = "Python"

full_word = first_word + " " + last_word

print(full_word)
Enter fullscreen mode Exit fullscreen mode

Output:

Go Python
Enter fullscreen mode Exit fullscreen mode

Python does not have a separate character (char) data type. A single character is simply considered a string of length one.

letter = "A"
print(type(letter))
Enter fullscreen mode Exit fullscreen mode

Output:

<class 'str'>
Enter fullscreen mode Exit fullscreen mode

This design keeps the language simpler because developers only need to think about one text type instead of multiple character-based types.

Strings and Runes in Go

Go also uses strings for textual data.

package main

import "fmt"

func main() {  
    name := "Michael"  
    fmt.Println(name)  
}
Enter fullscreen mode Exit fullscreen mode

But Go handles characters differently from Python.

In Go:

  • A string represents a sequence of bytes.
  • A rune represents a single Unicode character.

A rune is actually an alias for int32.

var letter rune = 'A'

Notice something important:

  • Strings use double quotes " "
  • Runes use single quotes ' '

This distinction is very important in Go.

package main
import "fmt"

func main() {  
    var character rune = 'G'

    fmt.Println(character)  
}
Enter fullscreen mode Exit fullscreen mode

Output:

71
Enter fullscreen mode Exit fullscreen mode

The output is numeric because Go stores runes internally using Unicode code points.

To print the actual character:

fmt.Printf("%cn", character)
Enter fullscreen mode Exit fullscreen mode

Output:

G
Enter fullscreen mode Exit fullscreen mode

Go’s approach gives developers more control over memory and encoding behavior, especially for systems programming and high-performance applications.

Numbers

Numbers are another core primitive data type.

Both Python and Go support:

  • Integers
  • Floating-point numbers

Integers and Floats in Python

Python makes numeric programming simple.

age = 25  
price = 19.99
Enter fullscreen mode Exit fullscreen mode

Python automatically determines the type.

print(type(age))  
print(type(price))
Enter fullscreen mode Exit fullscreen mode

Output:

<class 'int'>  
<class 'float'>
Enter fullscreen mode Exit fullscreen mode

One important feature of Python is that integers can grow very large automatically.

big_number = 999999999999999999999999999999
Enter fullscreen mode Exit fullscreen mode

Python dynamically allocates memory for large integers behind the scenes.

This flexibility is convenient because developers rarely worry about integer overflow or memory size during basic programming.

Integers and Floats in Go

Go is stricter and more explicit.

var age int = 25

var price float64 = 19.99

Go supports multiple integer sizes:

  • int8
  • int16
  • int32
  • int64

And floating-point types:

  • float32
  • float64

Example:

var smallNumber int8 = 100  
var largeNumber int64 = 9000000000
Enter fullscreen mode Exit fullscreen mode

This explicit sizing is important because each type uses a specific amount of memory.

Type Size
int8 8 bits
int16 16 bits
int32 32 bits
int64 64 bits

Go forces developers to think more carefully about memory usage and performance.

For example:

var x int32 = 10  
var y int64 = 20

// This causes an error  
// fmt.Println(x + y)
Enter fullscreen mode Exit fullscreen mode

Go does not automatically mix different integer sizes. Developers must explicitly convert types.

fmt.Println(int64(x) + y)
Enter fullscreen mode Exit fullscreen mode

This strictness reduces accidental bugs and improves predictability in large systems.

Booleans

Booleans represent logical truth values.

They are heavily used in:

  • Conditions
  • Comparisons
  • Decision-making statements

Booleans in Python

Python uses:

True and False

Notice the capitalization.

is_logged_in = True  
is_admin = False
Enter fullscreen mode Exit fullscreen mode

Example:

age = 20  
if age >= 18:  
    print(True)
Enter fullscreen mode Exit fullscreen mode

Output:

True
Enter fullscreen mode Exit fullscreen mode

Python’s boolean system is highly flexible because many values can behave as truthy or falsy.

Examples of falsy values:

0

None

""

[]

False

Everything else is generally considered truthy.

Booleans in Go

Go also supports boolean values, but with stricter rules(as usual).

var isLoggedIn bool = true  
var isAdmin bool = false
Enter fullscreen mode Exit fullscreen mode

Notice the lowercase keywords:

true and false

Go does not allow non-boolean values in conditional statements.

This is invalid:

var number int = 1

if number {  
    fmt.Println("Hello")  
}
Enter fullscreen mode Exit fullscreen mode

Python allows similar truthy checks, but Go requires an actual boolean expression.

Correct Go example:

if number == 1 {  
    fmt.Println("Hello")  
}
Enter fullscreen mode Exit fullscreen mode

This design improves clarity and reduces ambiguity.

Constants

Constants are values that should never change during program execution.

Constants in Python

Python does not have a true constant keyword. Instead, developers follow a naming convention using uppercase variable names.

PI = 3.14159  
MAX_USERS = 100
Enter fullscreen mode Exit fullscreen mode

However, Python does not enforce immutability.

PI = 10

This still works. The uppercase naming style simply communicates intent to other developers. Python relies heavily on developer discipline and readability conventions.

Constants in Go

Go provides an actual const keyword.

const Pi = 3.14159  
const MaxUsers = 100
Enter fullscreen mode Exit fullscreen mode

Once declared, constants cannot be modified.

const Age = 20

// Error  
// Age = 30
Enter fullscreen mode Exit fullscreen mode

This enforcement makes programs safer and more predictable. Go constants can also exist without explicitly specifying a type.

const Name = "GoLang"
Enter fullscreen mode Exit fullscreen mode

The compiler determines the appropriate type automatically.

Conclusion

In Python, primitive types are designed to feel natural and easy to use. Developers can move quickly without worrying much about memory sizes or strict typing rules.

In Go, primitive types are more structured and explicit. Developers are expected to think carefully about memory, type safety, and predictability.

Comment , Share and Like, thanks for reading.

Top comments (0)