0% found this document useful (0 votes)
7 views6 pages

Introduction To Python Programming

The document provides an overview of Python programming fundamentals, including its features, syntax, data types, variables, comments, and operators. It explains key concepts such as dynamic typing, conditional statements, and loops, along with examples of basic Python programs. Additionally, it outlines rules for naming variables and includes practical coding exercises for beginners.

Uploaded by

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

Introduction To Python Programming

The document provides an overview of Python programming fundamentals, including its features, syntax, data types, variables, comments, and operators. It explains key concepts such as dynamic typing, conditional statements, and loops, along with examples of basic Python programs. Additionally, it outlines rules for naming variables and includes practical coding exercises for beginners.

Uploaded by

amritarani483
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Ch.

01 FUNDAMENTALS OF PYTHON
 IDLE stands for integrated development learning Environment.
 Programming language: The language through which we
interact with computer. Example- C, C++,Java Python
Types of programming language:
a. High level language or human friendly language
b. Low level language or machine friendly language

FEATURES OF PYTHON
 Python is a case sensitive language-This means python treats
upper case and lower case differently.
 Python is a free and open source software-This means its
source code is available for free and changes can be done in it.
 Python is an interpreted language The code is checked and
executed line by line.
 Developer of Python is -Guido Van Rossum
 Python is a high level language-It is easy for humans to
understand.
 Python is platform independent. It can be used in various
operating systems.
SYNTAX: The rules that are followed for writing a program in Python.
INDENTATION: The space at the beginning of the code line.
SYNTAX ERROR: The error in writing a python code.
DATA TYPE: The type of data that can be stored in a variable.
[Link] DATA TYPE EXAMPLE
1 int 5,9,8
2. Float 5.5,5.0
3. boolean True/false
4. String “abc”,”5”,”5.5”
5. List [“a”,”b”,”c”]
6. Tuple (“a”,”b”,”c”)
7. Dictionary {a:”23”,b:”36”}
8. Set {“mango”,”pickle”}
VARIABLES:
The reserved memory area used to hold values in Python Program.
Example: A=”263535”
RULES FOR NAMING A VARIABLE
1. It should always be meaningful.
2. It should not be a keyword.
3. It cannot start from a number.
4. The only special symbol allowed is underscore.
DYNAMIC TYPING: We can change the data type of python variable and
can store different values.
Exmple: a=10
a=14
print(a) OUTPUT=14
COMMENTS IN PYTHON
The additional readable information which is read by the
programmers but ignored by python interpreter.
Types:
a. Single line comment: It starts with a #
b. Multi line comment: It starts with””” (triple quotes)

OPERATORS IN PYTHON
They are predefined symbols that perform operation on one
or more operands.
Types of operators

Arithmetic Assignment Logical Comparison


ARITHMETIC OPERATORS
These are used to perform common mathematical
operations.
[Link] Name and Symbol EXAMPLE OUTPUT
1 ADDITION (+) 8+3 11
2 SUBTRACTION(-) 8-3 5
3 MULTIPLICATION(*) 8*3 24
4 DIVISION(/) 8/3 2.67
5 FLOOR DIVIDE(//) 8//3 2
6 EXPONENENT(**) 8**3 512
7 MODULOUS(%) 8%3 2
Comparison operators

Logical operators

Who am I? [LOOPS]
a. I am a keyword which is used to get out of the loop. Break
b. I am a keyword which is used to skip a particular group of
instructions. Continue
c. I am also known as conditional loop. While loop
d. I am a loop in which increment testing is done in one line. For
loop
e. I am a loop which is also called counting loop. For loop
Predict the output in the following cases:
1. range(10) – 0,1,2,3,4,5,6,7,8,9
2. range(0,5)- 0,1,2,3,4
3. range(5,0,1)-no output
4. range(5,0,-1)-5,4,3,2,1
5. range(5,9)-5,6,7,8
6. range(9)- 0,1,2,3,4,5,6,7,8
7. range (2,5)-2,3,4
8. range(0,3,-1)-No output
9. range(0,3,1)-0,1,2
Conditional Statements:
Conditional statements are statements that allow our program to make decisions.
They check specific situations and respond accordingly. There are three type of
conditional statements.
1. if statement – is used to check a specific condition.
2. if …else statement – it checks the condition and provide the result in
both the situation.(True or False)
3. if…elif...else statement – it evaluates multiple conditions.
CODING SERIES
To open script mode in python we use Ctrl+N.
To save a file in python, we use .py extension
To run a python program we use F5 shortcut key.

1. Write a python program to print hello world.


print(“hello world”)
print(“This is my first python program”)
2. Write a python program to add two numbers .
a=5
b=7
sum=a+b
print(sum)
Second way :
A= int(input (“Enter your first number :”))
B= int(input(“Enter your second number :”))
sum=A+B
print(“the sum of two numbers is :”,sum)
3. Write a python program to subtract two numbers .
4. Write a python program to find product of two numbers.
5. Write a python program to find the quotient two numbers.
6. Write a python program to find the remainder when one entered
number is divided by the other.
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
remainder=a%b
print(remainder)
7. Write a program to swap two numbers.
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
print(“the original numbers are:”,a,b)
a,b=b,a
print(“the swapped numbers are”,a,b)
[Link] in python to check whether the given no is even or not.
num=int(input(“Enter any number”))
if num%2==0:
print(“Number is even")
else:
print(“Number is odd")
Q9. Write a Python Program to check whether the given year is leap or
not.
year = int(input(“Enter any Year”))
if ( year % 4 == 0):
print (“year is a leap year .")
else :
print("year is not a leap year.")
Q10. Write a Python Program to print the number series from 1 to 10.
for i in range(1,11):

print(i)
Q11. Write a Python Program to print the table of any number.
num=int(input(“Enter the number”))
for i in range(1, 11):
print(num*i)
Q12. Write a Python Program to print the number series from 1 to 5.
i=1
while i < 6:
print(i)
i=i+1
Homework-
8. WAP to calculate the simple interest when
principal, rate and time is entered by the user.

You might also like