You have reached the end of this topic.
In this topic, you learned how to:
Use the Python interpreter, IDLE.
Write a basic program to display the text, Hello World.
You also had a chance to practice some code using the Code Challenges. Here are some ideal solutions for
these code challenges.
Code Challenge 1
Problem Statement Ideal Solut
Sum of 21 and 62 21+62
Difference between 43 and 17 43-17
36 mod 5 36%5
Sum of 6 and 4 multiplied by 10 (6+4)*10
23 to the 5th power 23**5
An expression that will result in 19 and which includes multiplication 4*5-1
Sum of 177 mod 4 and 223 mod 5 (177%4)+(22
Difference between 3rd power of 14 and 3rd power of 13 14**3-13**3
An expression that will result in 0, which does not include multiplication and contains at least 3 arithmetic operators (27%11)+10-
An expression that includes all six arithmetic operators, addition (+), subtraction (-), multiplication (*), division (/), ((20*3+5-8)/
modulo (%) and power (**) 3**2)%4
Code Challenge 2
Problem Statement Ideal Solution
In the given code, add the text that will display the text, Hello
World! print("Hello World!")
>>> print()
Code Challenge 3
Problem Statement Ideal Solution
>>> a = input("Enter any number: ")
a = input("Enter any number: ")
Enter any number: 7
>>> b = input("Enter any number: ")
b = input("Enter any number: ")
Enter any number: 1
print(a+b)
>>> print(a+b)
71
1v
A
Progress report
Module
1. Introduction to Python
Topics
3. Salient Features of Python
1. Installation of Python
2. Using the Python Interpreter IDLE
3. Salient Features of Python
Salient Features of Python - I
1m 48s
Salient Features of Python - II
Comparing Python 2.x and Python 3.x
Summary
4. Basic Syntax of Python
Module test
© Copyright Internshala 2021
Salient Features of Python - II
Let us take a closer look at some of the salient features of Python. Click on each
button to learn more.
Enhanced Readability
Dynamic Typing
Interpreted Language
Extensible Language
Standard DB2 API
GUI Programming
Embeddable
In Python, uniform indents are used to delimit blocks of statements instead of cu
brackets like in C, C++, and Java. This enhances readability.
In C, C++, Java
if (X%2==0)
if (x%3==0)
[Link]("divisible by 2 and 3");
else
[Link]("divisible by 2 not divisible by
3");
else
if (x%3==0)
[Link]("divisible by 3 not divisible by
2");
else
[Link]("not divisible by 3 nor by 2");
}
In Python
if num%2 == 0:
if num%3 == 0:
print ("Divisible by 3 and 2")
else:
print ("Divisible by 2 not divisible by 3")
else:
if num%3 == 0:
print ("Divisible by 3 not divisible by 2")
else:
print ("Not divisible by 3 nor by 2")
Python extension modules implement new built-in object types and can call C
libraries and system calls which Python doesn’t have direct access [Link] ca
extended to work with other languages like C,C++ and Java.
A standard data connectivity API facilitates using data sources such as Oracle,
MySQL, and SQLite as a backend to a Python program for storage, retrieval, an
processing of data. Standard DB2 API is a common interface provider to all the
databases. Examples: Oracle, MySQL, DB2, etc.
GUI programming is nothing but creating buttons, text boxes, other user interact
elements and attaching function to the events like button click, key press. The
standard distribution of Python contains a Tkinter GUI kit, which is an implement
of the popular GUI library called Tcl/Tk. An attractive GUI can be constructed us
Tkinter. Many other GUI libraries like Qt, GTK, WxWidgets, etc. are also ported t
Python.
Python can be integrated with other popular programming technologies such as
C++, Java, ActiveX, and [Link] provides libraries to embed Python cod
other languages like Django can be used to embed python code in HTML etc.
Explanation: By default, the input() function in Python takes values as a string. So when we use the addition
operator, +, on these values, they are concatenated or joined rather than added. You will learn more about this
and how to actually convert the input into the required data type in the following topics.
1
A
Progress report
Module
1. Introduction to Python
Topics
3. Salient Features of Python
1. Installation of Python
2. Using the Python Interpreter IDLE
3. Salient Features of Python
Salient Features of Python - I
1m 48s
Salient Features of Python - II
Comparing Python 2.x and Python 3.x
Summary
4. Basic Syntax of Python
Module test
© Copyright Internshala 2021
Comparing Python 2.x and Python 3.x
Although the development of Python started in the late 80’s, Python 1.0 was published in January 1994. Some important
features like cycle-detecting garbage collector and Unicode support were added in Python 2.0 which was released in
October 2000. Python 3.0 was released in December 2008. It was designed to rectify certain flaws in the earlier version. The
guiding principle of Python 3 was: "reduce feature duplication by removing old ways of doing things". Python 3.0 doesn’t
provide backward compatibility. That means a Python program written using version 2.x syntax doesn’t execute under
Python 3.x interpreter. Since all the Python libraries are not fully ported to Python 3, Python Software Foundation continues
to support Python 2. The foundation has recently announced it will discontinue Python 2 support by the year 2020.
Some of the obvious differences between the Python 2.x variants and Python 3.x variants are displayed below. Click on
each button to learn more.
Print
Input
Integer division
Unicode strings
Long integer
1
A
Progress report
Module
1. Introduction to Python
Topics
3. Salient Features of Python
1. Installation of Python
2. Using the Python Interpreter IDLE
3. Salient Features of Python
Salient Features of Python - I
1m 48s
Salient Features of Python - II
Comparing Python 2.x and Python 3.x
Summary
4. Basic Syntax of Python
Module test
© Copyright Internshala 2021
Summary
You have reached the end of this topic. In this topic, you learned about:
The history of Python.
Common features of Python.
Differences between Python 2.x and Python 3.x.
1
A
Progress report
Module
1. Introduction to Python
Topics
1. Installation of Python
2. Using the Python Interpreter IDLE
3. Salient Features of Python
4. Basic Syntax of Python
Basic Syntax of Python
3m 50s
Keywords Used in Python
Indents
2m 20s
Summary
Module test
© Copyright Internshala 2021
Keywords Used in Python
False elif lambda
None else nonlocal
True except not
and finally or
as for pass
assert from raise
break global return
class if try
continue import while
def in with
del is yield
Note: Keywords are case-sensitive. You can't use them as identifiers (OR) variables.