In: Computer Science
please use python to solve this problem.
Math and String operations
Write a script to perform various basic math and string operations.
Use some functions from Python's math module. Generate formatted
output.
Basic math and string operations
Calculate and print the final value of each variable.
a equals 3 to the power of 2.5
b equals 2 b equals b + 3 (use +=)
c equals 12 c = c divided by 4 (use /=)
d equals the remainder of 5 divided by 3
Built-in functions abs, round, and min
Use abs, round, and min to calculate some values. These are all
Python built in functions (see: BIF ).
Print the difference between 5 and 7.
Print 3.14159 rounded to 4 decimal places.
Print 186282 rounded to the nearest hundred.
Print the minimum of 6, -9, -3, 0
Functions from the math module
Use some functions from Pythons math module to perform some
calculations.
Ask the user for a number (test with the value 7.6).
Print the square root of the number, rounded to two decimal places
(include an appropriate description).
Print the base-10 log of the number, rounded to two decimal places
(include an appropriate description)
(see https://docs.python.org/3/library/math.html).
Complex numbers
Do a calculation with complex numbers. Note that, while you might
be familiar with the notation convention commonly used within
mathematics for complex numbers (z = a + bi), Python uses the
notation convention used in electromagnetism and electrical
engineering (z = a + bj).
Assign z1 the value of 4 + 3j
Assign z2 the value of 2 + 2j
Assign z3 the value of z1 times z2
Print the value of z3
Add the following at the end of the script to show your results
OUTPUT :
CODE :
#a
a=3**2.5
print(a)
#b
b = 2
b += 3
print(b)
c=12
c/=4
print(c)
d=5%3
print(abs(5-7))
print(round(3.14159,2))
x = 186282
import math
print(int(math.ceil(x/100.0))*100)
print(min([6,-9,-3,0]))
n = float(input('Enter a number : '))
sq = math.sqrt(n)
print('Square root of ',n,' is ',sq)
print('log of ',n,' is ',math.log(n,10))
z1 = 4+3j
z2 = 2+2j
z3 = z1*z2
print(z3)