0% found this document useful (0 votes)
51 views3 pages

Assignment1 Xi

Uploaded by

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

Assignment1 Xi

Uploaded by

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

Q1. Which of the following identifier names are invalid and why?

(a) Serial_no.
(b) 1st_Room
(c) Hundred$
(d) Total Marks
(e) Total_Marks
(f) total-Marks
(g) _Percentage
(h) True
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.

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 integer’s num1 and num2.
(d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string ‘last’.
(e) List Stationery is empty.
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
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)
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
Q7. Give the output of the following when num1 = 4, num2 = 3, num3 = 2
(a) num1 += num2 + num3
(b) print (num1)
(c) num1 = num1 ** (num2 + num3)
(d) print (num1)
(e) num1 **= num2 + c
(f) num1 = '5' + '5'
(g) print(num1)
(h) print(4.00/(2.0+2.0))
(i) num1 = 2+9*((3*12)-8)/10
(j) print(num1)
(k) num1 = float(10)
(l) print (num1)
(m) num1 = int('3.14')
(n) print (num1)
(o) print(10 != 9 and 20 >= 20)
(p) print(5 % 10 + 10 < 50 and 29 <= 29)
Q8. Categorise the following as syntax error, logical error or runtime error:
(a) 25 / 0
(b) num1 = 25; num2 = 0; num1/num2
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 centre 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)
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)
Q11. Write a Python program to calculate the amount payable if money has been lent on simple
interest. Principal or money lent = P, Rate = 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.
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.
Q13. Write a program to enter two integers and perform all arithmetic operations on them.
Q14. Write a program to swap two numbers using a third variable.
Q15. Write a program to swap two numbers without using a third variable.
Q16. Write a program to repeat the string ‘‘GOOD MORNING” n times. Here n is an integer
entered by the user.
Q17. Write a program to find average of three numbers.
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.
Q19. Write a program that asks the user to enter one's name and age. Print out a message
addressed to the user that tells the user the year in which he/she will turn 100 years old.
Q20. The formula E = mc**2 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.
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

You might also like