Python: A Deep Dive into the Fundamentals

Nipun Madusanka
3 min readMar 9, 2023

--

Python is one of the most popular programming languages in use today, lauded for its versatility and power. While Python’s application in data mining is widely known, it has become ubiquitous in many other fields as well. Let us take a closer look at some of the fundamental concepts in Python programming.

Creating Variables in Python

Python’s dynamism allows for a flexible approach to variable creation. Unlike other languages, it is not necessary to declare the variable type before use. Take, for example, the following code snippet:

“x = 4 y = 6

print(x+y)”

The above code creates two variables “x” and “y,” both assigned with numerical values, and subsequently, adds them together. The output of this program is the sum of the two values. Python’s dynamic approach makes the declaration process effortless and smooth.

Variables in Python

Input Function in Python

The input function is an indispensable tool in Python programming. It is used to receive user inputs during program execution. However, the input function in Python defaults to receiving inputs as strings. To get the integer value, the input function must be wrapped in the eval function. See the following code snippet:

“xy = eval(input(“enter”))

print(xy+2)”

The above code prompts the user to input a value, which is then converted to an integer by wrapping the input function in the eval function. The resultant value is then added to the integer value 2 and printed on the console.

Input Function

Arrays in Python

In Python, arrays are used to access and manipulate data. Python’s dynamic approach also applies to arrays, allowing for easy management of data structures. For instance, strings in Python behave like arrays. See the following code snippet:

“my = “hello”

print(my[1])”

The above code creates a variable “my” and assigns it a string value “hello.” Then, the code prints the second element of the string, which is the letter “e.” Python supports three types of arrays, namely lists, tuples, and dictionaries, each with its unique characteristics.

Next Article: - Python Arrays: How to Use and Manipulate Arrays in Python

Feel free to get in touch with me. https://linktr.ee/jmnipun

--

--

Nipun Madusanka

Learning about new technologies is a passion of mine, and I find it enjoyable. My ultimate goal is to utilize technology in ways that benefit society.