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...
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
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....
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...
ON PYTHON Exercise 1. For each of the relational/logical expressions listed in exercise1.py determine whether the...
ON PYTHON Exercise 1. For each of the relational/logical expressions listed in exercise1.py determine whether the expression evaluates to True or False. Place a comment after each expression with the truth value and submit the updated exercise1.py file to the dropbox. For example, x = 10 y = 11 x < y # True  insert a comment after the expression x = 10 y = 11 a = 12.5 b = -5.2 x < y # True x <...
Plotting trajectories Classical Mechanics (Python) Question: In the plot, set v = 1 m/s, ω =...
Plotting trajectories Classical Mechanics (Python) Question: In the plot, set v = 1 m/s, ω = 1 1/s, and plot the trajectory for t ∈ [−6π, 6π]. Code: import numpy as np import matplotlib.pyplot as plt tx=[] for i in range(180): tx.append(i) radianConverter = np.pi/180 x_2 = [1*t*np.cos(2*np.pi*t*radianConverter) for t in tx] y_2 = [1*t*np.sin(2*np.pi*t*radianConverter) for t in tx] plt.figure(figsize=[10,10]) plt.grid(True) plt.axhline(y=0, color='k') plt.axvline(x=0, color='k') plt.plot(x_2,y_2) plt.show() What changes do I have to do in order to fit the question...
In this exercise we will practice using loops to handle collections/containers. Your job is to write...
In this exercise we will practice using loops to handle collections/containers. Your job is to write a program that asks the user to enter a sentence, then it counts and displays the occurrence of each letter. Note: your program should count the letters without regard to case. For example, A and a are counted as the same. Here is a sample run: Enter a sentence: It's a very nice day today! a: 3 times c: 1 times d: 2 times...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT