-
import random #not sure about this
-
-
while True:
-
guess = raw_input("Start or Exit?")
-
if guess.lower() == 'exit':
-
break
-
-
if guess.lower() == 'start':
-
-
a = raw_input("Digits?")
-
-
random() == (1-9)
-
-
print random()
-
-
-
else:
-
print 'Invalid entry'
-
Just a simple question guys; What's wrong with my coding?
This is the error i get: -
Traceback (most recent call last):
-
File "C:\Program Files\Python25\diggen.py", line 35, in <module>
-
random() == (1-9)
-
TypeError: 'module' object is not callable
-
6 1226 -
import random #not sure about this
-
-
while True:
-
guess = raw_input("Start or Exit?")
-
if guess.lower() == 'exit':
-
break
-
-
if guess.lower() == 'start':
-
-
a = raw_input("Digits?")
-
-
random() == (1-9)
-
-
print random()
-
-
-
else:
-
print 'Invalid entry'
-
Just a simple question guys; What's wrong with my coding?
This is the error i get: -
Traceback (most recent call last):
-
File "C:\Program Files\Python25\diggen.py", line 35, in <module>
-
random() == (1-9)
-
TypeError: 'module' object is not callable
-
I don't know what you are tyring to do. random is a module and 1-9 means one minus nine. Myabe something like this: -
while True:
-
guess = raw_input("Start or Exit?")
-
if guess.lower() == 'exit':
-
break
-
-
if guess.lower() == 'start':
-
a = raw_input("Digits?")
-
nums = [int(x) for x in a.split()]
-
if random.randint(1, 10) in nums:
-
print "good"
-
else:
-
print 'Invalid entry'
-
Doesn't seem to work....I'm trying to make a digit generator...you know? Something that displays 10 digits if you ask it to...
Doesn't seem to work....I'm trying to make a digit generator...you know? Something that displays 10 digits if you ask it to...
What do you mean it doens't work? Besides an indentation error, I'm pretty sure it works. Something like this? -
import random
-
-
if raw_input("Do you want to display 10 digits? ") in 'Yy':
-
for dummy in range(10):
-
print randint(1, 10)
-
-
import random
-
-
if raw_input("Do you want to display 10 digits? ") in 'Yy':
-
for dummy in range(10):
-
print randint(1, 10)
-
I do believe you either need to change "randint" to "random.randint " or change "import random" to "from random import randint"
bartonc 6,596
Recognized Expert Expert
What do you mean it doens't work? Besides an indentation error, I'm pretty sure it works. Something like this? -
import random
-
-
if raw_input("Do you want to display 10 digits? ") in 'Yy':
-
for dummy in range(10):
-
print randint(1, 10)
-
Our friend, William Manley, is correct. The import is one way to fix this: - from random import randint
Or on this line: - #
-
print random.randint(1, 10)
BTW, I notice that you are still typing your CODE tags in (I did it that way for a long time, too). Then I found that setting the "Enhanced Mode" radio button and using the # button is much faster and less error prone.
Hope that helps.
Our friend, William Manley, is correct. The import is one way to fix this: - from random import randint
Or on this line: - #
-
print random.randint(1, 10)
Yep, he's right, I missed that sorry.
BTW, I notice that you are still typing your CODE tags in (I did it that way for a long time, too). Then I found that setting the "Enhanced Mode" radio button and using the # button is much faster and less error prone.
Hope that helps.
Thanks, I'll try that.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sniffle |
last post by:
Thanks...
Say you have a double opt in mailing list, of which the subcriber list is
store in the db. Im still somewhat of a newb, so bear with me... are there
any pros/cons as to keeping the 'unverified' subscribers in a different
table, aside from organization?
I did just that, where, when they subscribe, they are put in a temp table,
and them moved to the real table once verified (and the temp entry deleted).
At the time, I did this...
|
by: Drebin |
last post by:
It's a long story really, but the bottom line is we need to encrypt or
obfuscate a clear-text 9-digit SSN/taxpayer ID into something less than 21
characters. It doesn't need to be super-secure, just something that isn't
plain-text and it HAS to be as unique as the original number. It also does
not need to be a symmetric algorithm - we are using this as a way to create
a unique "userid" on a system to which we single-signon. So it's used...
|
by: Kermit Piper |
last post by:
Hello,
I have been searching, Googling, searching. Cannot find a javascript to
calc 10, 11 or 12 digit UPC codes. I just need an algorithm that calcs
to verify the correct check digit. I have found a few that add the
check digit then do the final calc, but I need an input validation that
will verify the UPC as being correct with the correct check digit after
the user simply enteres the number in one text box. There has to be
something...
|
by: Kermit Piper |
last post by:
Hello everyone,
OK, let me try and explain again please. Here is what I'm trying to do.
I have a 12-digit
(UPC-A) javascript validation script which works great. All I need now
is a similar script for 8-digit (UPC-E) type script? I don't want to
convert it to a 12-digit UPC-A before validating it as a 12-digit
number. I would prefer to just be able to calc the number, as an
8-digit number, check digit and all, just like I am currently...
|
by: balakrishnan.dinesh |
last post by:
hi frnds,
Im having two 20digit numbers, But while comparing those it
is giiving wrong ouput in javascript.
for example here is my code,
my secanrio is ,
~ If first 20 digit number is greater number than second 20 digit
number ,then it should return.
| |
by: ffrugone |
last post by:
I need to create a method for a web page I'm building that encrypts a
number from 1 to 1000 into a 4 digit hex code. I know nothing about
cryptography. Can anyone steer me in the right direction?
|
by: Candace |
last post by:
I am using the following code to pick off each digit of a number, from right
to left. The number I am working with is 84357. So for the first iteration it
should return the number 7 and for the second iteration it should return the
number 5, and so on. But for some reason on the first iteration returns the
expected results. Each subsequent iteration returns the number plus 1. In
order words, when I run the program I am getting: 7, 6, 4, and...
|
by: hikmaz |
last post by:
I am trying to get the rightmost digits (%10) of a number (taken from the user) and store it into successive array locations and get rid of the rightmost digit (\10) to store the next and so on and so forth.
For example, if the number entered by the user is 4321
then, int array = 1
int array = 2
int array = 3
int array = 4
int array = '\0' (End of array - when number == 0)
This is the piece of code i...
|
by: southernsunsations |
last post by:
/******************************************************************\
*
* *
* Date: 09.06.2007 *
\******************************************************************/
// Example: num digit
// A
// B
// C
// D
|
by: thehobbit |
last post by:
Hi,
Could anyone give ideas on how to add 4 20 digit numbers in ANSI C and
pass the result back to a calling program in COBOL? We were able to
add up to 15 digit numbers without any problems, but we started facing
issues once we go above 15 digits.
Thanks,
Venkat
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| | |