Program Statement

Hammer icons created by Freepik - Flaticon
Hammer icons created by Freepik - Flaticonopen in new window

A python statement or program statement in general, like most of other programming languages, is a complete single instruction that an interpreter (for interpreted languages like python) or compiler (for compiled languages) can understand and execute.

Types of Statements

There are various types of statements in python, depending on their purpose. Some of them are

  • assignment statement
  • function call
  1. Assignment statements are used to define a variable or re-assign a new value to a variable.

It has a signature of

<variable> = <value>

Some examples are

age = 35 # Assigning value 35 to variable "age"

age = 35 + 1 # Assigning new value to new or existing variable

name = "syncster.dev" # Another assignment to a variable
  1. Function call is like what we've seen in the previous article when we printed out the "Hello, syncster.dev learner!". It is an execution of a function that may or may not return a value to the caller.

Example of this is:

go()

for function that do not require an argument.

add(2, 6)

for function that requires arguments.

Ending a statement

Unlike other languages such as C, Java, and C++, python do not require a semicolon ; to end a statement. The newline character (by pressing "return" or "Enter" key on the keyboard) triggers the end of a statement.

Summary

In this lesson, we've learned some basics of statements in python and the definition in general for other languages as well. We've also seen some types and examples of statements.

In the next chapter, we will be looking at python packages. See you on the next one!

Last Updated:
Contributors: alexiusacademia