Todo Tasks Week 2 Lab 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Tasks for Lab 2:

The python documentation is one of the best resources to know about nitty-gritty details in Python
Programming Language. The documentation is available as HTML pages. For today’s lab session, we
recommend you go through (start to end) a specific section of the documentation. This is available here:
https://docs.python.org/3/tutorial/introduction.html

The documentation style might look a little annoyingly structured but do spend some time in every Lab
Session going through it when you wish to understand any concept.

While you go through the above documentation, simultaneously, open the VS code IDE and practice the
concepts.

For this, Launch the Linux Lab using the below tab.

● Open the terminal in linux OS. The terminal prompt should resemble the symbol dollar $
● Go to Desktop folder by typing: cd ~/Desktop (press enter)
● Next type mkdir <your_first_name> (press enter)
● Next type cd <your_first_name> (press enter)
● Next type code . (press enter)

This will launch the Visual Studio Code IDE from the <you_first_name> directory. We are now ready to
write code here.

● After launching this, you can either open a jupyter notebook and go execute the material in the
above python documentation link. Learn how to use cells in a jupyter notebook.
● To complete the tasks listed below, open a new file and write your code and save the file as
task_A.py and execute the script from the terminal

Today's lab exercise has 5 tasks. Create and save five python scripts (that is, python program), one
corresponding to each of the tasks. Remember to follow the python style guidelines when you write the
code.

Task A

Compute Energy: Write a python script which takes input for mass (m) of an object and outputs the
energy computed using E=m*c*c*. Here, c is the speed of light, that is, c=300000000 meters per second.
The program output should look like,
Mass: <user input a number>
Energy: <output> Joules

The program should exit on typing q. Save the script as task_A.py.

Expected Learning Outcomes:

● Using variables, input(), print() in python


● Converting string to number
● Implementing power operations
● printing using f strings in print()
● Infinite loop using while True:

Use the understanding to implement the following tasks.

Task B:

Temperature Converter Script: Write a Python script named task_B.py that takes input for
temperature in Celsius and converts it to Fahrenheit using the formula F=9/5C+32. The program should
display the converted temperature in Fahrenheit. The output format should be:

Celsius: <user input a number>


Fahrenheit: <output>

Task C
Area of Circle Calculator: Write a Python script named task_C.py that takes input for the radius of a
circle and computes its area using the formula A=π*r**r, where π is a constant (use an approximation like
3.14159). The program should display the computed area. The output format should be:
Radius: <user input a number>
Area: <output> square units

Task D
Quadratic Equation Solver: Write a Python script named task_E.py that takes input for the
coefficients aa, bb, and cc of a quadratic equation ax2+bx+c=0ax2+bx+c=0 and computes its roots
using the quadratic formula. The program should display the computed roots. The output format should
be:
Coefficient a: <user input a number>
Coefficient b: <user input a number>
Coefficient c: <user input a number>
Roots: <output>

You might also like