UNDERSTANDING PYTHON CODE STRUCTURE
David Bosah
Posted on June 22, 2024
Code Structure
This is the arrangement of code in a programming language. it encompasses the use of formatting techniques like whitespace and indentation. The goal of a good structure is reliability and maintainability.
Python code Structures
There are various parameters that are used in describing the Python language. For proper understanding, look at python language as a modern skyscraper that consists of various subordinate structures such as Cement, sand, gravels, stones, Iron, metals and Glasses needed to build it. Without these structures the complete skyscraper you seen will definitely not be the way it is. Same with the python language, certain structures make up the language.
There are basic python language code structures that you must grasp. Let's look at some of them:
Comments:
These are used to make the code easy to understand. They start with "#"
Variables:
They are used to store data or values in your code.
Function:
They are used to exercise a certain function once called. They are either built in function or user defined function.
Data Types
Python Supports lots of built in data types including strings and integers.
Operators:
They are used to perform different operations on data and variables.
Let's Apply these Structures:
#This right here is a comment
#Defining Variables
a=10
y="happy"
#Defining Arithmetic operation
answer= a+8
#Now for functions
#Examples of built in functions
Print()
Input()
#For user defined functions
Def Applaud (name)
Print("congratulations + name + !")
#Using the function
Applaud ("Meghan")
Posted on June 22, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
May 13, 2023