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

Introduction to Python Basics

The document introduces basic concepts of Python programming, including keywords, identifiers, variables, and data types. It explains the Input-Process-Output (IPO) cycle in programming and provides examples of simple Python programs. Additionally, it covers different data types such as strings, lists, and tuples, along with the importance of variables and expressions.

Uploaded by

varshitachinnam1
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 views29 pages

Introduction to Python Basics

The document introduces basic concepts of Python programming, including keywords, identifiers, variables, and data types. It explains the Input-Process-Output (IPO) cycle in programming and provides examples of simple Python programs. Additionally, it covers different data types such as strings, lists, and tuples, along with the importance of variables and expressions.

Uploaded by

varshitachinnam1
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

CLASS 11: Informatics Practices

In today's session:
Introduction to Python

• We'll start with some concepts:


• Python keywords
• Python identifiers
• Python Variables

• Examples of simple Programs

• Python Data Types


To prepare tea we follow these three steps

•Step-1(INPUT) Take some raw ingredients like – water, milk, tea leaves and sugar.
•Step-2(PROCESS) Boil these ingredients for some time.
•Step-3(OUTPUT) Serve the prepared tea.
• Each program in the computer goes through
an IPO cycle

• IPO stands for “Input Process Output” cycle,


i.e. a program take some input data then
process this data and generate output for
user.
Token:

• The smallest individual unit of the program is called token.

• Every program is made up of – keywords, variables, operators,


literals etc. all of these small units of a computer program
Keywords
• Keywords of a programming language are the predefined
words.

• Here predefined means – “What action will take place on


execution of a keyword is already known to the interpreter”.
Keywords

• For each keyword the interpreter is programmed to take


necessary action.
• Each keyword has specific meaning according to which the
interpreter executes the keyword.
Identifiers
•Identifiers are the names given to the different parts of the
computer program.

•For example if a programmer creates a new function then he


provides a specific name for that function.
Variable
Variable is an identifier whose value can change.
Variables

•num = 5

•For above statement, Python will internally create a label named


“num” to a memory block

•Value of a variable can be any string for example name of a


person-“Ram”, it can be a number like - 65,500 or 125 or any
combination of alphanumeric characters.

•Variables must always be assigned values before they are used in


the program, otherwise it will lead to an error.
A sample program
#To find the sum of two given numbers

num1 = 10
num2 = 20

result = num1 + num2


A sample program
#To find the sum of two given numbers

num1 = 10
num2 = 20

result = num1 + num2

print(result)

#print function in python displays the output


A sample program
#To find the area of a rectangle

length = 10
breadth = 20

area = length*breadth

print(area)
Data types
• Data type specifies the nature of data which a variable can
hold. And according to the data type of variable we can
perform certain operations on that variable.
Data types
Data types
Sequence
Sequence

(A) String
String is a group of characters. These characters may be
alphabets, digits or special characters including spaces.
Sequence

(B) List
It is a sequence of items separated by commas and items are
enclosed in square brackets [ ]. Items may be of different
data types.
Sequence

(C) Tuple
Tuple is a sequence of items separated by commas and items
are enclosed in parenthesis ( ). Once created, we cannot
change items in the tuple.
Expressions
A small set of variables, operators, and value is known
as expression.

It seems like every line of a


program can be an
expression.
UNIT RDBMS:
Data
manupulation
using SQL
Thank you!

You might also like