i am asking an user to enter time, then add the time together to get a new times -
def main():
-
origTime = raw_input("Enter clock time (hh:mm): ")
-
hrsAdd = input("Enter hours to add: ")
-
hhmm = origTime.split (':')
-
hh = int(hhmm[0])
-
mm = hhmm[1]
-
hourSum = "origTime + hrsAdd"
-
print "New time: %d:%s" % (hourSum, mm)
8 1598
i am asking an user to enter time, then add the time together to get a new times -
def main():
-
origTime = raw_input("Enter clock time (hh:mm): ")
-
hrsAdd = input("Enter hours to add: ")
-
hhmm = origTime.split (':')
-
hh = int(hhmm[0])
-
mm = hhmm[1]
-
hourSum = "origTime + hrsAdd"
-
print "New time: %d:%s" % (hourSum, mm)
Very nice. Nicer with CODE tags, though.
i am asking an user to enter time, then add the time together to get a new times -
def main():
-
origTime = raw_input("Enter clock time (hh:mm): ")
-
hrsAdd = input("Enter hours to add: ")
-
hhmm = origTime.split (':')
-
hh = int(hhmm[0])
-
mm = hhmm[1]
-
hourSum = "origTime + hrsAdd"
-
print "New time: %d:%s" % (hourSum, mm)
Why are you using quotes around the "origTime + hrsAdd". Are you having any problems?
is not working,
i could only the hours but is not adding together and get the result
is not working,
i could only the hours but is not adding together and get the result
First you need to remove the quotes around the hourSum line. You wrote origTime + hrsAdd. That doesn't work because the variable "origTime" is a string. You want to add hours to "origTime", am I correct?
If so I believe you have to add "hrsAdd" to "hh". Then you would get:
Does that help?
i am asking an user to enter time, then add the time together to get a new times -
def main():
-
origTime = raw_input("Enter clock time (hh:mm): ")
-
hrsAdd = input("Enter hours to add: ")
-
hhmm = origTime.split (':')
-
hh = int(hhmm[0])
-
mm = hhmm[1]
-
hourSum = "origTime + hrsAdd"
-
print "New time: %d:%s" % (hourSum, mm)
My friend, ilikepython is correct. You can copy and paste this correction into your editor: -
def main():
-
origTime = raw_input("Enter clock time (hh:mm): ")
-
hrsAdd = input("Enter hours to add: ")
-
hhmm = origTime.split (':')
-
hh = int(hhmm[0])
-
mm = hhmm[1]
-
hourSum = origTime + hrsAdd
-
print "New time: %d:%s" % (hourSum, mm)
bvdet 2,851
Expert Mod 2GB
is not working,
i could only the hours but is not adding together and get the result
To convert a time string in this format "hh:mm:ss" to a value: - >>> s = "12:45:45"
-
>>> dd = dict(zip([1, 60, 360], [float(i) for i in s.split(':')]))
-
>>> sum([f/v for v, f in dd.items()])
-
12.875
-
>>>
So: - def hms(s):
-
dd = dict(zip([1, 60, 360], [float(i) for i in s.split(':')]))
-
return sum([f/v for v, f in dd.items()])
-
-
def main():
-
origTime = raw_input("Enter clock time (hh:mm): ")
-
hrsAdd = raw_input("Enter hours to add (hh:mm): ")
-
return hms(origTime) + hms(hrsAdd)
-
-
print main()
there's a similar situation in this recent thread . you can get some ideas there.
thank your all those posts.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: hokiegal99 |
last post by:
I don't understand how to use a loop to keep track of user input. Could
someone show me how to do what the program below does with a loop?
Thnaks!
----------------------------
#Write a...
|
by: tom |
last post by:
Hey All,
I have a subform that shows records in datasheet view, all sorted
nicely.
When I right-click on any column and choose "Sort Ascending", Access
pops up an "Enter Parameter" box for a...
|
by: Marius Kaizerman |
last post by:
Hi,
I have a report that is a based on a query.
One of the fields in the query is "time of sale", which is a date
field that holds the sales dates (day,month,year).
I want to use that field as...
|
by: Robin S. |
last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope
I've done a better job of explaining myself below.
I am trying to produce a form to add products to a table (new...
|
by: anand |
last post by:
Hi,
I have an Access 2000 database, which contains some native tables,
and some linked tables which belong to an ORACLE database, through
ODBC.
Using VB.NET, I am trying to fetch some data by...
|
by: Andrew Gentile |
last post by:
Hello,
I would like to find a way of using scanf() and the Enter key to
have user-controlled program flow. Currently, I have a couple of
lines in my program which serves as a pause in the...
|
by: td0g03 |
last post by:
Hello, I am new to C and I am new to English. I not sure what palindromes mean. I don't know exactly what my teacher wants me to do. If someone could explain it to me in a different way that would be...
|
by: no1zson |
last post by:
I have been reading through many of the array questions and cannot find one that addresses my issue. Maybe someone can help me out.
Same story, I am learning Java and have just written a CD...
|
by: vovan |
last post by:
I have set of controls (Textboxes, checkboxes etc) along with the Grid on
Windows Form.
I use BindingSource to populate both Grid and the set of Controls. User
selects the record in the grid and...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |