# PRIP 4.1 Sumita Arora Solutions | Class 12 Computer Science

Here are PRIP 4.1 Sumita Arora Solutions for class 12 Computer Science. To view Sumita Arora solutions for all chapters, visit here.

1. Consider the code of module welcome.py given below
`#welcome.py`
`"""welcome~~~This module contains the greeting message 'msg' and greeting function 'greet()."""msg = 'Hello'             #Global Variable                                                                        def greet(name):                # Function        print('{}, {}'.format (msg, name))`

Now carefully go through the code statements given below and figure out what will be their output. Every successive statement should assume that previous code statements hold i.e.
part (a) holds for (b); parts (a), (b) hold for (c) and so on.

(a) >>> import welcome
Answer:  blank  (if module imported successfully nothing will be printed otherwise error will get printed)

(b) >>> welcome.greet(‘Parth’)
>>>print(welcome.msg)

`Hello, ParthHello`

(c) >>> welcome. __doc__
>>> welcome.__name__

(d) >>> help(welcome)

`Help on module welcome:NAME    welcomeDESCRIPTION    welcome    ~~~    This module contains the greeting message 'msg' and greeting function 'greet().FUNCTIONS    greet(name)DATA    msg = 'Hello'FILE    c:\users\pritesh arun joshi\priteshjupyternotebook\computer tutor jupyter notebook\welcome.py`

(e) >>> import welcome as wel

Q.2: Create a module conversion.py that should contain the following:
Constant K = 273.15 #0        degree C = 273.15 kelvin
Two conversion functions
function Cels_to_Fahr(tmp)
That converts given temperature in Celsius to temperature in Fahrenheit using formula:
°F = (9 °F/5 °C)°C + 32 °F
and function Fahr To Cels(tmp)
That converts given temperature in Fahrenheit to temperature in Celsius using formula:
°C =(5 °C/9 F)(°F – 32 °F)
Add proper docstring to the module.

(a) Code for conversion.py

`#conversion.py"""conversionthis module contains functions to convert temperature from one unit to another"""k = 273.15c = 273.15def Cels_to_Fahr(tmp):    """    Cels_to_Fahr        Converts given temperature in Celsius to temperature in Fahrenheit    input: temperature in Celsius    output:temperature in Fahrenheit        """    fahr = (tmp * 9/5) + 32    return fahrdef Fahr_to_Cels(tmp):    """    Cels_to_Fahr        converts given temperature in Fahrenheit to temperature in Celsius    input: temperature in Fahrenheit     output:temperature in Celsius        """    cels = (tmp - 32) * 5/9    return cels`

(b) help(conversion)        #give its output below as per your code of conversion.py

`Help on module conversion:NAME    conversion - conversionDESCRIPTION    this module contains functions to convert temperature from one unit to anotherFUNCTIONS    Cels_to_Fahr(tmp)        Cels_to_Fahr                Converts given temperature in Celsius to temperature in Fahrenheit                input: temperature in Celsius        output:temperature in Fahrenheit        Fahr_to_Cels(tmp)        Cels_to_Fahr                converts given temperature in Fahrenheit to temperature in Celsius                input: temperature in Fahrenheit         output:temperature in CelsiusDATA    c = 273.15    k = 273.15FILE    c:\users\pritesh arun joshi\priteshjupyternotebook\computer tutor jupyter notebook\conversion.py`

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in

Subscribe
Notify of 