Join Our WhatsApp Group Join Subscribe Now!

BPP (313011) Practical No.10: Create python program to demonstrate use of math built-in function

BPP (313011) Practical No.10: Create python program to demonstrate use of math built-in function

 BPP (313011) Practical No.10: Create python program to demonstrate use of math built-in function

Python includes multiple math-related and string-related functions. The math built-in module is used to perform various mathematical calculations, such as numeric, trigonometric, logarithmic, and exponential calculations. The Python string module provides several constants that are useful for checking to see if a character, slice, or string contains letters, digits, symbols, etc. To use these modules, we need to import the module into our code.

Practical related Questions

1. Write the output of the following program.

import math
x = math.ceil(1.4)
y = math.floor(1.4)
print(x)
print(y)

Answer:

2
1

2. Write the output of the following program.

for i in range (3,12,2):
print("a".upper())

Answer:

A 
A 
A 
A 
A

3. The function pow(x,y,z) is evaluated as:

a) (x**y)**z
b) (x**y) / z
c) (x**y) % z

Answer:

c) (x**y) % z

Exercise

1. Write a Python script to calculate factorial of a number using math built-in function.

Answer:


2. Bill is 30 m away from a church. The angle of elevation when he looks at the top of the church’s spire is 45°. If Bill’s eye level is 1.5 m above the ground, how tall is the church spire. (Use math built-in function)

Answer:



3. Write a Python script that accepts a string in lowercase letters and convert into upper case letters using string module.

Answer:



4. Write a Python script that uses find() function to search for the “language” string from the original string "Python is a powerful language" and returns its index in the Python string.

Answer:





About the Author

Hi everyone, I'm Suraj Diware, and I'm passionate about helping students succeed in MSBTE programs. This blog is dedicated to providing clear and concise explanations of MSBTE curriculum topics, along with practical tips and resources to sup…

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.