Ad Code

Responsive Advertisement

Basic Python Program - 44

Question 44: Write a Python program to create a user defined module that will ask your college name and will display the name of the college.
Download hole Program / Project code, by clicking following link:
What is the output of the following program?
import math
print math.sqrt(25)
print math.pi
print math.degrees(2)
print math.radians(60)
print math.sin(2)
print math.cos(0.5)
print math.tan(0.23)
print math.factorial(4)

It seems you are using Python 2 syntax. In Python 2, you need to use parentheses when calling functions. In Python 3, the print statement became a function, and you would need to use parentheses.
Here's the corrected Python 2 code:
import math
print math.sqrt(25)
print math.pi
print math.degrees(2)
print math.radians(60)
print math.sin(2)
print math.cos(0.5)
print math.tan(0.23)
print math.factorial(4)


The corrected Python 2 code would produce the following output:
5.0
3.14159265359
114.591559026
1.0471975512
0.909297426825
0.87758256189
0.234143362351
24
In Python 2, you can use the math module functions directly with math.function_name(). The code you provided calculates and prints various mathematical values, such as the square root of 25, the value of pi, the conversion from radians to degrees, trigonometric values, and the factorial of 4.
Programming Code:
Following code write in: BP_P44.py
# Python Module

# import Module

import Python_module

college = Python_module.College_Details("Savitribai Phule Pune University", "Pune")

college.show()      # it print the college name and address

# Thanks for Reading.
Output:

Post a Comment

0 Comments

Ad Code

Responsive Advertisement