Question

Using Python 3+ for Question P5.9

Instructions: Use one main() to call each of the functions you created. Only use one value of r and h for all the function. Ask the user for the r and h in the main() as an input, and h for all the functions. You should put the functions for areas in a separate file. ​For example, firstDigtec7ze Write a function e digits n) (returning the number of digits in the argument returning the last digit of the argument) is 1,1astDec2) is 9, and igitsC12) is 4 def middle(string) that returns a string containing t odd, or the two middle characters if returns dd a string containing the midle in le character in string if the length of string is is even. For example, middeCnide) P5.5 Write a function def repeat(string, n, delim) that returns the string string repeated n times, separated by the string delte. For example, repeat(ho, 3, . ) returns ho, ho, ho. P5.6 Write a function def countVowe1s(string) that returns a count of all vowels in the string string. Vowels are the letters a, e,i,o, and u, and their uppercase variants .. P5.7 Write a function def countWords(string) that returns a count of all words in the string string. Words are separated by spaces. For example, countwords(Mary had a little 1amb) should return 5. It is a well-known pheno words have two characters flipped, provided the first and last letter of each word are not changed. For example, P5.8 menon that most people are easily able to read a text whose I dnot gvie a dman for a man taht can olny seplla wrod one way. (Mrak Taiwn) Write a function scramble (word) that constructs a scrambled version of a given word, randomly flipping two characters other than the first and last one.Then write a program that reads words and prints the scrambled words. Write functions def sphereVolume(r) def sphereSurface(r) def cylinderVolume (r, h) def cylinderSurface(r, h) def coneVolume(r, h) def coneSurface(r, h) that compute the volume and surface area of a sphere with radius r, a cylinder with a circular base with radius r and height h, and a cone with a circular base with radius r and height h. Then write a program that prompts the user for the values of r and h, calls the six functions, and prints the results. P5.10 Write a function def readFloat (prompt)

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

from math import pi



def sphereSurface(r):
    area1=(4*pi*r**2)
    return area1

def sphereVolume(r):
    volume1=((4/3)*pi*r)**3
    return volume1

def cylinderSurface(r,h):
    area2=(2*pi*r**2+2*pi*r*h)
    return area2

def cylinderVolume(r,h):
    volume2=(pi*r**2*h)
    return volume2

def coneSurface(r,h):
    area3=(pi*r+pi*r**2)
    return area3

def coneVolume(r,h):
    volume3=((1/3)*pi*r**2*h)
    return volume3


r = float(input('Enter radius:'))
h = float(input('Enter height:'))

print('Spehere Volume:', sphereVolume(r))
print('Spehere Surface:', sphereSurface(r))
print('Cylinder Volume:', cylinderVolume(r, h))
print('Cylinder Surface:', cylinderSurface(r, h))
print('Cone Volume:', coneVolume(r, h))
print('Cone Surface:', coneSurface(r, h))

Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.2] on linux saved main.py Enter radius: 3.4 Enter height: 2.3 Spehere VolHi. please find the answer.. In case of any doubts, please ask in comments. If the answer helps you, please upvote. Thanks!

