CHAPTER- 2 PYTHON
**(REMAING QUESTIONS)
What is python?
Python is a programming language. It is created by Guido Van Rossum when he was working
at centrum wiskunde & informatica. The language was released in 1991. It got its name from
a BBC comedy series. It can be used to follow both procedural approach and object-oriented
approach of programming.
What are the steps to write a python program?
To write a Python script/program, we need to open a Idle and create a new file - File >> New
File, type a sequence of Python statements for solving a problem, save it with a meaningful
name - File >> Save, and finally Run the program to view the output of the program.
What are the Datatypes?
Every value in Python has a datatype. Since everything is an object in Python programming,
data types are actually classes and variables are instance (object) of these classes.
1) Python Numbers
Number data type stores Numerical Values.
These are of three different types:
a) Integer : Integers are the whole numbers consisting of + or – sign with decimal
digits like 100000, -99, 0, 17
b) Float : A floating-point number will consist of sign (+,-) sequence of decimals
digits and a dot such as 0.0, -21.9, 0.98333328, 15.2963.
2) Sequence
String: String is an ordered sequence of letters/characters. They are enclosed in
single quotes (‘ ‘) or double (“ “).
Lists: List is also a sequence of values of any type. Values in the list are called
elements / items. These are indexed/ordered. List is enclosed in square brackets.
Example:
Dictionaries : dictionaries are defined within braces {} with each item being a pair
in the form key: value. Key and value can be of any type.
What is the use of print() function
We use the print() function to output data to the standard output device (screen).
We can also output data to a file.
An example is given below.
a = "Hello World!"
print(a)
The output of the above code will be:
Hello World!
What is Type Conversion?
The process of converting the value of one data type (integer, string, float, etc.) to
another data type is called type conversion. Python has two types of type conversion.
1. Implicit Type Conversion
2. Explicit Type Conversion
Explicit Type Conversion In Explicit Type Conversion, users convert the data type of
an object to required data type. We use the predefined functions like int(), float(),
str(), etc to perform explicit type conversion. This type of conversion is also called
typecasting because the user casts (changes) the data type of the objects.