Question

Use Python WingPersonal to compile and also please give output Math and String operations Write a...

Use Python WingPersonal to compile and also please give output

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:

'''
Execution results:
paste execution results here
'''

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

import math

#Basic Math and String operations
def f1():
a = 3**2.5

b = 2
b += 3

c = 12
c /= 4

d = 5%3

print ("Basic Math and String operations: ")
print (a)
print (b)
print (c)
print (d)
print ()

#Inbuilt python functions
def f2():
a = 5-7
b = round (3.14159, 4)
c = round (186282, -2)
d = min (6, -9, -3, 0)

print ("Inbuilt python functions: ")
print (a)
print (b)
print (c)
print (d)
print ()

#Using functions from the math module
def f3():
n = 7.6

a = math.sqrt(n)
b = math.log10(n)

print ("Using functions from the math module: ")
print (a)
print (b)
print ()

#Complex numbers
def f4():
z1 = 4 + 3j
z2 = 2 + 2j
z3 = z1*z2

print ("Complex numbers: ")
print (z3)
print ()

f1()
f2()
f3()
f4()

Output:

.Administrator: CWindows)System32\cmd.exe python op.py Basic Math and String operations: 15.588457268119896 3.0 2 Inbuilt pyt

Add a comment
Know the answer?
Add Answer to:
Use Python WingPersonal to compile and also please give output Math and String operations Write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use Python Write a script to perform various basic math and string operations. Use some functions...

    Use Python 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...

  • Use Python and need execution output Will give upvote! First Script - Working with Strings This...

    Use Python and need execution output Will give upvote! First Script - Working with Strings This script contains four parts. String Type Tests Ask the user for a string (test with "ABC123"). Use method isupper to test the string, print the result. Use method isdigit to test the string, print the result. Use method isalpha to test the string, print the result. Escape Characters within a string Use newline escape characters within a line of haiku Assign the text "Type,...

  • This problem demonstrates the use of import module. The Python programming language has many strengths, but...

    This problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules. We have given you some incomplete code; note that the very first line of that code contains an import statement as follows: import math This statement enables your program to use a math...

  • Write a Python program n_kids.py that reads the data from n_kids.txt, does some math, then displays...

    Write a Python program n_kids.py that reads the data from n_kids.txt, does some math, then displays the following: Total number of families: Total number of kids: Average number of kids per family: Maximum number of kids in a family: Minimum number of kids in a family: Extra credit (2 pts): write the above results to a different file (results.txt, not to the input file n_kids.txt) in addition to displaying them on the screen. Do not use built-in min and max...

  • Part 1: Using Idle Write a Python Script that Does the Following 1. At the top...

    Part 1: Using Idle Write a Python Script that Does the Following 1. At the top of your program, import the math library as in from math import * to make the functions in the math module available. Create a variable and assign into it a constant positive integer number of your choice. The number should be at most 10. 1 Suppose we call this variable x for this writeup document Try something like x = 4 2. Create another...

  • Python has the complex class for performing complex number arithmetic. For this assignment, you will design...

    Python has the complex class for performing complex number arithmetic. For this assignment, you will design and implement your own Complex class. Note that the complex class in Python is named in lowercase, while our custom Complex class is named with C in uppercase. A complex number is of the form a + bi, where a and b are real numbers and i is √-1. The numbers a and b are known as the real part and the imaginary part...

  • This question is from the textbook "Python for ArcGIS" by Laura Tateosian: Write a script "triangles.py"...

    This question is from the textbook "Python for ArcGIS" by Laura Tateosian: Write a script "triangles.py" that takes three arguments, the lengths of three sides of a triangle. Then define the following three functions: 1. perimeter takes three side lengths as arguments and returns the perimeter length. 2. triangleType takes three side lengths as arguments, determines if it is an equilateral triangle, an isosceles triangle, or neither. The result is returned. 3. area takes three side lengths as arguments and...

  • USE Python 1. Assign value 555 to the variable x, write code to square the variable...

    USE Python 1. Assign value 555 to the variable x, write code to square the variable x and print out the result. 2. Given a string x, write a program to check if its first character is the same as its last character. If yes, the code should output "True" . 3. We defined two variables, x = 'Python' and y = '3.0'. Write code to concatenate the two numbers (the result should be 'Python3.0').

  • Write a program to compute the area of a triangle using side-angle-side method and reports the...

    Write a program to compute the area of a triangle using side-angle-side method and reports the area of that triangle (rounded to 2 decimal places). Side-angle-side formula: ???? = 1/ 2 ?? sin(?), where a and b are two sides of the triangle, and C is the included angle. Your program must meet the following criteria to receive full marks: • Randomly generate two values between 5 and 10 (inclusive) for two sides a and b of the triangle, respectively....

  • use python please Write two new functions that simulate the addition and subtraction operators. Each of...

    use python please Write two new functions that simulate the addition and subtraction operators. Each of these functions should accept a width value as an argument (integer) and a single character (string) -- the function should then return the generated pattern. You can assume the operators will always be 5 units high. Here's some sample code: temp = plus(5, '*') print(temp) print() temp = minus(5, '*') print(temp) Which will generate ... * * ***** * * ***** Note that your...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT