Experience IT with PYTHON and Evolve Wisely

Srishti Singh
Analytics Vidhya
Published in
7 min readApr 11, 2020

Python for everyone: learn basic terms without scary codes

What is Program? and What is Programming?

A computer program from one perspective,is a sequence of instructions that dictate the flow of electrical impulse within a computer system, These impulses interact with the display screen, keyboard, mouse, and perhaps even with other computers across a network in such a way as to produce the “MAGIC” that permits humans to perform useful tasks, solve high-level problems and play games.

PROGRAMMING is part science, part art and one great adventure, what you’re creating will be all yours, something you made and it will do just what you told it do.

Why Python?

By learning Python you’ll be able to create a program whether it’s a simple game, a small utility, or business product. With PYTHON, you can quickly write a small project, but Python also scales up nicely and can be used for mission-critical, commercial applications.

INTRODUCING PYTHON:

  1. Python is easy to use: It’s a high level programming language, which allows programmers to express concepts in a few lines of code.
  2. Python is powerful: Python has all the power you’d except from a modern programming language.
  3. Python is a Object Oriented: Object-oriented programming(OOP) is a programming approach of thinking and solving the real world problems.
  4. Python is a “GLUE” language: Programmer can take advantage of work already done in another language while using Python.
  5. Python Runs Everywhere: PYTHON programs are platform independent, which means that regardless of the operating system you use to create your program, it’ll run on any other computer with Python.
  6. Python has a strong community: Python language have a dedicated newsgroup and python support communities.
  7. Python is free and open source: Python is free. You can install it on your computer and never pay a penny.

UNDERSTANDING VARIABLES:

  1. Creating Variables: A variable represents a value stored in the computers memory, A variable provides a way to label and access information.
  2. Using Variables: Once a variable has been created, it refers to some value. The convenience of a variable is that it can be used just like the value to which it refers.
  3. Naming Variables: Like the proud parent of your program, you pick the names of your variables.

Understanding the basic terms:-

Source Code:- The higher-level language code is called source code.

Target code:- The corresponding machine language code is called the target code.

Interpreter:- Translate the source code in line by line format into the target machine language.

Editors:- As only well-formed programs are acceptable for translation into executable machine code, some syntax-aware editors can use colors or other special annotations to alert programmers of syntax errors during the editing process.

Compilers:- Compilers translate the contents of a source file and produce a file containing all the target code.

Indentation:- The space and tabs that are used at the beginning of a statement. The statements with the same indentation belong to the same group called a suite.

Dictionary:- Dictionary is a collection of key-value pairs, dictionaries let you organize information without any sequence.

Assignment:- Assignment in computer language(=) makes the variable on its left take on the value of the expression on its right.

Concatenation:- The plus operator(+) splices two strings together in a process known as concatenation.

Floating-Point Numbers:- Non-integer numbers i.e having the fractional part is known as floating point numbers.

List:- A list is a data structure in Python that is a mutable, or changeable, ordered sequence of elements.

Tuple:- A tuple is a data structure in Python that is a immutable, or unchangeable, ordered sequence of elements.

Understanding Integer and String Values:-

String:- It is a sequence of characters.

Integer:- Integer numbers are same in Python as mathematics, the number without the fractional part which includes negative, positive and zero.

Any integer has a string representation, but not all strings have an integer equivalent.

Introducing the concepts of QUOTES:-

  1. Python recognizes both single quotes (‘) and double quotes(“) as valid ways to delimit a string value.
  2. No quotation for integer expression
  3. Under quotation ( ‘4’ ) its string expression and 4 is an integer expression, both are different.
  4. TRIPLE QUOTES- Triple-quoted strings can span multiple lines, They print on the screen exactly the way you type them.

IMPORTANT- If a single quote marks the beginning of a string value, a single quote must delimit the end of the string and vice versa.

Understanding IDENTIFIERS:-

An identifier is a word used to name things, one of the things an identifier can name is a variable.

Identifiers name other things such as function, classes and methods.

RULES that identifier follows are:-

  1. An identifiers must contain at least one character.
  2. The first character of an identifiers must be an alphabetic letter(upper or lower case) or the underscore.
  3. The remaining characters(if any) may be alphabetic characters(upper or lower case), the underscore or a digit.
  4. No other characters( including spaces) are permitted in identifiers.
  5. A reserved word cannot be used as an identifier.

