why I love atomic design

Atomic Design is a method for creating modular design systems. For the description of his modular system, the inventor of the design approach, Brad Frost, used an analogy from chemistry science…


独家优惠奖金 100% 高达 1 BTC + 180 免费旋转

Python for Beginners

Basics of Python for the Beginners

In the current times, Python have become one of the prominent & trendy programming language in the world. It is being used in most of the applications like Building the websites/Servers, Software testing, Machine Learning(ML) Algorithms, IOT’s , Games and much more.

Now let’s begin by understanding What is Python? And Where & How to start from?

python logo

Python is a general purpose language, which means we can use as a solution to varities of situations and not restricted to any specific situation. Versatility and beginner friendliness is the the one of the unique feature of Python.

Python is a cross platform language, which can be used to run on the different platforms like Windows, Mac, Linux & Raspberry Pi.

Versatility: Python is well-structured, readable, neat, easy to use/understand and learn. Hence can be used for developing varities of tasks/projects.

Maintainable Code: Python have very simple syntax which is very similar with the English language, hence it is easy to learn and understand. It helps to create and complete the projects faster.

Compatibility: As discussed ealier Python can run on different platforms like Windows, Mac, Linux & Raspberry Pi.

OpenSource: Python is free to use and distribute and also have very large and active community across the world which can be very helpful for the developers.

Libraries: Ther are many 3rd party libraries users have created and contributed which can be used for web development, games development, machine learning and many more.

Prototyping: As Python runs on the interpreter system, the code will be executed as soon as it is written and no need to wait for the build to be created or any such sort.

Even without any prior programming experience, you should be able to get a good start with this python basics.

To print anything, we just need to write:

In python you don’t require to declare variables or thier types before using them. Everything in Python is by default an object.

Python supports two types of numbers.
Integers: To declare any integer value without decimals we can follow the below syntax.

Float: To declare any floating point number which can contain positive/negative number with one or more decimals we can follow the below syntax.

Strings: Strings are declared using single quote or double quotes.

Booleans: To declare any boolean variable we can follow below syntax.

List: Lists are used to store multiple elements in a single variable, List can contain different data types and to declare a list we must follow the below syntax.

Tuples: Tuples are similar to list which can be used to store multiple elements in a single variable. But Tuples are ordered and unchangeable, to declare a tuples we must follow the below syntax.

Set: Sets are also similar to List and Tuples which can be used to store multiple items in to a single variable. But Sets are unordered, unchangeable(Once a set is created, we cannot change its items, but you can remove items and add new items and does not allow duplicate values) and unindexed, to declare a sets we must follow the below syntax.

Dictionaries: Dictionaries are used to store data in key:value pairs. It is a collection which is orderd, changeable and does not allow duplicate values, to declare a dictionary we mush follow the below syntax.

In other programming languages the indenting in code is for readability only, but in Python it is very important, it indicates a block of code. In other programming language we commonly use “{}” curly braces but in Python we must use the whitespaces to indent the code.

Here we will learn about the operators available in python.
Arithmetic Operators: Common operators like available in any language they are ‘+’,‘-’,‘*’,‘/’. For Example:

Modulo Operator: Modulo(‘%’) operator will return the integer remainer of the division. For Example:

Power Operator: ‘**’ operator is used to perform power of operation. For Example:

Concatinating String: To cponcat any string we can use ‘+’ operator. For Example:

Multiplying String: Python also supports multiplying of string to form a string with repeated same string. For Example:
tenTimesHello = “hello ” * 10

Using ‘+’ operator we can join lists. For Example:

Multiplying Lists: Just like string even with list we can multiply to create a repeating sequence using multiplier operator ‘*’. For Example:

Python supports normal logical conditions like any other programming language which are used to perform to make the decisions. Below are the conditions we can use to perform logical decisions.
Equals: ==
Not Equal: !=
Less than: <
Less than or equal to: <=
Greater than: >
Greater than or qual to: >=
For Example:

Boolean Operators:
In other languages we use ‘&&’ for and & ‘||’ for or. But in python it is replaced with and & or operators. For Example:

In Operator:
operator can be used to check if a specified element or string exists with-in the passed object/array/string.

IF Elif & Else Conditions: If, Elif and Else conditions are used to perform the decisions. If condition starts with the keyword if, elif key is used execute the condition if previous condition is not met and else key word is used to catch anything which is not caught in if and elif condition. For Example:

For Loops: For loops are used to iterate thru the element in a sequence. For Example:

Nested For Loop:
A loop inside a loop is called as nested loops. For Example

range: For loops iterate through a sequence of numbers using the ‘range’ methods. Range returns a new list of numbers with specified range. For Example:

While Loops: While loop will execute a set of statements as long as a certain boolean condition is met. For Example:

Break and Continue:
and continue statements are used in while loops to exit a loop or skip the current block.

Functions or methods are the convenient way to break a big code to small and meaningful blocks. It allows the user to order the code and make it more readable, increase re-usuability and reduces the time consumed while creating similar project functionalities. Syntax is a follows:

Sample function: On calling the below function it will display the text written in print.

Function with Arguments: Below is the example code to pass the arguments in the functions declaration.

Returning from a function: By using the keyword “return” we can return the value to the caller. For Example:

There is so much more to explore and learn but you can use the skill you have learnt till now to began your journey as a novice.

Now go ahead and read other blogs and articles but make sure your basics are clear before diving deep into the language.

Add a comment

Related posts:

A Tax Break That Could Raise Retiree Income and Reduce the Deficit

Taxes raise money for government operations, but they also sometimes serve to change behavior in society. Taxes on cigarettes are a well-known example because they tend to cause smokers to quit…