Retired
CIS 122 #5 Functions and Return Values (retired)
27CIS 122
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
I got everything fixed but Unit Tests for calculate_volume Argument is Real: '523.5987666666666' should equal '523.598766667' Argument is String: '33510.321066666664' should equal '33510.3210667' Test Passed
I'm confused on what's going on here. Why it's saying my argument is string and should equal the number that is rounded. A few more are:
Integration Tests for input_radius_of_sphere -> calculate_volume Test Passed Return result from calculate_volume: '1436.7550157333335' should equal '1436.75501573' Test Passed Test Passed Test Passed Test Passed
Integration Tests for calculate_volume -> output_volume Argument is Real: 'The volume of a sphere with radius 15.3 is: 15002.474399373603' should equal 'The volume of a sphere with radius 15.3 is: 15002.4743994' Test Passed Test Passed
System Tests for calculate_volume_of_sphere Test Passed First run, output: 'The volume of a sphere with radius 3.6 is: 195.43219246080002' should equal 'The volume of a sphere with radius 3.6 is: 195.432192461' Test Passed Second run, output: 'The volume of a sphere with radius 6.9 is: 1376.0552579112002' should equal 'The volume of a sphere with radius 6.9 is: 1376.05525791' Test Passed Third run, output: 'The volume of a sphere with radius 4.2 is: 310.3390833984001' should equal 'The volume of a sphere with radius 4.2 is: 310.339083398'
I'm confused
The radius parameter in calculate_volume is a float. So, be sure to use float(radius) in your calculation.
The following section of code is not correct:
x_print(output_volume(5.0, calculate_volume(5.0)))
x_print(output_volume("10.0", calculate_volume("10.0")))
x_print(output_volume(15, calculate_volume(15)))
In order to pass the tests the section should read as follows:
output_volume(15.3, calculate_volume(15.3))
output_volume("30.0", calculate_volume("30.0"))
output_volume(15, calculate_volume(15))
There are absolutely no checks on function invocation.
What, you say you don't know how to do that? Learn some basic Python metaprogramming first. It's perfectly doable.
There are mistakes in the CALCULATE VOLUME OF A SPHERE integration test drivers.
x_print(output_volume(15.3, calculate_volume(15.3))) x_print(output_volume("10.0", calculate_volume("10.0"))) x_print(output_volume(15, calculate_volume(15)))
should be
output_volume(15.3, calculate_volume(15.3)) output_volume("30.0", calculate_volume("30.0")) output_volume(15, calculate_volume(15))
Thank you! I was really beating my head against the wall on this one. Before changing these test statements, the program kept printing a value of "None". When I changed it to what you suggested though it worked.
Thanks!
I'm having a weird error on the last test. My error message is that the system test call on interactive_add_numbers() is invalid syntax. I copied and pasted my code from here to an IDE and it seemed to work fine in there, so I don't know what the problem here would be. I rechecked the name of my function definition and it seems to be correct.
There is an issue on "Integration Tests for calculate_volume -> output_volume"
expectation: test.it("Integration Tests for calculate_volume -> output_volume") test.assert_equals(print_output[25], "The volume of a sphere with radius 15.3 is: 15002.4743994", "Argument is Real") test.assert_equals(print_output[26], "The volume of a sphere with radius 30.0 is: 113097.3336", "Argument is String") test.assert_equals(print_output[27], "The volume of a sphere with radius 15.0 is: 14137.1667", "Argument is Integer")
tests in code:
Then, we'll "integration test" that the units work together:
...
x_print(output_volume(5.0, calculate_volume(5.0))) x_print(output_volume("10.0", calculate_volume("10.0"))) x_print(output_volume(15, calculate_volume(15)))
Are we expected to change the values of the tests or to change the expected value in the testcases?
I think there is a mistake in testcases, passes 70 tests, everything is ok but throws "You didn't use all the inputs!"? So i took you expected output (instead of my code), inserted it into the editor and same result... So in my opinion something is wrong?! But don't know why i can see "3 Solutions and 4 Upvotes"?
The test cases check not only that you have the correct output, but that you've called input the correct number of times to match the pseudocode. Are you actually using the input function everywhere that the pseudocode says Input ?
Yes... did it as described and requested... But at least i changed it and tested with your output results (converted to "x_print" commands)... so now my real solution is deleted (closed this kata/editor)... I think generally it's a very nice series of katas for learning, but each kata is a little bit too long (in my opinion;-)), too much text (for easy circumstances) and thereby too many possibilities to loose view and "concentration" and the overview of testcases (somtimes around 200 lines)...
I don't under stand the kata at Line 289: output_volume(5.0, 10.0) # Not really the correct answer, just testing output output_volume("10.0", "30.0") # Not really the correct answer, just testing output
Changed 10.0 to 20.0 in the line above to get it to work. Don't think that is right.
output_volume(15, 50) # Not really the correct answer, just testing output
If I change the second line as described, it passes this and then the next set is messed up. Are we supposed to be changing these? I don't think the errors are supposed to be correct. Not sure what is expected here.
I can't get to the rest of the kata without getting passed this part. Any input would be greatly appreciated.
The initial solution didn't match the test case, so I fixed it. This works, if everything else is correct: