Humanities/Arts Exam  >  Humanities/Arts Notes  >  Computer Science for Class 11  >  NCERT Solutions: Getting Started with Python

Getting Started with Python NCERT Solutions | Computer Science for Class 11 - Humanities/Arts PDF Download

Q1: Which of the following identifier names are invalid and why?
(i) Serial_no.
(ii) 1st_Room
(iii) Hundred$
(iv) Total Marks
(v) Total_Marks
(vi) total-Marks
(vii) _Percentage
(viii) True
Ans: 

(i) Serial_no.: Identifiers cannot contain special symbols.
(ii) 1st_Room: Identifiers cannot begin with a number.
(iii) Hundred$: Identifiers cannot contain special symbols.
(iv) Total Marks: Identifiers cannot contain spaces.
(v) total-Marks: Identifiers cannot contain special symbols.
(vi) True: Identifiers cannot be Python keywords.

Q2: Write the corresponding Python assignment statements: 
(a) Assign 10 to variable length and 20 to variable breadth. 
(b) Assign the average of values of variables length and breadth to a variable sum. 
(c) Assign a list containing strings ‘Paper’, ‘Gel Pen’, and ‘Eraser’ to a variable  stationery. 
(d) Assign the strings ‘Mohandas’, ‘Karamchand’, and ‘Gandhi’ to variables first, middle and last. 
(e) Assign the concatenated value of string variables first, middle and last to variable fullname. Make sure to incorporate blank spaces appropriately between different parts of names.

Ans: 
(a) length = 10
breadth = 20
OR (we can also assign values in a single line)
length , breadth = 10, 20
(b) sum = (length + breadth)/2
(c) stationery = [‘Paper’, ‘Gel Pen’, ‘Eraser’]
(d) first, middle, last = ‘Mohandas’, ‘Karamchand’, ‘Gandhi’
(e) fullname = first + ” ” + middle + ” ” + last