Operator Precedence and Associativity:-

When different operators appear in the same experssion, the normal rules of arithmetic apply.

PRECEDENCE:- When an expression contains two different kinds of operators, which should be applied first?

ASSOCIATIVITY:- When an expression contains two operators with the same precedence, which should be applied first?

Multiplicative operators (*, /, //, %) have equal precedence with each other.

Additive operators( binary + and -) have equal precedence with each other.

The multiplicative operators have precedence over the additive operators.

To do addition first programmer uses parenthesis to override the precedence rules.

Operator precedence and associativity. The operators in each row have a higher precedence than the operators below it. Operators within a row have the same precedence.

Understanding Looping/Iteration:-

Iteration:- Iteration repeats the execution of a sequence of code. This process of codes execution over and over is known as iteration or looping.

Python supports different forms for iteration, we’ll discuss WHILE and FOR here,

Understanding the WHILE loops:-

The expression following the while keyword is the condition that determines,if the statement block is executed or continues to execute. As long as the condition is true, the program executes the code block over and over again. When the condition becomes false, the loop is finished. If the condition is false initially, the program will not execute the code block within the body of the loop at all.

The general form of the while statement.

While statement is ideal for indefinite loops.

Understanding the FOR loops:-

Python provides a convenient way to express a sequence of integers that follow a regular pattern. The following code uses a range expression to print the integers 1 through 10:

for n in range(1, 11):

print(n)

The expression range(1, 11) creates a range object that allows the for loop to assign to the variable n the values 1, 2, . . . , 10. Conceptually, the expression range(1, 11) represents the sequence of integers 1;2;3;4;5;6;7;8;9; 10.

FORMAT of for loop in PYTHON follows:- range( begin,end,step )

NESTED LOOP:- Just like with if statements, while and for blocks can contain arbitrary Python statements, including other loops. A loop can therefore be nested within another loop.

BREAK STATEMENT:- Python provides the break statement to implement middle-exiting loop control logic. The break statement causes the program’s execution to immediately exit from the body of the loop.

The continue Statement:- The continue statement is similar to the break statement, except the continue statement does not necessarily exit the loop. The continue statement skips the rest of the body of the loop and immediately checks the loop’s condition. If the loop’s condition remains true, the loop’s execution resumes at the top of the loop.

while/else and for/else:- the code in a loop’s else block does not execute if the loop terminates due to a break statement. The else block in the context of a loop provides code to execute when the loop exits normally.

Infinite Loops:- An infinite loop is a loop that executes its block of statements repeatedly until the user forces the program to quit.

Understanding FUNCTIONS in Python:-

FUNCTION:- In Python, a function is a named block of code that performs a specific task. If an executing program needs to perform such a task, it calls upon the function to do the work. One example of a function is the mathematical square root function. Python has a function in its standard library named sqrt. The square root function accepts one numeric (integer or floating-point) value and produces a floating-point result.

MODULE:- A module is a collection of Python code that can used in other programs.

IMPORT:- The import keyword makes a module available to the interpreter.

General form of a statement that imports a subset of a module’s available functions.

BLACK BOX Function:- The caller is concerned strictly about what the function does, not how the function accomplishes its task.

From the Callers perspective a function has 3 important parts:-

  1. NAME:- Every function has a name that identifies the code to be executed, functions name follows the same rule as variable names.
  2. PARAMETERS:- A function must be called with a certain number of parameters and each parameter must be correct type.
  3. RESULT TYPE:-A function returns a value to its caller after computing the result, a function result type and its parameter types can be completely unrelated.

The Built-in Functions:- The builtins module is special because its components are automatically available to any Python program with no import statement is required.

These functions include print, input, int, float, str, and type.

Some functions do not accept any parameters (for ex:- random function)

That’s it! Hope you’ve learned a lot of things about Python basics.

The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination.-Frederick P. Brooks

These basics are enough for you to start you coding journey today!

Have fun, stay safe and always keep learning. And if you liked this content, support my work on Github( https://github.com/Srishti-17/this-girl-can-code ) and on linkedIn ( https://www.linkedin.com/in/srishti-singh-935a2812b )as well.

--

--