Help urgent! serial number generator!

hi guys!!!

i’m new to python and i have an assessment coming soon and i’m not sure how to generate serial numbers to show on the window. can someone help me please?

Which part are you having trouble with?

Making a basic sketch?
Generating random numbers?
Converting random numbers to letters?
Creating a String out of parts?
Displaying a String in the screen?

Without knowing more about what you want to do - and what you have already tried (POST YOUR CODE!) - we really can’t help you. Also, check the homework policy.

1 Like

hii

sorry for not posting the code

def draw():
    global r
    global z
    
    n = random(int(100))
    
    textSize(20)
    text(n, 300,300)
    background('#4D1040')
    img = loadImage('2.PNG')
    image(img, 0,0, 200,200)

im having trouble with one, generating the numbers, and two, displaying it on the screen

Now that we can see your code, the problem becomes clear. You are doing things in a weird order.

You start by drawing some text on the screen! Great!

Then you paint over everything with a background color. This covers up the text you just drew! Oh no!

Then you load an image… and draw that image.


So there are two problems.

First, DO NOT LOAD YOUR IMAGE IN DRAW!!! Move the line of code that loads the image to your setup() function. You do not want to be loading the image 60 times a second. You only want to load it ONCE.

Second, draw things in the proper order.
Start with the background color.
Then draw the image.
Then draw the text.

Try to change your code now to do this. Post the code again with your attempted changes, and more about what’s still wrong with it. Also post the setup() function!

1 Like

Hello,

There are Processing Python resources here:
https://py.processing.org/

Sometimes you can glean insight from the Processing JAVA page as well:
https://processing.org/

:)