DEV Community

Nkemchor Duru
Nkemchor Duru

Posted on

PYTHON PROGRAMMING -Lesson 1:Basics of Python Programming

As you rightly guessed i will be beginning my DEVOPS journey by learning a programming Language- PYTHON and what better way to go into it than briefly going through the basics of python programming.
So we will be considering briefly the following concepts- Data, Data Type, Basic Data Types in Python and Variable.
What then is Data? Data refers to information that your program processes or stores. It simply refers to information that is presented as values that can be processed by the computer.
What is Data Type? Data types is basically a categorization of data. it signifies the kind of value that a variable holds - in other words it is like a label that tells python how to interpret data.
What are the Data types? Data types can be divided into numeric data types (integers, floating point numbers and complex numbers ), strings and boolean.
Integers: represent whole numbers which can be negative, positive or zero. e.g x=0, y=12, z=-15.
Floating point numbers: represent decimal point numbers. e.g x=12.021, y= -30.12, z= 0.0
Complex numbers:this represents numbers with a real and an imaginary part.
e.g z=3+4j. 3 being the real part and 4j being the imaginary part.
Booleans: represent truth values and can only return two outcomes: true or false. e.g
a=100
b= 40
c= a>b
print (c).

What happens here?

a = 100 this assigns the value 100 to the variable a.

b = 40 this assigns the value 40 to the variable b.

c = a > b compares a and b using the > (greater than) operator.
Enter fullscreen mode Exit fullscreen mode

Why is c boolean?

The expression a > b asks: "Is 100 greater than 40?" This comparison results in either:

True if the statement is correct (100 is greater than 40), or

False if the statement is not correct.
Enter fullscreen mode Exit fullscreen mode

Since the result of this comparison is either True or False, the type of c is boolean (bool in Python), which is the data type used to represent truth values.
So, when you run print(c), you get:

True

because 100 is indeed greater than 40.

The last data type to consider is strings. A string in python can simply be defined as a sequence of characters that are enclosed in quotes.Strings are used to represent Texts.
e.g a= "Alice"
b= 'Hello World!'
c= "Python is fun"
Key points about strings in Python:

  • You can use single quotes ('...') or double quotes ("...") to create a string.
  • Strings can contain letters, numbers, spaces, symbols — basically anything you can type.
  • Strings are immutable, which means once created, you can’t change individual characters inside them (but you can create new strings based on them).

Example:

message = "Hello"
print(message) # Output: Hello
print(type(message)) # Output:
Here, message is a string variable.

Lastly, we will be looking at what a variable is. A variable in Python is like a container that holds a value.
Think of it like this:Imagine a labeled box where you can store something — a variable is the labeled box, and the value is what's inside the box.
For example:
x = 5
name = "Alice"
is_happy = True

x is a variable that stores the number 5
name stores the string "Alice"
is_happy stores the boolean value True

Rules for variables in Python:

  • Variable names must start with a letter or an underscore _.
  • They can contain letters, numbers, and underscores — but no spaces.
  • Python is case-sensitive, so Name and name are different variables.
  • You don’t need to declare a type — Python figures it out automatically.

This brings an end to the tutorial on basics of python programming . In the next lesson we will be exploring Python Operations.

Top comments (0)