Basics of Python: Part I


Bikash Santra

Indian Statistical Institute, Kolkata


1. Printing and Commenting

2. Data types in python

a) Strings
b) Integers
c) Floats
d) Complex Numbers
e) Boolean

3. Input from a user

Question: Take an input from the user and check it whether the input is an integer. If the input is not an integer, please prompt the user to write an integer. Prompt again and again until user writes the integer.

4. Data type conversion

Printing format

Exercise 1: Take as input an integer and a float. Print the integer and the float. Also print their sum along with the type of the sum.

5. Operators in python

a) Arithmetic operators
b) Assignments operators
c) Relational operators
d) Logical operators
e) Bitwise operators
f) Membership operators
g) Identity operators

5.1 Arithmetic operators

5.2 Assignment operators

5.3 Relational operators

5.4 Logical operators

Practice: Prepare the truth tables for the OR and AND operations. Then you display the truth values of each operations in python.

Exercise 2: Take four numbers as input. Display whether the sum of the first two numbers is greater than or equal to the sum of the latter two numbers

5.5 Bitwise operators

5.6 Membership operators

5.7 Identity operators