LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   need help in python (https://www.linuxquestions.org/questions/programming-9/need-help-in-python-891161/)

JAPANBOY 07-11-2011 04:29 PM

need help in python
 
i need to make a code that i get hours and minutes for both 2 tasks and when i add it i get days and hours and minutes both seperate and the total time is both tasks

so i just dont know how i tell it them that

1day=24hours

24hours=1440 minutes


import math

hours=int(input("enter number of hours for 1st task:"))
minutes=int(input("enter number of minutes for 1st task:"))
hours1=int(input("enter number of hours for 2nd task:"))
minutes2=int(input("enter number of minutes for 2nd task:"))


hours+hours1=24hours2


any suggestions ?


thanks!!!

dugan 07-11-2011 04:45 PM

I told you to look at the datetime module. I even told you exactly what you need from it. If you'd bothered to even click on the link that was given to you, you wouldn't need to ask this. It disgusts me that you would tell yourself that you want to learn how to program, and then display such an unbelievable level of laziness.

Here is your code:

Code:

from datetime import timedelta

# the code you wrote above goes here

time1 = timedelta(hours=hours, seconds=minutes * 60)
time2 = timedelta(hours=hours1, seconds=minutes2 * 60)

total = time1 + time2

print total

EDIT: The identify of the person who rated this "not helpful" is obvious. Let me tell you, JapanBoy, that punishing people for helping you is not how you advance.

bgeddy 07-11-2011 06:28 PM

Yet again this happens.

JAPANBOY - not wishing to sound too hard but I very much must agree with dugan here. I once, answered your query with a fix that explained, should have fixed and hopefully explained your programming problem - you ignored it with no reply. Maybe I'm getting the wrong end of the stick here but often your posts then seem to not follow up on replies and learn by them. This is a very quick way to become ostracized by everyone and not receive any guidance. Not a good thing.

The community here works from decent folk offering advice, without any recompense, to anyone asking for help in the learning process. Everyone, however, expects that free advice to be noted and maybe even taken or at least discussed or acknowledged. After all, that's how "a community" works Take it from me your attitude is alienating people and doing you harm in that you are missing out on any educational discussions that may, and often do, ensue.

It seems to me you are missing the whole point of how these forums work and are just looking for someone else to do your work for you and offer some sort of "magic bullet" to your learning.

This interactive way of adding to the common knowledge is very easy to get into but if you are not willing to play by the rules and just expect others to do all your work, and some how "magically absorb this education" then it won't work for you. Also it won't really help you at all. Any learning process needs the involvement of the student and is best with the involvement of the tutor as well - something you get here automatically by the nature of the medium.

It's very simple, there are on this and the related Forums, a great deal of very knowledgeable people who can help in your enlightenment and do so freely until perhaps your reputation reveals your true bad nature. Don't mess up this opportunity to advance via communication.

Perhaps I may mean seem too judgemental as, judging by your prior posts, you appear to want to learn how to program your machine and are not just "looking for a fix" for a particular problem. I'f I'm right then my prior words are even more relevant as you are missing what's to be gained via this medium.


All times are GMT -5. The time now is 02:26 PM.