Question

Python Programming 1. Write the following Python expressions in mathematical notation. a. dm = m *...

Python Programming

1.

Write the following Python expressions in mathematical notation.

a.

dm = m * (sqrt(1 + v / c) / sqrt(1

-

v / c)

-

1)

b.

volume = pi * r * r * h

c.

volume = 4

* pi * r ** 3 / 3

d.

z = sqrt(x * x + y * y)

2.

What are the values of the following expressions? In each line, assume that

s = "Hello"

t = "World"

a.

len(s) + len(t)

b.

s[1] + s[2]

c.

s[len(s) // 2]

d.

s + t

e.

t + s

f.

s * 2

3.

Write a program that prompts the user to input an integer that represents cents. The program will then calculate the smallest combination of coins that the user has. For example, 27 cents is 1 quarter,0 nickle, and 2 pennies.

That is 27=1*25+0*5+2*1

Homework Answers

Answer #1
1.
a.
import math
dm = m * (math.sqrt(1 + v / c) / math.sqrt(1-v / c)-1)

b.
import math
volume = math.pi * r * r * h

c.
import math
volume = (4 * math.pi * r ** 3) / 3

d.
import math
z = math.sqrt(x * x + y * y)

================================

2.
s = "Hello"
t = "World"

a.
len(s) + len(t) is 10

b.
s[1] + s[2] is 'el'

c.
s[len(s) // 2] is 'l'

d.
s + t is 'HelloWorld'

e.
t + s is 'WorldHello'

f.
s * 2 is 'HelloHello'

================================

3.
amount = eval(input("Enter amount in cents: "))
print((amount//25),"quarters,",end=" ")
amount = amount % 25
print((amount//10),"dimes,",end=" ")
amount = amount % 10
print((amount//5),"nickles,",end=" ")
amount = amount % 5
print(amount,"pennies.")

Know the answer?
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
Similar Questions
(Python Programming) Write a program that prompts a user for a positive integer and then uses...
(Python Programming) Write a program that prompts a user for a positive integer and then uses a loop to calculate and display the sum of specific fractions as follows: Let's say the user enters 5, then your program will compute: 1/5 + 2/4 + 3/3 + 4/2 + 5/1 which is 8.7.
Using C++, Python, or Java, write a program that: In this programming exercise you will perform...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform an empirical analysis of the QuickSort algorithm to study the actual average case behavior and compare it to the mathematically predicted behavior. That is, you will write a program that counts the number of comparisons performed by QuickSort on an array of a given size. You will run the program on a large number of arrays of a certain size and determine the average...
Using python, please do the following. 1. Write regular expressions. (a) Capture any string that contains...
Using python, please do the following. 1. Write regular expressions. (a) Capture any string that contains at least three digits. (b) Capture any word that starts with one lowercase character, and either ends with two digits or with three vowels. 2. Given the following statements: string = """ Supreme executive power derives from a mandate from the masses , not from some farcical aquatic ceremony .""" words = string . split () Write a short program, using the re module,...
write a program in python for following x = { 'a' : 1 , 'b':2 ,...
write a program in python for following x = { 'a' : 1 , 'b':2 , 'c':3, 'd':4 } For the following key,value pairs of dictionary display those which are even values i.e for which the value is even. i am trying like this but getting confused. (k:v for k,v in x.items() if v%2 != 0
Python programming Write a program that prompts the user to input the three coefficients a, b,...
Python programming Write a program that prompts the user to input the three coefficients a, b, and c of a quadratic equationax2+bx+c= 0.The program should display the solutions of this equation, in the following manner: 1. If the equation has one solution, display ONE SOLUTION:, followed by the solution, displayed with4 digits printed out after the decimal place. 2. If the equation has two real solutions, display TWO REAL SOLUTIONS:, followed by the two solutions, each displayed with4 digits printed...
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED....
WRITE USING PYTHON PROGRAMMING THE CODE GIVEN BELOW HAS SOME ERRORS WHICH NEED TO BE SOLVED. ALSO THE 2 POINTS MENTIONED BELOW SHOULD BE PRESENT IN THE CODE Write a script that calculates the 3 longest words of a text stored in a file and print them from the longest to the smaller of the 3. Please note: 1. The name of the file is word_list.csv and it doesn’t need to be asked to the user (meaning the name will...
In C programming, Thank you Write a program to compute the area of a circle. You...
In C programming, Thank you Write a program to compute the area of a circle. You have to write a complete “C” program that compiles and runs in Codeblocks. Program requirements: 1. Declare the variables needed: radius (r) and area (yourLastName). 2. Calculate and print the area of each circle. 3. The program MUST prompt the user for a new radius (r) over and over until the user types -1. 5. Use the type double for all decimal numbers. 6....
Write a program in python that computes the date of Easter Sunday for a specified year....
Write a program in python that computes the date of Easter Sunday for a specified year. 1.Ask the user for the year (such as 2001). Save the year in y. 2. Divide y by 19 and call the remainder a. Ignore the quotient. 3.Divide y by 100 to get a quotient b and a remainder c. 4.Divide b by 4 to get a quotient d and a remainder e. 5. Divide 8 * b + 13 by 25 to get...
1.Write a function which takes a string that contains two words separated by any amount of...
1.Write a function which takes a string that contains two words separated by any amount of whitespace, and returns a string in which the words are swapped around and the whitespace is preserved. Hint: use regular expressions where \s detects the whitespaces in a string. Example: given "Hello     World", return "World         Hello" 2.Pandas exercises: Write a python program using Pandas to create and display a one-dimensional array-like object containing an array of data. Write a python program using Pandas to...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features the design of a calculator program using pseudocode and a Python program that uses a list and functions with variable scope to add, subtract, multiply, and divide. Open the M4Lab1ii.py program in IDLE and save it as M4Lab1ii.py with your initials instead of ii. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT