You are on page 1of 16

SUMMER TRAINING

PYTHON
RITIK KUMAR
ECE 2K17
CSJMA17001390099
WHAT I GIVE YOU?
1. What is Python?
2. Difference between programming and scripting
language.
3. Scope of Python.
4. Program.
5. Keywords in Python.
6. Data types in Python.
7. Loop statements in Python.
8. Conditional statements in Python.
9. Comparison between C++ and Python.
INFORMATION OF PYTHON
WHAT IS PYTHON?
Python is An interpreted as well as general purpose
programming language that is often applied in
scripting roles.

Python is programming language as well as scripting


language.

Python is a case sensitive language.


DIFFERENCE BETWEEN PROGRAMMING
AND SCRIPTING LANGUAGE
PROGRAM SCRIPTING
 A program is executed (i.e. the  A script is interpreted
source is first compiled, and the
result of that compilation is
expected).
 A "program" in general, is a  A "script" is code written in a
sequence of instructions written scripting language. A scripting
so that a computer can perform language is nothing but a type of
certain task. programming language in which
we can write code to control
another software application.
SCOPE OF PYTHON
Science
- Bioinformatics

System Administration
- Unix
- Web logic
- Web sphere

Web Application Development


- CGI
- Jython – Servlets

Testing scripts
PROGRAM
choice = input("Enter choice(1/2/3/4):")

num1 = int(input("Enter first number: "))


num2 = int(input("Enter second number: "))

if choice == '1':
print(num1,"+",num2,"=", add(num1,num2))

elif choice == '2':


print(num1,"-",num2,"=", subtract(num1,num2))

elif choice == '3':


print(num1,"*",num2,"=", multiply(num1,num2))
elif choice == '4':
print(num1,"/",num2,"=", divide(num1,num2))
else:
print("Invalid input")
KEYWORDS IN PYTHON
There are 33 keywords In Python:
False, await, else, import, None, break,
except, in, raise, True, class, finally, is,
return, and, continue, for, lambda, try, as,
def, from, nonlocal, while, assert, del,
global, not, async, elf, if, or, yield.
DATA TYPES IN PYTHON
Python has many native data types. Here are the important ones:

Booleans are either True or False.

Numbers can be integers (1 and 2), floats (1.1 and 1.2), fractions(1/2 and 2/3), or even complex
numbers.

Strings are sequences of Unicode characters, e.g. an HTML document.

Bytes and byte arrays, e.g. a JPEG image file.

Lists are ordered sequences of values.

Tuples are ordered, immutable sequences of values.

Sets are unordered bags of values.


LOOP STATEMENTS IN PYTHON
LOOP TYPE DESCRIPTION

while loop Repeats a statement or group of


statements while a given condition is
TRUE. It tests the condition before
executing the loop body.
for loop Executes a sequence of statements
multiple times and abbreviates the code
that manages the loop variable.

nested loops You can use one or more loop inside any
another while, for or do..while loop.
CONDITIONAL STATEMENTS IN
PYTHON
STATEMENT DESCRIPTION

if statements An if statement consists of a boolean


expression followed by one or more
statements.

if...else statements An if statement can be followed by an


optional else statement, which executes
when the boolean expression is FALSE.

nested if statements You can use one if or else if statement


inside another if or else if statement(s).
COMPARISON BETWEEN C++ AND PYTHON

C++ PYTHON
Compiled Programming Language Interpreted Programming
Language
Platform dependent Platform Independent

C++ is a fast compiling Due to the use of interpretor


programming language execution is slower
Code length is a bit lesser,1.5 times Smaller code length ,3-4 times less
less that java than java
Strictly uses syntax norms Use of ; is not compulsary
Example : TO PRINT “HELLO WORLD”

You might also like