PYTHON:-

immandi murali krishna
3 min readSep 5, 2024

--

What is Python ?

Python is a General-purpose Interpreted, Interactive, Object-Oriented and High-level programming language.It is defind as object-oriented scripting language a defination that blends support for OOPS with an over all orientation towards Scripting roles.

Benefits of using Python:-

  • Easy to use
  • Flexibility
  • Extensive libary support
  • Fewer Bugs
  • In-demand
  • Carrer opportunities
  • Offical Google server-side

Literals in Python :-

Literals is a fixed value or piece of data that stored in the source code of program and doesnt change during execution. Literals are used to represnt data types like string,Numbers,and Booleans are often used to specify data that user should not be able to change.

String:-

Contain textual data in the form of characters, enclosed within Quotes. Single-line string literals are enclosed within a single Quote or Double Qoute.

EXAMPLE:- print("Hello wrold") , print('Hello world'), print( 'Hello "Ram"'),print(" Hello 'ram'")

Numbers:-

A numeric in PYTHON has three types of numeric literals: integer literals, floating-point Literals , Complex literals

  • interger literals:- integer literals are numbers that do not have a decimal point or an exponential part they can be represented as
  • decimal integer
  • Example: x= 1, y=333, z=332
  • Floating-point literals:- floating point literals represent real numbers and written with a decimal point dividing the integer and fractinoal part.
  • Example: X= 33.2 , Y= 33.3
  • Complex literals:- * Complex literals are Represented by A+Bj. A is the real part and the entire B part, along with j, is the imaginary or complex part
  • Examle: A=(‘3+Bj’)

Booleans;-

Boolean is one of the built-in data types provided by Python, which represents one of the two values i.e. True or False. Generally, it is used to represent the truth values of the expressions.

Examples: print(10 > 9), print(10 == 9), print(10 < 9)

variables in Python:-

A Python variable is a reserved memory location to store values. In other words, a variable in a python program gives data to the computer for processing.

Variable Naming Rules in Python

  • Variables names start with letter (a to z or A to Z) OR Underscore ( _ )
  • Example: Vaild = age , _age , Age
  • .In variable name, no special characters allowed other than underscore (_)
  • Example: Valid : age_ , _age
  • Variables are case sensitive. In the above Examples.age and Age are different, since variable names are case sensitive.
  • Variable name can have numbers but not at the beginning.
  • Example: *Age1**
  • Variable name should not be a Python keyword.Keywords are also called as reserved words

How to Declare and use a Variable
Let see an example.
We will declare variable “a” and print it.
a=100 print (a) Here a is a Variable

Differnt types of Variables
Camel Case: The first word is lower case, and each subsequent word start with an uppercase letter

Example**: MyVariable,UserName

snake case:- All letters are lowercase and words are sperated by underscore (_)

Example**: my_variables,user_nam**e,

Kebab case:- All letters are Lowercase,and words are separated by hyphens.

Example:- my-variables,usename
.r

Reserved Keywords:-

  • Reserved keywords are specfic words that have special meanings in the programming language, such as if, for, while, return, class..etc
  • Example: You cannot use class or for as variable names in python, java, or javascript. variable names should be meaningful.
  • To name variables based on the kind of the data they hold, making the code easy to understand.
  • Example: age, studentname, x,y,z.
  • special symbol are not allowed in the variable names, except for the underscore _ .
  • Avoid using special characters like @,#

Comments in Pythone

  • In python, comments are used to annote the code and make it more readable. they are ignored during code excution and do not affect the program functionatilty
  • TYPES OF COMMENTS IN PYTHON
  • Single line comments:-
    A single line comments start with the symbol #. Everything after # on that same line is treated as Comment.
  • Example:- X=11 # this is a variable “
  • MULTI-LINE COMMENTS:-
  • python does not have a specific syntax for multi-line comments. you use Multiple single line comments or use triple quotes(“”” or ‘’’) to simulate line comments
  • Example: “””This is a comments spanning multiple lines”””

https://colab.research.google.com/drive/1wZq5lkJozVAqvocCjlhJKHfnvddYrrnj#scrollTo=042a321b-6344-4b5e-93e0-261acd7d8751

--

--