DEV Community

Kipkurui Evans Langat
Kipkurui Evans Langat

Posted on

Python programming for beginners

What is python?

Python is a high-level, object-oriented programming language. Most beginners in the development field prefer Python as one of the first languages to learn because of its simplicity and versatility.

Executing the Python program.

take for example we have created a file named main.py and we want to run it we will do the following

Python3 main.py
Enter fullscreen mode Exit fullscreen mode

Creating Functions in Python

for example : if we want to create a function to add two variables


  def add_10(x):
     return (10+x)
Enter fullscreen mode Exit fullscreen mode

Data Types

  • numbers
  • strings
  • boolean
  • tuples
  • lists
  • dictionaries

control statements

  1. for loop

A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).

eg.
Print each fruit in a fruit list:

fruits = ["apple", "banana", "cherry"]
for x in fruits:
  print(x)

Enter fullscreen mode Exit fullscreen mode
  1. if statement

If statement:

a = 33
b = 200
if b > a:
  print("b is greater than a")

Enter fullscreen mode Exit fullscreen mode

Applications of Python.

Artificial Intelligence
Desktop Application
Automation
Web Development
Data Wrangling, Exploration And Visualization.

Top comments (0)