473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

using 2 functions in addition to main program

Hello everyone this is my first post and I just started my Python class. I am stuck on an assignment...please help

I have to redo the below program (from a prior assignment) to include 2 functions in addition to main program. The first function should ask for the hours and return them to the main program. The second function should receive the hours from the main program, calculate the minutes and display them


original program code referring to question above

def main():
print"This program converts hours to minutes"
hours = input ("Please enter the number of hours to be converted: ")
minutes = hours * 60
print "The number of minutes is:", minutes
main()


what I have so far

def intromsg():
print "This program converts hours to minutes"
def gethours():
hour = input ("Enter the number of hours: ")
return score
def minutes():
total = gethours() * 60
def main():
intromsg()
gethours()
minutes()
Its probably something so simple. I think I am incorrectly getting the hours from the user to be multiplied by 60 to show minutes. Please Help
Feb 26 '08 #1
2 1592
bvdet
2,851 Expert Mod 2GB
Hello everyone this is my first post and I just started my Python class. I am stuck on an assignment...please help

I have to redo the below program (from a prior assignment) to include 2 functions in addition to main program. The first function should ask for the hours and return them to the main program. The second function should receive the hours from the main program, calculate the minutes and display them


original program code referring to question above

def main():
print"This program converts hours to minutes"
hours = input ("Please enter the number of hours to be converted: ")
minutes = hours * 60
print "The number of minutes is:", minutes
main()


what I have so far

def intromsg():
print "This program converts hours to minutes"
def gethours():
hour = input ("Enter the number of hours: ")
return score
def minutes():
total = gethours() * 60
def main():
intromsg()
gethours()
minutes()
Its probably something so simple. I think I am incorrectly getting the hours from the user to be multiplied by 60 to show minutes. Please Help
Thanks for trying to show your code structure with indention tags, but you should use code tags instead.

gethours() should return hours instead of score. score is not defined. You should assign the value returned by a function to a variable name. Pass a variable name to a function, and assign the returned value to another variable. Example (with code tags):
Expand|Select|Wrap|Line Numbers
  1. # This function returns a value
  2. def getdeg():
  3.     return float(raw_input("Enter temp in degrees F"))
  4. # This function receives an argument and returns a value
  5. def FtoC(deg):
  6.     return (deg-32)*(5.0/9.0)
  7.  
  8. degF = getdeg()
  9. degC = FtoC(degF)
  10. print degC
HTH
Feb 26 '08 #2
Thanks for your time and effort in helping me. I have completed my assignment. Thanks!
Mar 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Christopher Reeve | last post by:
Hi, I wonder if anyone could help me. I am moving accross from C to C++ and am writing a program that reads and writes data into a file. I am aware of the old C ways of doing it but am trying to...
4
by: August1 | last post by:
A handful of articles have been posted requesting information on how to use these functions in addition to the time() function as the seed to generate unique groups (sets) of numbers - each group...
10
by: Cam | last post by:
Hi all, The code below is a practical exercise and works well running in the debug environment but fails when being compiled for a release build. I believe this is because the debug environment...
13
by: agentxx04 | last post by:
Hi. Our assignment was to creat a program that can find the average, median & mode of a #of integers. Here's my program: #include<stdio.h> int main() { int item; int a, b, t, mode; int...
16
by: Martin Jørgensen | last post by:
Hi, I've made a program from numerical recipes. Looks like I'm not allowed to distribute the source code from numerical recipes but it shouldn't even be necessary to do that. My problem is...
7
by: wardm | last post by:
I have created a Dict object in a C++ App that calls (embedded) Python functions. The Dict is to be used to pass variable data between the C++ App and the python functions. However I cannot get...
21
by: asif929 | last post by:
I need immediate help in writing a function program. I have to write a program in functions and use array to store them. I am not familiar with functions and i tried to create it but i fails to...
26
by: vid512 | last post by:
hi. i wanted to know why doesn't the scanf functions check for overflow when reading number. For example scanf("%d" on 32bit machine considers "1" and "4294967297" to be the same. I tracked...
7
by: Sanchit | last post by:
My program is #include <fcntl.h> #include <unistd.h> int main(void) { int fd; ssize_t nread; char buf; /*open file for reading */
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.