Q3: Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, last are already having meaningful values): 
(a) The sum of 20 and –10 is less than 12. 
(b) num3 is not more than 24.
(c) 6.75 is between the values of integers num1 and num2. 
(d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string  ‘last’. 
(e) List Stationery is empty.
Ans: 

(a) 20 + (-10) < 12
(b) not (num3 > 24)
(c) (6.75 > num1) and (6.75 < num2)
(d) (middle > first) and (middle < last)
(e) stationery == [] OR len(stationery) == 0

Q4: Add a pair of parentheses to each expression so that it evaluates to True. 
(a) 0 == 1 == 2 
(b) 2 + 3 == 4 + 5 == 7 
(c) 1 < -1 == 3 > 4  
Ans: 

(a) (0 == (1 == 2))
(b) ((2 + (3 == 4) + 5) == 7)
(c) (1 < -1) == (3 > 4)

Q5: Write the output of the following: 
(a) num1 = 4 

num2 = num1 + 1 
num1 = 2 
print (num1, num2)  
(b) num1, num2 = 2, 6 

num1, num2 = num2, num1 + 2 
print (num1, num2) 
(c) num1, num2 = 2, 3 

num3, num2 = num1, num3 + 1 
print (num1, num2, num3)
Ans: 

(a) 2, 5
(b) 6, 4
(c) NameError: name 'num3' is not defined

Q6: Which data type will be used to represent the following data values and why? 
(a) Number of months in a year 
(b) Resident of Delhi or not 
(c) Mobile number 
(d) Pocket money 
(e) Volume of a sphere 
(f) Perimeter of a square 
(g) Name of the student 
(h) Address of the student
Ans: 

(a) int data type
(b) Boolean data type
(c) int data type
(d) float data type
(e) float data type
(f) float data type
(g) String data type
(h) String data type

Q7: Give the output of the following when num1 = 4, num2 = 3, num3 = 2 
(a) num1 += num2 + num3 

print (num1) 
(b) num1 = num1 ** (num2 + num3) 

print (num1) 
(c) num1 **= num2 + num3 
(d) num1 = '5' + '5' 

print(num1)
(e) print(4.00/(2.0+2.0)) 
(f) num1 = 2+9*((3*12)-8)/10 

print(num1) 
(g) num1 = 24 // 4 // 2 

print(num1) 
(h) num1 = float(10) 

print (num1) 
(i) num1 = int('3.14') 

print (num1) 
(j) print('Bye'  == 'BYE') 
(k) print(10 != 9 and 20 >= 20) 
(l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29 >= 29/9)
(m) print(5 % 10 + 10 < 50 and 29 <= 29) 
(n) print((0 < 6) or (not(10 == 6) and (10<0)))

Ans: 
(a) 9
(b) 1024
(c) Syntax Error
(d) '55'
(e) 1.0
(f) 27.2
(g) 3
(h) 10.0
(i) ValueError
(j) False
(k) True
(l) True
(m) True
(n) True

Q8: Categorise the following as syntax error, logical error or runtime error: 
(a) 25 / 0 
(b) num1 = 25; num2 = 0; num1/num2 
Ans: 

(a) Run-time Error (ZeroDivisionError: division by zero)
(b) Run-time Error (ZeroDivisionError: division by zero)

Q9: A dartboard of radius 10 units and the wall it is hanging on are represented using a two-dimensional coordinate system, with the board’s center at coordinate (0,0). Variables x and y store the x-coordinate and the y-coordinate of a dart that hits the dartboard. Write a Python expression using variables x and y that evaluates to True if the dart hits (is within) the dartboard, and then evaluate the expression for these dart coordinates: 
(a) (0,0) 
(b) (10,10) 
(c) (6, 6) 
(d) (7,8)
Ans: 

Formula: sqrt((x2 - x1)**2 + (y2 - y1) ** 2 )
(a) (0,0) → True
(b) (10,10) → False
(c) (6,6) → True
(d) (7,8) → False

Q10: Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes as 0 degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale. 
(Hint: T(°F) = T(°C) × 9/5 + 32)
Ans: 
Program to convert degree Celsius to degree Fahrenheit is
TC=0
TF=0
TC = int(input(“Enter temperature in degree Celcius”))
TF = 9/5*TC + 32
print(TF)
If input is 100 then output will be 212.0
If input is 0 then output will be 32.0

Q11: Write a Python program to calculate the amount payable if money has been lent on simple interest.
Principal or money lent = P, Rate of interest = R% per annum and Time = T years. Then Simple Interest (SI) = (P x R x T)/ 100. 
Amount payable = Principal + SI. 
P, R and T are given as input to the program.
Ans: 

P = float(input("Enter Principal: "))
R = float(input("Enter Rate of interest: "))
T = float(input("Enter Time: "))
SI = (P * R * T) / 100
A = P + SI
print("Amount to be paid is", A)

Q12: Write a program to calculate in how many days a work will be completed by three persons A, B and C together. A, B, C take x days, y days and z days respectively to do the job alone. The formula to calculate the number of days if they work together is xyz/(xy + yz + xz) days where x, y, and z are given as input to the program.
Ans: 
x = int(input("Enter number of days for A to finish work: "))
y = int(input("Enter number of days for B to finish work: "))
z = int(input("Enter number of days for C to finish work: "))
s = (x * y) + (y * z) + (x * z)
d = (x * y * z) / s
print("Number of days required to finish task together is", d)

Q13: Write a program to enter two integers and perform all arithmetic operations on them.
Ans: 
a = int(input(“Enter First Number”))
b = int(input(“Enter Second Number”))
print(“Basic Mathematical Operations are”)
print(“Addition is “, a+b)
print(“Subtraction is “, a-b)
print(“Division is “, a/b)
print(“Product is “, a*b)
print(“Advanced Mathematical Operations are”)
print(“Modulus “, a%b)
print(“Floor Division is “, a//b)

Q14: Write a program to swap two numbers using a third variable.
Ans: 
a = int(input(“Enter First Number”))
b = int(input(“Enter Second Number”))
print(“Before Swaping Values are”)
print(“Value of First Variable a is “, a)
print(“Value of Second Variable b is “, b)
c = a
a = b
b = c
print(“After Swaping Values are”)
print(“Value of First Variable a is “, a)
print(“Value of Second Variable b is “, b)

Q15: Write a program to swap two numbers without using a third variable.
Ans: 
a = int(input(“Enter First Number”))
b = int(input(“Enter Second Number”))
print(“Before Swaping Values are”)
print(“Value of First Variable a is “, a)
print(“Value of Second Variable b is “, b)
a = a + b
b = a – b
a = a – b
print(“After Swaping Values are”)
print(“Value of First Variable a is “, a)
print(“Value of Second Variable b is “, b)
OR
a = int(input(“Enter First Number”))
b = int(input(“Enter Second Number”))
print(“Before Swaping Values are”)
print(“Value of First Variable a is “, a)
print(“Value of Second Variable b is “, b)
a, b = b, a
print(“After Swaping Values are”)
print(“Value of First Variable a is “, a)
print(“Value of Second Variable b is “, b)

Q16: Write a program to repeat the string ‘‘GOOD MORNING” n times. Here ‘n’ is an integer entered by the user.
Ans: 
n = int(input("Enter how many times you want to repeat? "))
print("GOOD MORNING" * n)

Q17: Write a program to find average of three numbers.
Ans: 
num1 = int(input(“Enter First Number “))
num2 = int(input(“Enter Second Number “))
num3 = int(input(“Enter Third Number “))
avg = (num1 +num2 + num3)/3
print(“Average of three numbers is :”, avg)


Q18: The volume of a sphere with radius r is 4/3πr3. Write a Python program to find the volume of spheres with radius 7cm, 12cm, 16cm, respectively.
Ans: 
print(“Volume of a Sphere when radius is 7cm is “, 4/3 * 22/7 * 7 * 7* 7)
print(“Volume of a Sphere when radius is 12cm is “, 4/3 * 22/7 * 12 * 12 * 12)
print(“Volume of a Sphere when radius is 16cm is “, 4/3 * 22/7 * 16 * 16 * 16)


Q19: Write a program that asks the user to enter their name and age. Print a message addressed to the user that tells the user the year in which they will turn 100 years old.
Ans: 
nm = input(“Enter Your Name”)
age = int(input(“Enter Your age”))
yr = 2021 + (100 – age) #Taking 2021 as Current Year
print(nm,” :You will turn 100 in “,yr)


Q20: The formula E = mc2 states that the equivalent energy (E) can be calculated as the mass (m) multiplied by the speed of light (c = about 3 × 108 m/s) squared. Write a program that accepts the mass of an object and determines its energy.
Ans: 
m = int(input(“Enter mass”))
print(“Energy produced by given mass is “, m * ((3 * 10 ** 8) ** 2))


Q21: Presume that a ladder is put upright against a wall. Let variables length and angle store  the length of the ladder and the angle that it forms with the ground as it leans against the wall. Write a Python program to compute the height reached by the ladder on the  wall for the following values of length and angle: 
(a) 16 feet and 75 degrees 
(b) 20 feet and 0 degrees 
(c) 24 feet and 45 degrees 
(d) 24 feet and 80 degrees
Ans: 
import math
length = int(input(“Enter the length of ladder: “))
angind = int(input(“Enter the angle in degree: “))
anginr = math.radians(angind)
sin = math.sin(anginr)
height = round(length * sin,2)
print(“The height reached by ladder “,height)

The document Getting Started with Python NCERT Solutions | Computer Science for Class 11 - Humanities/Arts is a part of the Humanities/Arts Course Computer Science for Class 11.
All you need of Humanities/Arts at this link: Humanities/Arts
33 docs|11 tests

FAQs on Getting Started with Python NCERT Solutions - Computer Science for Class 11 - Humanities/Arts

1. What is the significance of learning Python in the Humanities/Arts field?
Ans.Learning Python in the Humanities/Arts field allows students to analyze data, create digital projects, and enhance their research skills. Python's versatility facilitates the exploration of complex datasets, enabling artists and researchers to discover trends and patterns that may not be apparent through traditional methods.
2. How can Python be applied in art and literature studies?
Ans.Python can be applied in art and literature studies through various means such as text analysis, data visualization, and digital art creation. For example, students can use Python libraries to analyze literary texts for themes or patterns, or create generative art using algorithms, merging technology with creative expression.
3. What are some basic Python concepts that students should focus on initially?
Ans.Students should initially focus on basic Python concepts such as variables, data types, control structures (like loops and conditionals), functions, and lists. Understanding these foundational elements is crucial for building more complex programs and for applying Python effectively in their projects.
4. Are there any specific Python libraries that are beneficial for Humanities/Arts students?
Ans.Yes, several Python libraries are particularly beneficial for Humanities/Arts students, including NLTK for natural language processing, Matplotlib for data visualization, and Pygame for creating interactive multimedia projects. These libraries provide tools to enhance research and creative work in the Humanities and Arts.
5. What resources are available for beginners to learn Python in the context of Humanities/Arts?
Ans.Beginners can access various resources to learn Python, including online courses on platforms like Coursera or edX, tutorials on websites such as Codecademy, and books specifically aimed at using Python in the Humanities. Additionally, community forums and local workshops can provide support and networking opportunities for learners.
Related Searches

Getting Started with Python NCERT Solutions | Computer Science for Class 11 - Humanities/Arts

,

Objective type Questions

,

MCQs

,

past year papers

,

Sample Paper

,

Semester Notes

,

Summary

,

Important questions

,

Exam

,

video lectures

,

study material

,

practice quizzes

,

Extra Questions

,

Free

,

pdf

,

Getting Started with Python NCERT Solutions | Computer Science for Class 11 - Humanities/Arts

,

shortcuts and tricks

,

Viva Questions

,

ppt

,

mock tests for examination

,

Previous Year Questions with Solutions

,

Getting Started with Python NCERT Solutions | Computer Science for Class 11 - Humanities/Arts

;