PYTHON PROGRAMMING

Kodipyakasanjana
6 min readSep 9, 2024

--

Hey Guys…. Hello and first of all I welcome you to all my blog!!! So you guys all know what is python??

OK !! OK !! Breathe in! I will explain you all what it is and how its implemented in our lives. So lets get into it!!

What is Python??

The below picture seems a bit clumsy right….Don’t worry python can be learnt in fun way as well….

INTRODUCTION TO PYTHON PROGRAMMING:-

🐍Python isn’t just a snake! It’s a programming language that’s become a global ✨ in coding world. Interesting right???
Now let’s get into some Technical terms of python
Python is an object-oriented, interpreted, high-level programming language, developed by Guido van Rossum and originally released in 1991.Python is a versatile language that is now replacing many of the programming languages. Not only that it handles the complexity for the user, allows the newbies to focus on grasping the concepts, and produce result-driven codes.
Got some idea about python??? So the term Python shadows you wherever you go . So now we will understand where python is applicable and how is it useful in different backgrounds…..
» Python is used in finance and accounting to manage personal budgets, analyze financial data, or build simple accounting tools.

» Python can be used for entertainment purpose , manage media files, create playlists, or automate video and photo editing tasks.

» Python can be used for creating interactive games in a very easy manner.

Interesting right??? So that’s why Python is called as a versatile language!!!

Why is it ideal for both beginners and developers?

For Beginners, Python’s simplicity, readability, and supportive learning resources make it an approachable language for those new to programming.

For the developers its rich ecosystem, versatile applications, and advanced features allow seasoned developers to tackle complex projects and integrate with other technologies effectively.

Python

Now you understood python is a programming language its like a medium for both computer and a human to talk just like an English language which acts like a medium for the humans to communicate with each other. So you all know phrases in English language in which are fixed words. In the same way Python has Literals. Now let’s get into literals topic in deep………………

LITERALS IN PYTHON :-

In Python programming, literals are the basic building blocks of code that represent fixed values. They are used to specify constant values directly in the code, and they come in several types, each representing different kinds of data.

Types of literals in python:-

» Numeric Literals:- In numeric literals, we have 3 types
⁃ Integer Literals :- Represent whole numbers.
Example:-0,47,-5
⁃ Floating-Point Literals :- Represent numbers with a decimal point. Example:-3.14, -0.001, 2.0.
⁃ Complex Number Literals :- Represent numbers with both real and imaginary parts. Example: 3 + 4j, -1j.

» String Literals :- Represent text data and can be enclosed in single quotes (‘…’), double quotes (“…”), or triple quotes (‘’’…’’’ or “””…”””). Triple quotes allow for multi-line strings.
Example :- s1 = ‘Hello, World!’

»Boolean Literals :- Represent the truth values True and False.
Example :- flag = True

»None Literal:- Represents the absence of a value or a null value.
Example :- result = None

Literals in Python

VARIABLES IN PYTHON:-

In Python, variables are fundamental elements that store data values. They act as containers for data, allowing you to reference and manipulate that data throughout your program.

» Defining the variables:- In Python, you define a variable by assigning it a value using the = operator. The general syntax is:

variable_name = value

Example :- int a=5
Here, int is its datatype , a is the variable name and 5 is its value..

There are different datatypes in python like int, float, string, char and bool.

Variables in python

Dynamic Typing:- Python’s dynamic typing allows variables to be assigned different types of data at runtime. This flexibility supports rapid development and testing.

Example :- data = 42 # Initially an integer
data = “hello” # Later changed to a string

Naming Conventions for variables:-

— Start with a Letter or Underscore: Variable names must start with a letter (a-z, A-Z) or an underscore (_).
variable1,_variable, myVariable.
Example:- a1,_a
Followed by Letters, Digits, or Underscores: After the first character, variable names can include letters, digits, and underscores.
Example :- var_2, data_2024
Case-Sensitive: Python is case-sensitive, meaning Variable, variable, and VARIABLE are considered different identifiers.
— Avoid Reserved Keywords
Example :- if, else, for, while.

Python naming conventions

COMMENTS IN PYTHON:-

Comments in code are crucial for enhancing readability and maintainability. They serve as annotations that explain what the code does, making it easier for others (and yourself) to understand and manage the code later.

Types of comments:-
» Single Line Comments:- Single-line comments in Python are used to add brief explanations or notes about a particular line or block of code. They start with the # symbol. Everything following the # on that line is considered a comment and is ignored by the Python interpreter.

Example :- variable = 10 # This is a single-line comment
» Multi Line Comments:- Python does not have a specific syntax for multi-line comments, but you can use triple quotes (‘’’ or “””) for multi-line strings, which can also serve as multi-line comments if they are not assigned to a variable.
Example:-
’’’’’
This is a multi-line comment.
It spans multiple lines.
’’’’’

KEYWORDS IN PYTHON:-

In Python, keywords are reserved words that have a special meaning in the language. These keywords are integral to the syntax and structure of Python and cannot be used as identifiers (names for variables, functions, classes, etc.). They are predefined and serve specific functions within the language, guiding how the interpreter processes the code.

Keywords in python:- There are 36 keywords in python like
[False, None, True, and, as, assert, break, class, continue, def, del, elif, else, except, finally, for, from, global, if, import, in, is, lambda, nonlocal, not, or, pass, raise, return, try, while, with, yield]

Code Snippets of keywords used in Python:

Example 1:- In this code snippets if,elif are the keywords

age = 18
if age < 18:
print(“You are a minor.”)
elif age == 18:
print(“You are an adult now.”) else: print(“You are an adult.”)

Example 2 :- In this code snippet try,except are the keywords
try:
value = int(“hello”)
except ValueError:
print(“Conversion failed!”)
finally:
print(“Execution complete.”)

Python Keywords

So these are some of the basics in Python hope you all got the point which I was trying to say if you have any queries refer to the links on the main areas which were mentioned with the link…
Happy learning…..😁😁

--

--