LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-11-2011, 04:29 PM   #1
JAPANBOY
LQ Newbie
 
Registered: Jun 2011
Location: somewhere over the rainbow
Posts: 11

Rep: Reputation: Disabled
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!!!
 
Old 07-11-2011, 04:45 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,217

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
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.

Last edited by dugan; 07-11-2011 at 05:25 PM.
 
2 members found this post helpful.
Old 07-11-2011, 06:28 PM   #3
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
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.

Last edited by bgeddy; 07-11-2011 at 06:31 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Python 2.6 dependencies error installing python-sqlite2-2.5.5-1.1.i586.rpm jmp007 Linux - Newbie 1 02-11-2011 11:05 AM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
LXer: Review: Programming in Python 3: A Complete Introduction to the Python Language LXer Syndicated Linux News 0 01-26-2009 04:50 AM
python update - Unable to load GTK2 Python bindings: No module named gtk itpedersen Linux - Software 2 10-03-2008 03:44 AM
LXer: Move to python 2.4 / Changing the packaging style for python packages LXer Syndicated Linux News 0 06-13-2006 07:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration