473,656 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

random.random() , random not defined!?

do i need to import something to use random?
Jun 27 '08 #1
4 11541
On Sun, Apr 20, 2008 at 12:58 AM, globalrev <sk*******@yaho o.sewrote:
do i need to import something to use random?
--
you need to import random :)

Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>import random
random.random ()
0.7601899891908 5967
Jun 27 '08 #2
globalrev wrote:
do i need to import something to use random?
No, you need to import random
Jun 27 '08 #3
On Apr 19, 3:36�pm, John Machin <sjmac...@lexic on.netwrote:
globalrev wrote:
do i need to import something to use random?

No, you need to import random
But you could alsways import it as something.
>>import random as something
something.ran dom()
0.4581160625666 8347
Jun 27 '08 #4
En Sat, 19 Apr 2008 16:28:37 -0300, globalrev <sk*******@yaho o.seescribió:
do i need to import something to use random?
Let me guess: you have a script named random.py? Perhaps the same one you're executing?
In that case when you write "import random", you're importing *your* script instead of the standard one.

--
Gabriel Genellina

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
3684
by: Paul Rubin | last post by:
http://www.nightsong.com/phr/python/sharandom.c This is intended to be less predicable/have fewer correlations than the default Mersenne Twister or Wichmann-Hill generators. Comments are appreciated.
4
5100
by: Jesse Noller | last post by:
Hello - I'm probably missing something here, but I have a problem where I am populating a list of lists like this: list1 = list2 = list3 = main_list =
15
4938
by: John Cassidy | last post by:
This has been driving me crazy. I've done basic C in school, but my education is mainly based on object oriented design theory where Java is our tool. For some reason, while helping a friend with a C Programming lab. I cannot for the life of me generate a random number. i don't know what is wrong. please help. #include <stdio.h> #include <stdlib.h> #include <math.h>
10
2501
by: Marshall Belew | last post by:
I'm trying to synchronize a network app that uses random numbers generated by System.Random. Rather than pass every randomly generated number, I just pass the seed. I'm seeing a result that leads me to believe that a seeded random number is still slightly random. I need a predictable random number. Here's my results Machine 1 Seed: 1453549276
3
1198
by: Darren Clark | last post by:
I do the following in code int count = randata.ProductTable.Rows.Count; Random r = new Random(); Random r2 = new Random(); int i = r.Next(1,count);
2
1832
by: KS | last post by:
I can't make the Random,Next(1,13) to work ! In Dim NrForDefekteEmne As Random = New Random.Next(1, 13) Random.Next is marked as "not defined" - I have "Imports System" What is wrong here ?
3
4676
by: Daniel | last post by:
Hey guys Using Random(), how random is it, is it possible to be predicted? I have a requirement for a very good random number generator. I was doing something such as: Random randomSeed = new Random((int)_seedTimer.ElapsedTicks); _random = new Random(randomSeed.Next(0,99999999)); return random.Next(min, max);
8
3906
by: Daniel | last post by:
Hey guys Using Random(), how random is it, is it possible to be predicted? I have a requirement for a very good random number generator. I was doing something such as: Random randomSeed = new Random((int)_seedTimer.ElapsedTicks); _random = new Random(randomSeed.Next(0,99999999)); return random.Next(min, max);
6
4809
by: Mike Langworthy | last post by:
i can not seem to get this code to work. someone please help using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
11
11549
by: Alex | last post by:
Hi everybody, I wonder if it is possible in python to produce random numbers according to a user defined distribution? Unfortunately the random module does not contain the distribution I need :-( Many thanks axel
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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, 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...
0
8717
jinu1996
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...
0
8600
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 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...
0
7311
agi2029
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...
0
5629
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();...
0
4150
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...
1
2726
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
2
1600
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.