Learning Journal Unit 2 CS 1101.docx - Learning Journal Unit 2 Part 1 The volume of a sphere is 4\/3\u03c0r3 where \u03c0 has the value of\"pi given in Section

Learning Journal Unit 2 CS 1101.docx - Learning Journal...

This preview shows page 1 - 4 out of 4 pages.

Learning Journal Unit 2 Part 1 The volume of a sphere is 4/3πr 3 , where π has the value of "pi" given in Section 2.1 of your textbook. Write a function called print_volume (r) that takes an argument for the radius of the sphere, and prints the volume of the sphere. Call your print_volume function three times with different values for radius. Include all of the following in your Learning Journal: The code for your print_volume function. The inputs and outputs to three calls of your print_volume . Part 2 Write your own function that illustrates a feature that you learned in this unit. The function must take at least one argument. The function should be your own creation, not copied from any other source. Do not copy a function from your textbook or the Internet. Include all of the following in your Learning Journal: The code for the function that you invented. The inputs and outputs to three calls of your invented function. A description of what feature(s) your function illustrates.
Image of page 1
Image of page 2
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 4 pages?

Unformatted text preview: Part 1 >>> import math >>> print(math.pi) 3.141592653589793 >>> def print_volume(): print ("What is the radius of the sphere? Please input:") r=float(input()) V=4/(3*math.pi*(r**3)) print (V) >>> print_volume() What is the radius of the sphere? Please input: 0.5 3.3953054526271007 >>> print_volume() What is the radius of the sphere? Please input: 15 0.00012575205380100372 >>> print_volume() What is the radius of the sphere? Please input: 5 0.0033953054526271007 >>> Part 2 >>> def invented_function(): print("a=") a=str(input()) print("b=") b=str(input()) print ("a+b="+a+b) print("x=") x=float(input()) print("y=") y =float(input()) print("x/y=") z=x/y print (z) >>> invented_function() a= 7 b= 3 a+b=73 x= 1 y= 10 x/y= 0.1 >>> invented_function() a= Greatest b= Ever a+b=GreatestEver x= 18 y= 6 x/y= 3.0 >>> invented_function() a= Tom b= Bardy a+b= Tom Brady x= 6 y= 6 x+y= 12.0 >>>...
View Full Document

  • Spring '18
  • Jane

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors