473,503 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Boolean function

1 New Member
As homework, I am to write a scrip that can determine if one integer is factor of another. I define the input x and y as follow;
Expand|Select|Wrap|Line Numbers
  1. def main():
  2. x = input ("What is the integer? ")
  3. y = input ("Enter another integer: ")
  4.  
  5. def isfactor (x, y):
  6.    if x % y == 0:
  7.  
  8.       print y, "is a factor of x."
  9.  
  10.   else:
  11.      print y, "is not a factor x."
  12.  
  13. main()
  14.  
For some reason the program only interprets up to the input parts and left the rest out. That is, when I run the program in shell, it prompts me to enter the integers and stop there. Can any body tell me why? your help will be greatly appreciated. Thank you very much.
Feb 6 '07 #1
3 1715
bartonc
6,596 Recognized Expert Expert
As homework, I am to write a scrip that can determine if one integer is factor of another. I define the input x and y as follow;
Expand|Select|Wrap|Line Numbers
  1. def main():
  2. x = input ("What is the integer? ")
  3. y = input ("Enter another integer: ")
  4.  
  5. def isfactor (x, y):
  6.    if x % y == 0:
  7.  
  8.       print y, "is a factor of x."
  9.  
  10.   else:
  11.      print y, "is not a factor x."
  12.  
  13. main()
  14.  
For some reason the program only interprets up to the input parts and left the rest out. That is, when I run the program in shell, it prompts me to enter the integers and stop there. Can any body tell me why? your help will be greatly appreciated. Thank you very much.
You are in luck. We'll just shoot this over to the python forum and get you some help there. Welcome to TheScripts.com.
Feb 6 '07 #2
bartonc
6,596 Recognized Expert Expert
As homework, I am to write a scrip that can determine if one integer is factor of another. I define the input x and y as follow
For some reason the program only interprets up to the input parts and left the rest out. That is, when I run the program in shell, it prompts me to enter the integers and stop there. Can any body tell me why? your help will be greatly appreciated. Thank you very much.
The second function call was never made. Here's one way to do it:
Expand|Select|Wrap|Line Numbers
  1. # I like to have subroutines on top and main() at the bottom
  2. def isfactor (x, y):
  3.     if x % y == 0:
  4.         print y, "is a factor of x."
  5.     else:
  6.         print y, "is not a factor x."
  7.  
  8. def main():
  9.     x = input ("What is the integer? ")
  10.     y = input ("Enter another integer: ")
  11.     isfactor(x, y)
  12.  
  13.  
  14. main()
  15.  
Feb 6 '07 #3
bartonc
6,596 Recognized Expert Expert
By the way, welcome to the Python Forum on TheScripts.com. I'm glad you found this site and I really like you nic (wish I'd thought of that handle). Get all the python help you need here on TSDN.
Feb 6 '07 #4

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

Similar topics

0
1582
by: Lucas, Todd | last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing for a Menu. I've been at it for about 3 weeks now, and can't seem to get around this problem. So I'm hoping that someone...
1
3877
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
6
1912
by: jcrouse | last post by:
I have a project with a startup (Sub Main) module and two forms. Based on the logic in the Sub Main it calls one of the two forms. The two forms are almost identical. They both make calls into the...
1
1706
by: graemeharnish | last post by:
Hello. I'm trying to mod an open source app called TinyERP and inherit from a parent object, and in essence change how _column is defined. I found sample code of: class...
1
3405
by: leslie_tighe | last post by:
Hello, I have webservice created with Axis 1.2.1 and that I am trying to consuming in .NET (VB) using the Microsoft provided tools. While I am able to consume methods on the service that return...
5
19560
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
18
1770
by: jslowery | last post by:
I am not completely knowledgable about the status of lexical scoping in Python, but it was my understanding that this was added in a long time ago around python2.1-python2.2 I am using python2.4...
5
1510
by: tshad | last post by:
In VS 2003, I am setting up an abstract class that is setting up classes for each datatype of VB.Net (as well as C#). I am trying to set it up so that most of the work is done in the Abstract...
4
2530
by: Gilberto | last post by:
Hello, I have a couple of forms using the code to FIND AS YOU TYPE from Allen Browne (http://allenbrowne.com/AppFindAsUType.html). It worked PERFECTLY until yesterday when i splitted the db into...
0
1262
by: jhop | last post by:
Hello everyone, I am having a slight problem with a program i am working on for a class, I am using Visual Studio 2005. The program only allows the up arrow key as input. In the code it is...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.