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

Python Programming Basics for Class 11

Uploaded by

trvvv7pbtc
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)
17 views3 pages

Python Programming Basics for Class 11

Uploaded by

trvvv7pbtc
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

Subject : Computer Science (083)

Class : 11
Chapter - 2 Python Fundamentals
Topic :- Simple Sequential Programming in Python

Instructions.
➢ Code the following program in any suitable Python IDE first.
➢ Check for expected output.
➢ Write the question, program and output in the self-study register.

1. 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)
2. Write a program in Python to accept 2 numbers and print their sum, difference, product
and quotient.
3. 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 𝑠𝑖 = 100
Amount payable = Principal + SI. P, R and T are given as input to the program.
4. Write a program in Python accept Principal amount, rate of interest and time period and
print the compound interest.
𝑟 𝑡
Hint. 𝑐𝑖 = 𝑝(1 + 100
) −𝑝
5. Write a program in Python to accept marks of a student in 5 subjects and calculate his
grand total and percentage. Assume per subject marks = 100.
6. 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
𝑥𝑦𝑧
𝑥𝑦+𝑦𝑧+𝑥𝑧
days where x, y, and z are given as input to the program.
7. Write a program to swap two numbers using a third variable.
8. Write a program to swap two numbers without using a third variable.
9. Write a program to find average of three numbers.
4 3
10. The volume of a sphere with radius r is 3
π𝑟 . Write a Python program to find the volume
of spheres with radius 7cm, 12cm, 16cm, respectively.
2
11. The area of a circle is π𝑟 and the circumference is 2π𝑟. Write a Python program to find
the area and circumference of a circle if radius is input by the user. Caution. Use
identifier PI to represent π
12. 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.
2
13. The formula 𝐸 = 𝑚𝑐 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.

Case Study-based Question


Schools use “Student Management Information System” (SMIS) to manage
student-related data. This system provides facilities for:
★ recording and maintaining personal details of students.
★ maintaining marks scored in assessments and computing results of students.
★ keeping track of student attendance.
★ managing many other student-related data.

Let us automate this process step by step.

Identify the personal details of students from your school identity card and write a
program to accept these details for all students of your school and display them
in the following format.

Documentation Tips
It is a fact that a properly documented program is easy to read, understand and is
flexible for future development. Therefore, it is important that one pays extra attention to
documentation while coding. Let us assess the documentation done by us in our case
study program and also find out whether our friends also pay similar attention to
documentation or not.

Following is a checklist of good documentation points:


➔ Objective of the program is clearly stated in the beginning.
➔ Objective of each function is clearly mentioned in the beginning of each function.
➔ Comments are inserted at the proper place so as to enhance the
understandability and readability of the program.
(Note: Over commenting doesn’t help)
➔ Variables and function names are meaningful and appropriate.
➔ Single letter variable names are not used.
➔ Program name is meaningful.
(Note: It is not proper to use your name as program name, for example, ‘raman.
py’ or ‘[Link]’ to denote your program code. It is more appropriate to use the
program name as ‘[Link]’ for a banking related program or
‘admProcess’ for an admission related program.)
➔ Program code is properly indented.
➔ Same naming conventions are used throughout the program.
(Note: Some of the naming conventions are firstNum, first_num, to denote the variable
having first number).
Let’s do this exercise for our peer’s case studies as well and provide a feedback to them.
A relevant peer feedback helps in improving the documentation of the projects. It also
helps in identifying our mistakes and enriches us with better ideas used by others.

Common questions

Powered by AI

To write a Python program to find the volume of a sphere, the formula V = 4/3 * π * r^3 can be used. First, the program should prompt the user to input the radius (r) of the sphere. Then, using the math library to access the constant π (pi), calculate the volume by plugging the radius into the formula. The program should print the calculated volume, allowing the user to verify the calculation for different input values of radius, such as 7 cm, 12 cm, and 16 cm.

A Student Management Information System (SMIS) efficiently manages and automates student-related data, including the recording and maintenance of personal student details, tracking attendance, maintaining marks scored in assessments, and computing results. This system facilitates the organized handling of this information, making data retrieval and updates more efficient and minimizing errors often associated with manual processes.

Peer feedback on program documentation is crucial in software development for several reasons. It provides a fresh perspective, which may identify ambiguities or errors that the original developer might have overlooked. Constructive feedback helps enhance the program's readability and understanding by suggesting improvements in the structure or content of documentation. Moreover, engaging with peer reviews fosters the exchange of communication practices and ideas, contributing to continuous learning and better coding standards across teams.

To swap two numbers using a third variable, store one number in the third variable, replace it with the second number, and finally use the third variable to set the first number to the second. Without a third variable, swapping can be achieved using tuple unpacking: `a, b = b, a`. The tuple method is concise and preferred for its simplicity and efficiency as it does not require additional storage, thus optimizing performance, especially in larger applications.

In a programming context, accepting mass as an input and using it to calculate energy exemplifies applied physics by implementing the equation E = mc^2. The program prompts the user for the mass, uses the speed of light constant (c ≈ 3×10^8 m/s), and computes energy (E) by multiplying the mass with the square of the speed of light. This application demonstrates the integration of theoretical physics formulae within computer programming to solve real-world problems efficiently, thereby bridging theoretical concepts and practical execution.

A Python program can automate the calculation of simple interest by using the formula SI = P * R * T / 100, where P is the principal amount, R is the rate of interest per annum, and T is the time period in years. The program should accept P, R, and T as inputs from the user. After calculating the simple interest, the program should then add it to the principal to determine the total amount payable. This approach automates the repetitive calculation process and ensures accuracy in financial computations.

A Python program for maintaining and processing student details from a school identity card should have a structured input method for capturing essential details such as student name, ID number, contact information, and class details. The program can store these inputs in a data structure like a dictionary or a database for easy retrieval and updating. It should allow querying of data based on student-specific identifiers, ensuring efficient management and processing of student information. Prioritizing key personal details ensures comprehensive data capture and storage for subsequent educational processes.

When documenting a Python program, it is important to clearly state the objective of the program at the beginning. Each function should have an explanation of its purpose preceeding it. Comments should be strategically placed to enhance understandability, but over-commenting should be avoided as it may clutter the code. Variable and function names need to be meaningful and appropriate, avoiding the use of single-letter variable names. The program’s name should be indicative of its functionality. Additionally, the program code should be properly indented and consistent naming conventions throughout the program are crucial for maintaining clarity and uniformity.

To calculate the time for three individuals working together to complete a job, the program must apply the formula for combined work rates: T (total time) = (xyz) / (xy + yz + xz), where x, y, and z are the individual times each person takes to finish the job alone. By accepting these values as input, the program calculates the total effective work rate and then determines the shortest amount of time they would need when collaborating, based on their combined efforts. This approach considers shared workloads and the efficiency of joint work output.

A Python program can determine the boiling and freezing points of water on the Fahrenheit scale by using the formula T(°F) = T(°C) × 9/5 + 32. For the boiling point, substitute T(°C) with 100°C, and for the freezing point, substitute T(°C) with 0°C. The program should then apply these substitutions and output the results, showing the boiling point as 212°F and the freezing point as 32°F.

You might also like