Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function Help
#1
Hey everyone,

I'm a graduate student taking a Python course, and while the professor is great, his homework is unreasonably difficult. Seeing as I'm a beginner at this, my classmates and I have spent well over 10 hours each on five questions, and have only answered three of them thus far. I'm looking for some tips on how to code a function that only uses integers as inputs. I've attempted nested conditionals with "if" and "elif", tried using "try" and "except", and am just not able to come up with anything that gives me an error when floats are being entered. I don't feel that this really necessitates the modulus operator or Boolean expressions, but if they help, I'm all ears. The question is as follows.



"Implement a Python function that takes two integer arguments. Your function should return the result of the division of the two integers. If the result is an integer, the return type should be an integer. If the result is a floating point number, the return type should be a floating point number.

Write a main program that requests the two integers (perform error checking for non-integer inputs). Also in the main program you should call your defined function that takes 2 arguments and displays the result of the division and the return type."



I'm not so concerned about the second one as I am with the first. Writing the function in and of itself would not be so difficult if it wasn't restricted to integers only. Any assistance that could help me get started with this would be greatly appreciated. Thank you!
Reply


Messages In This Thread
Function Help - by DansterTx - Feb-15-2020, 06:50 PM
RE: Function Help - by michael1789 - Feb-15-2020, 07:10 PM
RE: Function Help - by ibreeden - Feb-16-2020, 10:44 AM
RE: Function Help - by stullis - Feb-16-2020, 01:36 PM
RE: Function Help - by DeaD_EyE - Feb-16-2020, 03:00 PM
RE: Function Help - by DansterTx - Feb-16-2020, 07:36 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020