DEV Community

Emenike onyedikachi sunday
Emenike onyedikachi sunday

Posted on

Getting Started with Python Programming: A Beginner's Guide

Python is a popular programming language noted for its ease of use and adaptability. Python is a wonderful language, to begin with if you are an aspiring programmer or a curious individual wishing to dip your toes into the world of coding. In this post, we'll give you a gentle introduction to Python programming, walking you through the fundamentals and preparing you to begin your coding journey /lcife.

1. What exactly is Python?

Python is a computer language that prioritizes readability and ease of use. It was designed to be simple to learn and write, making it an excellent alternative for novices. Python's syntax is intended to be intuitive and human-friendly, allowing you to express your thoughts naturally.

2.Installing Python:

  • Download the newest version of Python from the official Python website (python.org).
  • To install Python on your PC, run the installer and follow the instructions.

3. Writing Your First Program:

Once Python is installed, open a text editor (such as Notepad, Sublime Text, or Vs Code) to write your code.

Let's start with creating a python file by naming the new file you created "name.py" the ".py" is very important because that what tell the text editor that the file is python file ,and inside it lets start with a simple "Hello, World!" program, which is a common programming starting point. In a text editor, enter the following code:

print("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

Image description

4. Running Python Code:

So for the code to run you have to Open the command prompt or terminal and navigate to the directory where you saved your Python file.

Type python filename.py and press Enter to run the program. In this case, it would be python hello.py.
You should see the output "Hello, World!" displayed on the screen.

Image description

5. Variables and Data Types:

Variables are used to store values in Python. The equals (=) sign is used to assign a value to a variable. Python supports a wide range of data types, including:
Integers (whole numbers) and floating-point numbers (decimal numbers) are the two types of numbers.

  • Strings: character sequences contained in single (' ') or double (" ") quotes.
  • Booleans: can be either True or False.
name = "John" //strings//
age = 25 //integers//
price = 9.99 //floating-point//
is_valid = True //booleans//

Enter fullscreen mode Exit fullscreen mode

6.Basic Operations:

Python allows you to perform arithmetic operations like addition (+), subtraction (-), multiplication (*), division (/), and more.
You can also use comparison operators like equals (==), greater than (>), less than (<), and logical operators like and, or, and not.

7.Flow of Control:

Python has control flow statements that can be used to make decisions and repeat activities. If-else statements and loops are two examples.
If-else statements allow your software to take alternative actions depending on certain conditions.
Loops, such as the for and while loops, allow you to repeat a block of code several times.

8. Functions:

Functions are reusable blocks of code that perform specific tasks. They help organize your code and make it more modular. Python provides built-in functions, and you can also create your own functions.

Python has built-in functions, but you can also create your own functions using the def keyword. For example:

def sayhello(name):
    print("Hello, " + name + "!")

sayhello("Emenike") ;

Enter fullscreen mode Exit fullscreen mode

Conclusion:

There are still many stuffs to learn python but for now as a beginner this is the basic you need to learn and there are site you can go to learn more like w3school, Udemy, YouTube .etc..
I will still be dropping more soon , please fell to comment below . and another Enjoy your journey.

Top comments (0)