Basic Python Notes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5
At a glance
Powered by AI
The key takeaways from the document are the basics of Python programming language including data types, operators, and initialization of variables.

The different data types in Python are Integers, Floating-Point Numbers, Complex Numbers, Strings, List, Set, Tuple, and Dictionary.

The different operators in Python are Arithmetic, Relational, Logical, Assignment, Arithmetic Assignment, Bitwise, Identity, and Membership operators.

Introduction to Programming language :

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Language : Communication :

Programming Language : Device, Peripheral , Machine...

AIM : passing set of instructions to a computer to perform a task

Computerization of manual process: Project

Arithmetic : + - * /...

10 5

15

50

Language :

Low : MUL , binary , 0s 1s ... instructions (transalates) to binary's

every Machine independent machine language:

Middle : assembly language , code converteres, code transalators

High to Low, Low to High...

compilers :

interpreters :

assemblers :

c-lang: c -compliers.. Turbo c, borland c ... Dennis Ritchie...

cpp : Cpp Complier Bjarne Stroustup

java : compliled , interpreted programming language. James Gossling

python: Interpreted programming language : Guido Van Russum

Computer Scientist:

Adobe : cpp..

High : english and mnenomics (special character)

E<--------------->(E/C)<--------------------->C

passing set of instructions to a computer to perform a task using syntax rules.


syntax rules: we should communicate in such that mediator should understand our language...

Python : HIGH LEVEL, OPEN SOURCE, CASE SENSITIVE, OBJECT ORIENTED, STRONGLY TYPED
PROGRAMMING LANGUAGE..

PASSING SET OF INSTRUCTIONS TO A COMPUTER TO PERFORM A TASK

COMPUTERIZATION OF MANUAL PROCESS,..

1. SYNTAX : HOW TO WRITE..

2. ENVIRONMENT : WHERE TO WRITE A PROGRAM

HOW TO EXECUTE(GETTING RESULT)

3. API : WHAT TO USE IN THE PROGRAM (LIBRARIES)

APPLICATION PROGRAMMING INTERFACE

---------------------------------------------------------------

C-LANGUAGE : HEADER FILES

CPP : HEADER FILES

JAVA : PACKAGES

.NET : NAMESPACES

PYTHON : MODULES..

----------------------------------

ENVIRONMENT : IDLE : INTEGRATED DEVELOPMENT LEARNING ENVIRONMENT

IDE: INTEGRATED DEVELOPMENT ENVIRONMENT

Tokens:

Tokens Of python:

Pre-Requirment to write programs in python

1. identifiers : every smallest unit of a program is called an identifier , identified by the programmer,
understandable by the interpreter..

valid:

invalid :

2. keywords : reserved word : already occcupied.;. which internally consists a meaning according to
interpreter

Provided by language developers..


>>> import keyword

>>> keyword.kwlist

['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif',
'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or',
'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

>>>

3. variables:

a variable is called a name given to the memory address to store, retrive and modify a value..

Literals: programmer defines inside a program

variable, class, method, module.. (literals)

1. a literal should not start with an interger.

2. a literal shoulbe not be a keyword

3. a literal should not empty spaces in between them

4. Except _ should not use any other special characters in between the literal

5. it should be unique with in the scope of the program

6. It should be declared in a relavant way..

4. data types : python implicitly


 Integers
 Floating-Point Numbers
 Complex Numbers
 Strings
 List, Set, Tuple, Dictionary

5. operators.

1. Arithmetic

2. Relational
3. Logical

4. Assignment, Arithmetic Assignmet

5. Bitwise

6. Identity

7. Membership

1. Simple Programming / Basic Programs in Python

Initialization: Is a process of input a value to the variable for the first time

1. Initialization before interpretation


2. Initialization after interpretation

StudentMarks:

'''

Student Marks

Developed by : vamsee

Location : vybhavi gosala

Date : 21st Sep 2019

Time : 11:06 AM IST

'''

# input part...

sno = int(input("Enter student number:"))

name=input("Enter student name:")

colleg=input("Enter college name:")

campus=input("Enter campus:")

address=input("Enter address:")

mbz=int(input("Enter marks in mbz"))

mp=int(input("Enter marks in mp"))

mc=int(input("Enter marks in mc"))

mip=int(input("Enter marks in mip"))

me=int(input("Enter marks in me"))

# calc.... part

tot=mbz+mp+mc+mip+me

avg=tot/5
# disp part

print("\t\t-----------------------------------------------------------")

print("\t\t STUDENTS MARKS OF :" + colleg)

print("\t\t CAMPUS :" + campus)

print("\t\t**************" + address + "**********************")

print("\t\t-----------------------------------------------------------")

print("\t\tStudent Number : "+ str(sno))

print("\t\tName :" + name)

print("\t\tMBZ : "+ str(mbz))

print("\t\tPhysics Marks :" + str(mp))

print("\t\tChemistry Marks :" +str(mc))

print("\t\tInformatics Practices : " + str(mip))

print("\t\tEnglish :" + str(me))

print("\t\tTotal Marks :" + str(tot))

print("\t\tAverage Marks :" + str(avg))

print("\t\t-----------------------------------------------------------")

Simple Programs:

1. Arithmetic

2. Student Marks

3. Employee Pay Slip

4. Electricity bill

5. Telephone Bill

6. Movie Ticket booking

7. Train Ticket Booking

8. Temperature Conversion Celsisus to Fah , Fah to Cel

9. Average of 3 numbers

10. Product Billing

You might also like