Add a comment
Know the answer?
Add Answer to:
Using Python 3+ for Question P5.9 Instructions: Use one main() to call each of the 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
  • Write a Java program which takes a string as a user input. Create 2 functions. The...

    Write a Java program which takes a string as a user input. Create 2 functions. The first function expects a string as argument and returns void. It converts all upper case characters to lower case and converts all lower case characters to upper case. It then prints out the converted string to a console. The second function also expects a string as argument and returns void. It will find first charactor that is repeated exactly 2 times in the string....

  • This is for Pycharm a python course. Can I get some help doing this and understand...

    This is for Pycharm a python course. Can I get some help doing this and understand it? ⑤ : ib tps://canvas.pasadena.edu/courses/1032754/assi a ☆ 西%N m Crowfall. Th O computing, with-c- O PHP Tutorial | SoloL ontoja. on tojav.. Write functions . def main) . def sphereVolume(r) . def sphereSurfacelr) def cylinderVolumetr. h) . def cylinderSurface(r, h) . def coneVolumefr, h) . def coneSurface(r, h) ences rations main() # call amin function at teh end In the main display, a menu...

  • You are to write two functions, printString() and testString(), which are called from the main function....

    You are to write two functions, printString() and testString(), which are called from the main function. printString (string) prints characters to std::cout with a space after every character and a newline at the end. testString (string) returns true if the string contains two consecutive characters that are the same, false otherwise. See the main() to see how the two functions are called. Some sample runs are given below: string: “hello” printString prints: h e l l o testString returns: true...

  • Guessing one password: write a function called guess that takes a string (a guessed password) as an argument and prints out matching information if its encrypted string matches any of the strings in t...

    Guessing one password: write a function called guess that takes a string (a guessed password) as an argument and prints out matching information if its encrypted string matches any of the strings in the encrypted password file. When you write the function, you may hardcode the name of the password file. Here is an example run: >>> guess("blue") Found match: blue Line number: 1 Encrypted value: 16477688c0e00699c6cfa4497a3612d7e83c532062b64b250fed8908128ed548 You will want to use the encrypt function presented in class: import hashlib...

  • Objectives Work with functions Assignment Write each of the following functions using Python. The function header MUST b...

    Objectives Work with functions Assignment Write each of the following functions using Python. The function header MUST be written as specified. In your main code test all of the specified functions. Each function must have a comment block explaining what it does, what the parameters are and what the return value is. Please remember the following two guidelines: unless the purpose of the function is to generate output DO NOT write to the screen within the function unless the purpose...

  • C++ help Format any numerical decimal values with 2 digits after the decimal point. Problem descr...

    C++ help Format any numerical decimal values with 2 digits after the decimal point. Problem description Write the following functions as prototyped below. Do not alter the function signatures. /// Returns a copy of the string with its first character capitalized and the rest lowercased. /// @example capitalize("hELLO wORLD") returns "Hello world" std::string capitalize(const std::string& str); /// Returns a copy of the string centered in a string of length 'width'. /// Padding is done using the specified 'fillchar' (default is...

  • USING PYTHON 3. For this question, you will build three helper functions and one main function....

    USING PYTHON 3. For this question, you will build three helper functions and one main function. All four functions must work together to draw the letter ‘H. Every line of code written should be inside of a function. Here are the function specifications: 1) Helper function (given): def draw_edges(symbol, width): print(symbol + " "*(width-2) + symbol) 2) Helper function: draw_H(symbol, width, height): This function will draw an "H" symbol, given the symbol, width, and height. This function must call the...

  • In C++: You are to write two functions, printString() and testString(), which are called from the...

    In C++: You are to write two functions, printString() and testString(), which are called from the main function. printString (string) prints every character in the string to std::cout with a space after every character and a newline at the end. testString (string) returns true if the string contains characters that are in sorted order, false otherwise. You may assume that all characters are lowercase and only alphabetical characters are present. See the main() to see how the two functions are...

  • 2. This question is about processing strings 2.1 [4 marks] Given a string str, we can...

    2. This question is about processing strings 2.1 [4 marks] Given a string str, we can calculate a checksum of the string by summing up the ASCII codes of the characters in the string. For example, the checksum of a string "apple" is 530, which equals to 'a' + 'p' + 'p' + 'l' + 'e' = 97 + 112 + 112 + 108 + 101. Write a function int calculate_checksum(char str[] that calculates and returns the checksum of the...

  • CODE THE FOLLOWING FUNCTIONS IN JAVASCRIPT (USE OF THE ABOVE MENTIONED IN BUILT FUNCTIONS IS NOT...

    CODE THE FOLLOWING FUNCTIONS IN JAVASCRIPT (USE OF THE ABOVE MENTIONED IN BUILT FUNCTIONS IS NOT ALLOWED) Write a function that accepts an array as argument. The function should loop through the array elements and accumulate the sum of ASCII value of each character in element and return the total. For example: function([‘A’, ‘bc’, 12]); // returns 361 which is the sum of 65 + 98 + 99 + 49 + 50 Write a function that accepts two arguments (a...

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