
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.

Before starting with the basics of the Python programming language, we will learn about some definitions and elements of the Python language:-
- Central Processing Unit (CPU) : Runs the program-The CPU is always wondering “What to do next?”. Not the brains exactly, very dumb but very fast.
- Input Devices such as Keyboard, Mouse, Touch Screens and Output devices are Screens, Speakers, Printers, DVD, Burner.
- Main Memory: Fast but small temporary storage which will be lost on system reboot. Main memory is also known as Random Access Memory (RAM).
- Secondary Memory: Slower but large permanent storage which lasts until deleted. These can be known as disk drives or memory disks.
Elements of Python
- Vocabulary/words – Variables and reserved words.
- Sentence Structure – Valid syntax patterns.
- Story Structure – Constructing a program for a purpose.
Reserved Words
You cannot use reserved words as variable names/identifiers. Some reserved words are: false, class, return, is, finally, none, if for, lambda, continue, true, def, from, while, nonlocal, and, del, global, not, with, as, elif, try, or, yield, assert, else, import, pass, break, except, in, raise.
Sentences or Lines
- x = 2 ⇽ Assignment statement
- x = x+2 ⇽ Assignment with expression
- print(x) ⇽ print function
Python Scripts
- Interactive Python is good for experiments and programs of 3–4 lines long.
- Most programs are much longer, so we type them into a file and tell Python to run the commands in the life.
- In a sense, we are, “giving Python a script”.
- As a convention, we add “.py” as the suffix at the end of these files to indicate they contain python.
Interactive versus Script
- Interactive → You type directly to Python one line at a time and it responds.
- Script → You enter a sequence of statements (lines) into a file using a text editor & tell Python to execute the statements in the file.
Program Steps/Program Flow
- Like a recipe or installation instructions, a program is a sequence of steps to be done in order.
- Some steps are conditional, which means they may be skipped.
- Sometimes a step or group of steps is to be repeated.
- Occasionally, we store a set of steps that can be used multiple times throughout the program, as needed.
Sequential Steps: When a program is running, it flows from one step to the next. As programmers, we set up “paths” for the program to follow.

Conditional Steps

Repeated Steps: Loops (repeated steps) have iteration variables that change each time through a loop.

Constants
- Fixed values such as numbers, letters & strings are called “constants” because their values do not change.
- Numeric constants are as you expect. For example: 123, 234, etc.
- String constants use single quotes (‘’) or double quotes (“”).
print(123)
print(98.6)
print("Hello World")
Variables
- A variable is named as a place in memory where a programmer can store data and later retrieve the data using the variable “name”.
- Programmers get to choose the names of the variables.
- You can change the contents of a variable in a later statement.
Rules for naming a Python variable:
- It must start with a letter or underscore
- It may consist of letters, numbers, and underscores.
- There can be no special characters used for naming a variable.
- Naming of variables is case-sensitive.
Good: spam, eggs, spam23, _speed
Bad: 23spam, #sign, var.12
Different: spam, Spam, SPAM
Reposting here as I posted it before on Medium.
Please like and subscribe for more...



Comments
There are no comments for this story
Be the first to respond and start the conversation.