Question

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 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 ''' Print and staple together the script, including the execution results, and turn it in.

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

# your code goes here
import math
a = 3 ** 2.5
print("Value of a is {}".format(a))

b = 2
b += 3
print("Value of b is {}".format(b))

c = 12
c /= 4
print("Value of c is {}".format(c))

d = 5 % 3
print("Value of d is {}".format(d))

print("Difference between 5 and 7 is {} ".format(abs(5 - 7)))

print(round(3.14159, 4))

print(round(186282, -2))

print("minimum of the numbers 6, -9, -3, 0 is {}".format(min([6, -9, -3, 0])))

number = float(input("Enter a number"))
print("Square root of the number to two decimal places is {}".format(round(math.sqrt(number), 2)))

print("Log base-10 of the number to two decimal places is {}".format(round(math.log10(number), 2)))

z1 = complex(4, 3)
z2 = complex(2, 2)
z3 = z1 * z2

print("Z3 is {}".format(z3))


OUTPUT

Add a comment
Know the answer?
Add Answer to:
Use Python Write a script to perform various basic math and string operations. Use some functions...
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 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...

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

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

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

  • all should be solved using the basic data types, assignments, math operations, conditionals, loops, string functions,...

    all should be solved using the basic data types, assignments, math operations, conditionals, loops, string functions, user defined functions, lists, tuples, file input/output and dictionaries. Please use python Problem 3 (lab4_p3.py) An older, existing campus system has been previously storing student grades in list form with the following format: grades_list - [[student_name_1, student_1_id, student_1_midterm, student_1_final], (student_name_2, student_2_id, student_2_midterm, student 2_final], ... 1 In other words, a list of lists, where each member list contains the student's name, ID, midterm exam...

  • Please use Java to write the program The purpose of this lab is to practice using...

    Please use Java to write the program The purpose of this lab is to practice using inheritance and polymorphism. We need a set of classes for an Insurance company. Insurance companies offer many different types of policies: car, homeowners, flood, earthquake, health, etc. Insurance policies have a lot of data and behavior in common. But they also have differences. You want to build each insurance policy class so that you can reuse as much code as possible. Avoid duplicating code....

  • please use python and provide run result, thank you! click on pic to make it bigger...

    please use python and provide run result, thank you! click on pic to make it bigger For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...

  • C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) L...

    C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...

  • If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but...

    If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own. INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, the...

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