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

  • 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...

  • 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...

  • PLEASE DO THIS IN PYTHON!! 1.) Goal: Become familiar with The Python Interpreter and IDLE. Use...

    PLEASE DO THIS IN PYTHON!! 1.) Goal: Become familiar with The Python Interpreter and IDLE. Use IDLE to type, compile, and run (execute) the following programs. Name and save each program using the class name. Save all programs in one folder, call it Lab1-Practices. Save all programs for future reference as they illustrate some programming features and syntax that you may use in other labs and assignments. ================================== Program CountDown.py =================================== # Program CountDown.py # Demonstrate how to print to...

  • 1. Pleae write the following code in Python 3. Also, please show all the outputs. ....

    1. Pleae write the following code in Python 3. Also, please show all the outputs. . Write a simple Rectangle class. It should do the following: Accepts length and width as parameters when creating a new instance Has a perimeter method that returns the perimeter of the rectangle Has an area method that returns the area of the rectangle Don't worry about coordinates or negative values, etc. Python provides several modules to allow you to easily extend some of the...

  • Python Script format please! 1. Write a script that takes in three integer numbers from the...

    Python Script format please! 1. Write a script that takes in three integer numbers from the user, calculates, and displays the sum, average, product, smallest, and largest of the numbers input. Important things to note: a. You cannot use the min() or max() functions, you must provide the logic yourself b. The calculated average must be displayed as an integer value (ex. If the sum of the three values is 7, the average displayed should be 2, not 2.3333). Example:...

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
ADVERTISEMENT