All Basic Concept of Python

All Basic Concept of Python

In this Blog I promised You Learned All of the Python Concept

Python is a High-level programming Language.It's also a case-sensitive language Python was also used in Artificial Intelligence and Machine Learning. Python was created bu Guido Van Rossum in 1970.

Why Python

Python is used for many reasons.

  1. Automation: Python was a very good programming language for automation like the python automated various things like computers, or the Web.

  2. Web Scrapping: Python was a very good programming language for Web scraping.

  3. Backend: Python was very good Language for Backend like with the help of Django framework he give tools for write backend in python.

  4. Aritificial Intelligence: Python is generally used for AI. Ex - ChatGpt was also AI Platform.

  5. Machine Learning: Python was generally was used in Ml. Like python have various Libraries For ML.

Revolution of Python

Python was designed to be extensible and allow you to use it as an extension language for other modules and applications that need a programmable interface. It was created in the late 1980s and its implementation was started in 1989 by Guido Van Rossum.

Syntax

The syntax is a rule of write a code⭐

Hello World Program

print("Hello, World")

How to Declared Variable in Python

a = "This is a variable"
b = 10

DataTypes in Python

Text Type:

str

Numeric Types:

int, float, complex

Sequence Types:

list, tuple, range

Mapping Type:

dict

Set Types:

set, frozenset

Boolean Type:

bool

Binary Types:

bytes, bytearray, memoryview

None Type:

NoneType


Getting the Data Type

You can get the data type of any object by using the type() function:

a = 10
print(type(a)

x = "Hello World"

str

Try it »

x = 20

int

Try it »

x = 20.5

float

Try it »

x = 1j

complex

Try it »

x = ["apple", "banana", "cherry"]

list

Try it »

x = ("apple", "banana", "cherry")

tuple

Try it »

x = range(6)

range

Try it »

x = {"name" : "John", "age" : 36}

dict

Try it »

x = {"apple", "banana", "cherry"}

set

Try it »

x = frozenset({"apple", "banana", "cherry"})

frozenset

Try it »

x = True

bool

Try it »

x = b"Hello"

bytes

Try it »

x = bytearray(5)

bytearray

Try it »

x = memoryview(bytes(5))

memoryview

Try it »

x = None

NoneType

Conditional Statements

If-else is two only statements are exist in python

If is used for set condition. Else is used for set condition was not True

user = "I Promised in this Blog you clear all Basic concept of Python"
if user == "I Promised in this Blog you clear all Basic concept of Python":
    print(⭐)
else:
    print("Read Again!")

Loop in Python

Python programming language provides the following types of loops to handle looping requirements. Python provides three ways for executing the loops. While all the ways provide similar basic functionality, they differ in their syntax and condition checking time.

While Loop in Python

Python For Loops

A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).

This is less like the for keyword in other programming languages, and works more like an iterator method as found in other object-orientated programming languages.

With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.

Example

Print each fruit in a fruit list:

fruits = ["apple", "banana", "cherry"] for x in fruits: print(x)

Try it Yourself »

The for loop does not require an indexing variable to set beforehand.


Looping Through a String

Even strings are iterable objects, they contain a sequence of characters:

Example

Loop through the letters in the word "banana":

for x in "banana": print(x)

Try it Yourself »


The break Statement

With the break statement we can stop the loop before it has looped through all the items:

Example

Exit the loop when x is "banana":

fruits = ["apple", "banana", "cherry"] for x in fruits: print(x) if x == "banana": break

Try it Yourself »

Example

Exit the loop when x is "banana", but this time the break comes before the print:

fruits = ["apple", "banana", "cherry"] for x in fruits: if x == "banana": break print(x)

All Basic are complete If you Learn Advanced python like class function Libraries of Python etc. Pls send me in Comments What You want.❤️

Did you find this article valuable?

Support KARTIKEY MISHRA by becoming a sponsor. Any amount is appreciated!