0% found this document useful (0 votes)
4 views4 pages

Python Basics

Python is a general-purpose Object Oriented Programming language developed by Guido van Rossum and released in 1991. It is characterized by its high-level syntax, open-source nature, and interpreted execution, making it user-friendly for beginners. The document also covers key concepts such as tokens, data types, operators, comments, and basic input/output functions in Python.

Uploaded by

tanmay.gdgpsmt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Python Basics

Python is a general-purpose Object Oriented Programming language developed by Guido van Rossum and released in 1991. It is characterized by its high-level syntax, open-source nature, and interpreted execution, making it user-friendly for beginners. The document also covers key concepts such as tokens, data types, operators, comments, and basic input/output functions in Python.

Uploaded by

tanmay.gdgpsmt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

INTRODUCTION TO PYTHON

Python is a general-purpose Object Oriented Programming language developed in late 1980


and released in 1991 by Guido van Rossum at National Research Institute for Mathematics
and Computer Science in the Netherlands.
Features of Python
• Python is a high level language (English like).
• It is a free and open source language. It can be freely downloaded from
www.python.org/downloads and comes along with source code.
• It is an interpreted language, as Python programs are executed by an interpreter (line
by line)
• Python programs are easy to understand as they have a clearly defined syntax and
relatively simple structure.
• Python is case-sensitive

There are two ways to use the Python interpreter:


a) Interactive mode – where each command is followed by its output. Easy for beginners
b) Script mode – group of logically related commands that make a program.

Any programming language is made up of tokens


Tokens – Smallest individual unit in a program is known as token. Tokens are of following
types :
Keywords: Reserved for special use. Can’t be used as variable names. Ex. if, any, in while,
else etc
Identifier: A variable name is called as identifiers. A variable name must follow certain
rules -
• It can be any combination of letters, digits and underscore characters.
• No special characters ( $@#!-., etc ) are allowed. Not even space character.
• The first character cannot be a digit.
• Variables in Python are case sensitive.
Literal : It is a constant (fixed) whose value never change during the program execution.
Eg.
String Literal – “Delhi”, ‘book’, ‘Enter a no’, ‘Enter your name’
Numeric Literal – 2, 7, 480, 12.5, 256.1724
Operators: These are special symbols used to perform some tasks. The variables or values
on which the operators work is called operands. The various types of operators are -
✓ Arithmetic: These are used to perform mathematical operations on variables or constants
(fixed values)
✓ Relational: These are also known as comparison operators. They compare the values
given on oth sides of the operator and return a Boolean True/ False.
Data Types: Data type specifies the type of value a variable can store. It helps us to identify
what kind of operations can e performed on specific data values. Some of the common, uilt-
in data types are -
✓ Numbers – can be further divided as
• Integer – positive or negative whole no. without decimal point eg- 5, 12, -9
• Float- Real numers with decimal point eg – 23.7 , 3.14172, -56.72
✓ String – a group of characters enclosed in quotation marks. It can be single quote (‘ ‘ ) or
doule quotes (“ “)
✓ Boolean- It can have only two values – True or False. A True value is represented by 1 or
any non-zero value, whereas False is represented by 0
Eg. 2>3 → False

Comments- Comments are used to add a remark or a descriptive note in the source code.
They are not executed by interpreter. They are added with the purpose of making the
source code easier for humans to understand. In Python, a comment starts with # (hash sign).

The input function : It is used to take input from the user. The input given by the user is
collected in a variable on LHS of = sign before the input function. The input function
returns a string by default. We can provide a string message as a prompt inside the
brackets. Eg.
Name= input(‘Enter your name’)
If we want numeric input, the function name should be preceded by int or float as required.
Eg. A = int(input(‘Enter age’)
M = float(input(“Enter marks”))

The print function(): The print function is used to print output on screen. You may use a
combination of variables, literals (fixed value) or string constants separated y comma.
Eg. print(“your age is – “, N)
print(Name, A)
print(M * 2)
print(‘Double of marks = ‘, M*2)

---------

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy