Day 1
Day 1
In C Language
//program to Print a Message
#include<stdio.h>
#include <conio.h>
Void main()
{
Printf(“Welcome to Python Programming In Datapro, Srikakulam”);
}
In Java Programming
Public class Messages
{
Public static void main(String args[])
{
System.out.println(“Welcome to python programming in Datapro, Srikakulam”);
}
}
In Python Programming
In C Language
//program to Print a Message
#include<stdio.h>
#include <conio.h>
Void main()
{
Int a,b;
a=100;
b=200;
Printf(“The addition of ‘a’ and ‘b’ is %d”,(a+b));
}
In Java Programming
Public class Messages
{
Public static void main(String args[])
{
Int a=100;
Int b=200;
System.out.println(“The Addition of ‘a’ and ‘b’ is :”+(a+b));
}
}
In Python Programming
A=100
B=200
Print(“Sum of A and B is “,(A+B));
The name Python was selected from the TV Show "The Complete Monty Python's
Circus", which was broadcasted in BBC from 1969 to 1974.
Guido developed Python language by taking almost all programming features from
different languages
1. Functional Programming Features from C .
2. Object Oriented Programming Features from C++.
3. Scripting Language Features from Perl and Shell Script.
4. Modular Programming Features from Modula-3
Note: Internally Google and Youtube use Python coding NASA and Nework Stock
Exchange Applications developed by Python. Top Software companies like Google,
Microsoft, IBM, Yahoo using Python.
Features of Python:
1. Simple and easy to learn: Python is a simple programming language. When we read
Python program,we can feel like reading english statements. The syntaxes are very
simple and only 30+ kerywords are available. When compared with other languages, we
can write programs with very less number of lines. Hence more readability and
simplicity. We can reduce development and cost of the project.
2. Freeware and Open Source: We can use Python software without any licence and it
is freeware. Its source code is open, so that we can we can customize based on our
requirement. Eg: Jython is customized version of Python to work with Java Applications.
3. High Level Programming language: Python is high level programming language and
hence it is programmer friendly language. Being a programmer we are not required to
concentrate low level activities like memory management and security etc..
4. Platform Independent: Once we write a Python program,it can run on any platform
without rewriting once again. Internally PVM is responsible to convert into machine
understandable form.
5. Portability: Python programs are portable. ie we can migrate from one platform to
another platform very easily. Python programs will provide same results on any
paltform.
6. Dynamically Typed: In Python we are not required to declare type for variables.
Whenever we are assigning the value, based on value, type will be allocated
automatically.Hence Python is considered as dynamically typed language. But Java, C
etc are Statically Typed Languages b'z we have to provide type at the beginning only.
This dynamic typing nature will provide more flexibility to the programmer.
7. Both Procedure Oriented and Object Oriented: Python language supports both
Procedure oriented (like C, pascal etc) and object oriented (like C++,Java) features.
Hence we can get benefits of both like security and reusability etc
9. Extensible: We can use other language programs in Python. The main advantages of
this approach are:
1. We can use already existing legacy non-Python code
2. We can improve performance of the application
10. Embedded: We can use Python programs in any other language programs. i.e we
can embedd Python programs anywhere.
11. Extensive Library: Python has a rich inbuilt library. Being a programmer we can use
this library directly and we are not responsible to implement the functionality. etc...
Limitations of Python:
1. Performance wise not up to the mark b'z it is interpreted language.
2. Not using for mobile Applications
Flavors of Python:
1.CPython: It is the standard flavor of Python. It can be used to work with C lanugage
Applications
2. Jython or JPython: It is for Java Applications. It can run on JVM
3. IronPython: It is for C#.Net platform
4.PyPy: The main advantage of PyPy is performance will be improved because JIT
compiler is available inside PVM.
5.RubyPython For Ruby Platforms
6. Anaconda Python It is specially designed for handling large volume of data
processing. ...
Python Versions:
Python 1.0V introduced in Jan 1994
Python 2.0V introduced in October 2000
Python 3.0V introduced in December 2008 Note:
Python 3 won't provide backward compatibility to Python2 i.e there is no guarantee
that Python2 programs will run in
Python3. Current versions Python 3.6.1 Python 3.7.13…..
Identifiers
A name in Python program is called identifier.
It can be class name or function name or module name or variable name.
a = 10
Identifier:
1. Alphabet Symbols (Either Upper case OR Lower case)
2. If Identifier is start with Underscore (_) then it indicates it is private.
3. Identifier should not start with Digits.
4. Identifiers are case sensitive.
5. We cannot use reserved words as identifiers Eg: def=10
6. There is no length limit for Python identifiers. But not recommended to use too
lengthy identifiers.
7. Dollor ($) Symbol is not allowed in Python.
Q. Which of the following are valid Python identifiers?
1) 123total
2) total123
3) java2share
4) ca$h
5) _abc_abc_
6) def
7) if
Note:
1. If identifier starts with _ symbol then it indicates that it is private
2. If identifier starts with __(two under score symbols) indicating that strongly
private identifier.
3.If the identifier starts and ends with two underscore symbols then the identifier
is language defined special name, which is also known as magic methods.
Eg: __add__
Note:
1. All Reserved words in Python contain only alphabet symbols.
2. Except the following 3 reserved words, all contain only lower case alphabet symbols.
True
False
None
Eg:
a= true
a=True √
>>> import keyword
>>> keyword.kwlist
['False', 'None', 'True', 'and', 'as', 'assert', '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']
Ex: Adding of two numbers using python IDLE:
Open python IDLE File New File
a=10
b=20
print(a+b)
Save the file with the name: add.py
F5 – to run the python script.
This python file can be run from the windows command prompt
also.Goto the location where the file is saved.
D:\python> py add.py
'Rama Krishna'
>>> print("Rama Krishna ")
Rama Krishna
>>> "Pyton"+"Python"
'PytonPython'
>>> "python"*5
'pythonpythonpythonpythonpython'
Syntax:
print(Object(s), sep=separator, end=end,
file=sys.stdout,flush=false)
Paramter Description
Object(s) Anything that has to be printed, Converted into String before printed
sep Optional – specifies how to separate objects, if there is more than one
then
default is ‘ ‘
end Optional – Specifies what to be printed at the end,default is ‘\n’ (new
line)
file Optional - must be an object with write(string) method. If omitted it,
sys.stdout will be used which prints objects on the screen.
flush If True, the stream is forcibly flushed. Default value: False
a=10
print("The Value is:",a)
print("Appala") print("Raju")
print("Appala",end=" ") print("Raju")
ex2.py
a=5
print("a =", a, sep='00000', end='\n\n\n')
print("a =", a, sep='0', end='')
ex3.py
print ("Appala Raju")
print (5 * "\n")
print ("Coding Career Expert")