0% found this document useful (0 votes)
5 views6 pages

Python Fundamentals

The document provides an overview of Python programming fundamentals, including its definition, popularity, and key features. It covers installation, the Python IDLE environment, tokens, data types, and common programming errors. Additionally, it explains expressions versus statements and provides examples of valid and invalid identifiers.

Uploaded by

minirbflb85
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Python Fundamentals

The document provides an overview of Python programming fundamentals, including its definition, popularity, and key features. It covers installation, the Python IDLE environment, tokens, data types, and common programming errors. Additionally, it explains expressions versus statements and provides examples of valid and invalid identifiers.

Uploaded by

minirbflb85
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Python Fundamentals

Q – 1 What is python?
Ans. : Python is a popular middle-level programming language but not a high-level
programming language like C, C++, Java.

Q – 2 Why python is a popular programming language?


Ans.: There few reasons why python is a popular programming language, few
reasons are as following:
1. Its easy structure
2. The liveliness of code and productivity
3. No brackets in code
4. Fewer lines in code
5. Interpreted Language

Q – 3 Who developed python?


Ans.: Python was developed by Guido Van Rossum in February 1991 and then
Python Software Foundation.

Q – 4 Enlist various distribution of python programming language.


Ans. The few distributions of Python programming are as following:
1. CPython
2. PyCharm
3. Anaconda

Q – 5 Which one is the latest version of Python?


Ans. The latest version of python is Python 3.8.3

Q – 6 How to get python and install?


Ans. Python can be downloaded from www.python.org. Find the OS relevant
version for the computer and install.
The next section of Python Fundamentals for class 11 provides you the questions
related to IDLE.
Q – 7 What is Python IDLE?
Ans.: Python IDLE is a tool which allows writing python programs and provides
the output on screen after running the program. IDLE stands for Integrated
Development and Learning Environment.

Q – 8 What are the two basic modes available for writing a program in Python
IDLE?
Ans.
1. Interactive Mode: Write a few lines of code and display the output
2. Script Mode: Write large programs and allows to save the program for
future use
Q – 9 What is token?
Ans.: The smallest units of a program are known as a token.

Q – 10 Which token are used in python?


Ans.: The tokens used in python are as following:
1. Keywords
2. Literals
3. Identifiers
4. Punctuators
5. Operator

Q – 11 How to write multiple lines code in python?


or
What are the ways to write multiple lines code in python?
Ans.: Python allows two ways of writing code in multiple lines in a program:
By using double quotes and slash
>>> str = "This is an example of multiple line \
Code in \
Python"
By using triple double quotes
>>> str = """This is an example of multiple line
of code in
Python"""
In the next section of Python Fundamentals for class 11 is all about data types in
python.

Q – 12 What is the use of None in Python?


Ans.: None is a special literal used in python. It means there is no value stored in
an identifier. In other words, None means the that value is not assigned to the
identifier.

Q – 13 Identify the types of the identifier of the following: 15.859, 125, True,
‘True’, False, ‘False’, 0XDADA, 0o456, None, “None”
Ans. :
Value Type

15.859 Float

125 Integer

True Boolean

“True” String
False Boolean

“False” String

0XDADA Integer (Hexadecimal)

0o456 Integer (Octal)

None None

“None” String
Data and data types

Q – 14 Differentiate between an expression and a statement.


Ans.:
Expression Statement

It is a programming
It is a combination of letters, numbers instruction written according
and symbols to python syntax

It represents some meanings in a It perform a specific task in a


program program

It is evaluated by python It is executed by python

It produces value as a result It does not produce any value

Example: (25 + 7) / 4 Example: If x<100:


Difference between python expression and statement

Q – 15 Find out errors in the following


1
x = 090
y = 0o123
z = 0o99
print x
print(y)
print (x AND y AND z)
Ans.:
Errors:
Line 1: The variable x should initialize a number starting with 0 because python
doesn’t allow to do the same.
Line 3: When a value starts with 0o it represents the octal value and octal value is
in the range of 0 to 8. In this line, z is initialized with 99 which is out of range.
Line 4: Brackets are missing in print() function.

Line 5: print() function required comma-separated value to print.


2
p,q,r= 33, 44, 66
print(p;q;r)
Ans.: Same as above Line 5 explanation.
3
n=input("Enter no.")
sq_of_n=n*n
print(sq_of_n)
Ans.:
Runtime error inline 1 as input() function returns only string that doesn’t allow
computation. To allow computation int the statement use int(), the correct would be
like this:
n=int(input(“Enter no.:”))
4
cname=int("Enter Name:")
bill=int(input("Enter amoumnt:"))
print(cname)
print(bill)
Ans.:
In input() function is required in place of int. Line 3 and line 4 should be use with
the same indent level as other lines.

Q – 16 Which of the following are invalid identifiers?


mynum, 1tab, stu roll no, for1, for, While, while
Ans.: 1tab → Starts with a number, stu roll no → space is given in the variable name,
for and while are keywords

Q – 17 Find errors in the following code:

i) stu_marks = 90
print(Students Score stu_marks)

Ans.: There is error in line 2. The print() function accepts only variable without
function if the user needs to print any custom message, the message text should be
enclosed in double-quotes. So correct statement is anyone these:
print(stu_marks)
print(“Students Score:”, stu_marks)

ii) a = 30, b = 40
print(a;b)
Ans.: There is an error in line 1. Python doesn’t allow to assign multiple variables
like this. If its required it can be done either one of these ways:
a,b = 30, 40

a = 30
b = 40

There is an error in line 2 as well. To separate values of the variable in print, user
can use, (comma) not a semicolon, hence the correct code is like this:
print(a,b)

iii) stu_name (input=”Enter name of student:”)


print(“Student Name:”,Stu_name)
Ans.: There is error in line 1. When input() function is used in the expression, in
must come after =. Here the correction is like this:
stu_name = input(“Enter name of student:”)

iv) x, y = 30, 7
z = (int) x/y
Ans.: There is an error in the typecasting statement. In python, the statement where
type casting is required is written as a parameter in a specific data type function.

Q – 18 Find the output:

(i) a = 3
print(a+a)
Output:6

(ii) a = 5
b=a
c=b–3
print(a,b,c)
Ouptut: 5 5 2

(iii) cname = “Subodh”


bill_amount=1500
print(“Customer Name & Bill:”,cname+1500)
Output:No output due to Error, cname is string and bill_amount is integer

(iv) a = 55
b=a+4
a = 30, b + 2
print(b, a)
Ouptut: 59 (30,61) . Initially, the value of a is 55, the value of b is 55 + 4 = 59, in
third line the value of a is gain changed as mentions 30, 59 + 2= (30, 61). So in
print function first value of b is printed, then a is printed Hence ouptut is 59 (30,61)

(v) a, b = 10, 30
a, b, a = b, b + 3, a – 5
print( a, b)
Ouptut: The value of a and b is 10 and 30 respectively. After that, in next line the
value of b is assigned to a i.e 30 then b + 3 = 30 + 3 = 33 assigned to b and finally a
-5 = 10 – 5 = 5 assigned to a. So output will be 5 33.

(vi) a, b = 10 , 5
print(type(print(a+b)))
Ouptut: 15
<class ‘NoneType’>. As print() function is nested in the code gives None
output for the outer print() function. type() function returns the final data type of
the value.

*************************************

You might also like