Python Fundamentals
Python Fundamentals
5.What is the difference between Interactive mode and Script Mode in Python?
Ans: In interactive mode, one command can run at a time and commands are
not saved. Whereas in Script mode, we can save all the commands in the form of
a program file and can see output of all lines together.
7.Write Instructions in python to get the following result: (Do it in both interactive
mode and script mode)
I am a student of KV Barabanki
I live in Barabanki
And I love Barabanki.
Barabanki is 20 KM away from Lucknow
This Place is famous for Dewa Sharif
Ans: In Interactive Mode-
>>> print("I am a student of KV Barabanki \nI live in Barabanki \nAnd I love
Barabanki\n\n Barabanki is 20
KM away from Lucknow\n This Place is famous for Dewa Sharif")
In Script Mode- print("I am a student of KV Barabanki \n I live in Barabanki
\nAnd I love Barabanki\n\n Barabanki is 20 KM away from Lucknow\n This
Place is famous for Dewa Sharif") (save this code to a file and then run the
file)
13.What are literals in Python? How many types of Literals allowed in Python?
Ans: Literals: Python comes with some built-in objects. Some are used so often
that Python has a quick way to make these objects, called literals.
The literals include the string, Unicode string, integer, float, long, list, tuple and
dictionary types.
14.How many types of sequences are supported in Python?
Ans: Three Types of Sequences are supported in python:
(i) String
(ii) List
(iii) Tuple
18.What are operators? What is their function? Give examples of some unary and
binary operators.
Ans: “Operators are those symbols used with operands, which tells compiler which
operation is to be done on operands, in other words – ―operators are tokens that
trigger some computation/action when applied to variables and other objects in an
expression.
Operators are of following types:
▪ Unary operators like (+) Unary Plus, (-) Unary Minus, not etc.
Output:
Hari , you are 18 now but You will be 19 next year
23.Write a Program to obtain temperature in Celsius and convert it into Fahrenheit
using formula –
C X 9/5 + 32 = F
24.Predict output:
Output: 4 6 8
25.Write a program, to print the area of circle when radius of the circle is given by
user.
26.Write a program, to print the volume of a cylinder when radius and height of
the cylinder is given by user.
27.Write a program, that asks your height in centimeters and converts it into foot
and inches.
28.Write a program, to find area of a triangle.