Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
- -cloudcoding-
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Codesandbox gives you AMAZING specs and also is not ip banned on scratch (replit is) okay, does anyone know about a good online compiler i can use at school with libaries?
Last edited by kaj (Tomorrow 00:00:00)
-cloudcoding-
"[coding is] like clouds - always evolving and ready to transform!" - ChatGPT :)
Go check out my projects!
- MonkeyBean2
- Scratcher
100+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
store _seed in an array/dict, and then to update _seed update it like so: _seed = …Sorry, I pasted the code twice. Heres the real code:Hello, I was making a game in pygame, which uses tkinter for selecting the seed. I was making a prototype when i encountered a problem.your inner askseed function does nothingdef askseed(self, initvalue): def askseed(self, initvalue): root = tkinter.Tk() root.title("Seed") root.geometry("400x300") root.resizable(False, False) seedvar = tkinter.IntVar() _seed = initvalue def submit(): global _seed _seed = str(seedvar.get()) print("test1", _seed) seedvar.set(0) # root.destroy() intro1 = tkinter.Label(root, text="New World", font=("Times", 16), justify='center').pack(anchor='center', side="top", pady=20) intro2 = tkinter.Label(root, text="Enter seed:", font=("Times", 14)).pack(pady=5) seed_entry = tkinter.Entry(root, textvariable = seedvar, font=('calibre',10,'normal')).pack(side="top", after=intro2, padx=20, pady=10) sub = tkinter.Button(root, text=" ok ", command=submit).pack(pady=10) root.mainloop() # return askinteger(Main, text, initialvalue=initvalue) print("test2", _seed) return _seed
How to i send the value from inside the submit() function inside the askseed function to the askseed function. The submit function is triggered by a button. [The init value is randomly chosen]
The result is:pygame 2.5.0 (SDL 2.28.0, Python 3.10.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
test1 83
test2 163002 ⬅ original randomly chosendef askseed(self, initvalue): root = tkinter.Tk() root.title("Seed") root.geometry("400x300") root.resizable(False, False) seedvar = tkinter.IntVar() _seed = initvalue def submit(): global _seed _seed = str(seedvar.get()) print("test1", _seed) seedvar.set(0) root.destroy() intro1 = tkinter.Label(root, text="New World", font=("Times", 16), justify='center').pack(anchor='center', side="top", pady=20) intro2 = tkinter.Label(root, text="Enter seed:", font=("Times", 14)).pack(pady=5) seed_entry = tkinter.Entry(root, textvariable = seedvar, font=('calibre',10,'normal')).pack(side="top", after=intro2, padx=20, pady=10) sub = tkinter.Button(root, text=" ok ", command=submit).pack(pady=10) root.mainloop() # return askinteger(Main, text, initialvalue=initvalue) print("test2", _seed) return _seed
- divtrev2013
- Scratcher
26 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
import turtle
bird = turtle.Turtle()
bird.up()
bird.speed(0)
bird.goto(-50, 0)
yVelocity = 0
def flap(h):
yVelocity = h
while True:
yVelocity = yVelocity-1
bird.sety(bird.ycor() + yVelocity)
bird.onkey(lambda x=8: flap(x), 'space')
- INSERT-USER_NAME
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
I wanna get into python but I really don't like snake_case… Is it possible for me to not use snake_case for variables or other things?
- ajskateboarder
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Yes, snake_case is just a popular style choice I wanna get into python but I really don't like snake_case… Is it possible for me to not use snake_case for variables or other things?
- rishi272011
- Scratcher
99 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
I wanna get into python but I really don't like snake_case… Is it possible for me to not use snake_case for variables or other things?Variable names don't really matter. As long as you don't use any reserved characters, keywords or spaces, everything should work fine.
Snake_case is used with python as it is very easy to read and is popularly used.
- mybearworld
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
You should adapt to the language's convention when learning or using a language. That'll make code easier to read, and make library code consistent with code using them. You I wanna get into python but I really don't like snake_case… Is it possible for me to not use snake_case for variables or other things?can use other casing methods, though.
Signatures are the only place where assets links still work.
- ToastersUnited
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
You can, but what @mybearworld said. I wanna get into python but I really don't like snake_case… Is it possible for me to not use snake_case for variables or other things?
Each language has different conventions. Python, rust, etc. like snake_case. The C Languages tend to prefer PascalCase. Lua uses camelCase (my personal favourite) so you switch between languages.
I'm hosting Country Clash Minecraft, a minecraft server where you can join or create a nation, trade, engage in politics, go to war and more!
CCMC is a Country Clash RP spinoff. It is currently in a trial period where CCRP admins will observe the server and see whether or not it should continue.
CCMC uses a custom map with volcanoes, nether and end islands, winding rivers and more!
CCMC will start within the next two days or so. It has a 10 player limit at any time. Anyone can join, as long as you have a copy of Minecraft Java Edition or Minecraft Bedrock Edition
- divtrev2013
- Scratcher
26 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
What should I add?
code = [] class Easy(): proVars = {} def __init__(self,code): self.code = code def log(self,msg): print(msg) def newVar(self,name): Easy.proVars[name] = None def setVar(self,varName,val): if not(varName in proVars): print("!We found an error!") program() Easy.proVars[varName] = val def var(self,variable): return Easy.proVars[variable] def run(self): functions = { 'log': self.log, 'newVar': self.newVar, 'setVar': self.setVar, 'var': self.var } try: exec(self.code, {}, functions) except NameError: print("!We found an error!") program() except ValueError: print("!We found an error!") program() def program(): global code code = [] while True: line = input(">> ") if line == "RUN": break else: code.append(line) def exeCode(): for line in code: cte = Easy(line) cte.run() while True: program() exeCode()
- divtrev2013
- Scratcher
26 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Codesandbox gives you AMAZING specs and also is not ip banned on scratch (replit is) okay, does anyone know about a good online compiler i can use at school with libaries?
Replit is a great editor for Python!
- -cloudcoding-
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
It is but codesandbox just has better specs….Codesandbox gives you AMAZING specs and also is not ip banned on scratch (replit is) okay, does anyone know about a good online compiler i can use at school with libaries?
Replit is a great editor for Python!
Last edited by kaj (Tomorrow 00:00:00)
-cloudcoding-
"[coding is] like clouds - always evolving and ready to transform!" - ChatGPT :)
Go check out my projects!
- AslanAslan11
- Scratcher
100+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
hey ya'll, like my game
# DIMOND HUNT
import random
#SETTIN UP
turn = 0
def runout():
if turn == 4:
print(' you lose!!!!')
lvl = 0
fliper =
coin = fliper
def coinflip():
global flipper, coin
coin = random.choice(fliper)
mine1 =
mine2 =
mine3 =
#SERCH
newvar = 5
mine =
set = ‘x,x,x,x,x,’
lvl += 1
mine1 = ['0','x','x','','x','x']
clue1 = ‘the other side, the ____nd.’
ansr1 = ‘2nd’
def check(themine,theclue,theansr):
global cmd, coin, turn, lvl
print(set)
if lvl == 1:
cmd = input(' COMMAND?? ‘)
if cmd == ’c':
coinflip()
if coin == 0:
turn += 1
print(themine)
runout()
else:
print('try again')
guess = input(theclue)
if guess == theansr:
print('congrats!! ')
print(themine)
else:
print('ooppppsieeee')
#NOW LVL ORGANIZEATION.
check(mine1,clue1,ansr1)
print(lvl)
mine2 = ['','x','x','a','x','x']
clue2 = ‘in the scale, this is the only base ten number besides 7 to start with s.’
ansr2 = ‘2nd’
check(mine2,clue2,ansr2)
print(lvl)
mine3 = ['0','x','x','a
clue3 = ‘ start of everything’
ansr3 = ‘a’
print(lvl)
check(mine3,clue3,ansr3)
sadly you have to edit the shalshing ' to the python excaptable one.
# DIMOND HUNT
import random
#SETTIN UP
turn = 0
def runout():
if turn == 4:
print(' you lose!!!!')
lvl = 0
fliper =
coin = fliper
def coinflip():
global flipper, coin
coin = random.choice(fliper)
mine1 =
mine2 =
mine3 =
#SERCH
newvar = 5
mine =
set = ‘x,x,x,x,x,’
lvl += 1
mine1 = ['0','x','x','','x','x']
clue1 = ‘the other side, the ____nd.’
ansr1 = ‘2nd’
def check(themine,theclue,theansr):
global cmd, coin, turn, lvl
print(set)
if lvl == 1:
cmd = input(' COMMAND?? ‘)
if cmd == ’c':
coinflip()
if coin == 0:
turn += 1
print(themine)
runout()
else:
print('try again')
guess = input(theclue)
if guess == theansr:
print('congrats!! ')
print(themine)
else:
print('ooppppsieeee')
#NOW LVL ORGANIZEATION.
check(mine1,clue1,ansr1)
print(lvl)
mine2 = ['','x','x','a','x','x']
clue2 = ‘in the scale, this is the only base ten number besides 7 to start with s.’
ansr2 = ‘2nd’
check(mine2,clue2,ansr2)
print(lvl)
mine3 = ['0','x','x','a
clue3 = ‘ start of everything’
ansr3 = ‘a’
print(lvl)
check(mine3,clue3,ansr3)
sadly you have to edit the shalshing ' to the python excaptable one.
Last edited by AslanAslan11 (Feb. 12, 2024 00:13:52)
virus thingy, put it at the top of your signature
Generation 381: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
hello! im a nintendo fan and a major tally hall fan! this is my signatrue lol.
:3 <—- hi! this is ruff! he protects my siggy!
- rishi272011
- Scratcher
99 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Use code tags, please. hey ya'll, like my game…
# DIMOND HUNT import random #SETTIN UP turn = 0 def runout(): if turn == 4: print(' you lose!!!!') lvl = 0 fliper = None coin = fliper def coinflip(): global flipper, coin coin = random.choice(fliper) mine1 = #nothing? mine2 = #nothing? mine3 = #nothing? #SERCH newvar = 5 mine = #nothing? set = 'x,x,x,x,x,' lvl += 1 mine1 = ['0','x','x','','x','x'] clue1 = 'the other side, the ____nd.' ansr1 = '2nd' def check(themine,theclue,theansr): global cmd, coin, turn, lvl print(set) if lvl == 1: cmd = input(' COMMAND?? ') if cmd == 'c': coinflip() if coin == 0: turn += 1 print(themine) runout() else: print('try again') guess = input(theclue) if guess == theansr: print('congrats!! ') print(themine) else: print('ooppppsieeee') #NOW LVL ORGANIZEATION. check(mine1,clue1,ansr1) print(lvl) mine2 = ['','x','x','a','x','x'] clue2 = 'in the scale, this is the only base ten number besides 7 to start with s.' ansr2 = '2nd' check(mine2,clue2,ansr2) print(lvl) mine3 = ['0','x','x','a'] clue3 = ' start of everything' ansr3 = 'a' print(lvl) check(mine3,clue3,ansr3)
- mybearworld
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
(#973)They are, but BBCode destroyed them. This is the actual code:
Also, your mine1 mine2 and mine3 variables are not set.
# DIMOND HUNT import random #SETTIN UP turn = 0 def runout(): if turn == 4: print(' you lose!!!!') lvl = 0 fliper = [0,1] coin = fliper def coinflip(): global flipper, coin coin = random.choice(fliper) mine1 = [] mine2 = [] mine3 = [] #SERCH newvar = 5 mine = ['o','x','-'] set = 'x,x,x,x,x,' lvl += 1 mine1 = ['0','x','x','[a its in this sector]','x','x'] clue1 = 'the other side, the ____nd.' ansr1 = '2nd' def check(themine,theclue,theansr): global cmd, coin, turn, lvl print(set) if lvl == 1: cmd = input(' COMMAND?? ') if cmd == 'c': coinflip() if coin == 0: turn += 1 print(themine) runout() else: print('try again') guess = input(theclue) if guess == theansr: print('congrats!! :)') print(themine) else: print('ooppppsieeee') #NOW LVL ORGANIZEATION. check(mine1,clue1,ansr1) print(lvl) mine2 = ['[0 this sector!]','x','x','a','x','x'] clue2 = 'in the scale, this is the only base ten number besides 7 to start with s.' ansr2 = '2nd' check(mine2,clue2,ansr2) print(lvl) mine3 = ['0','x','x','a [--- is NOT DIRECTLY THERE BUT IN THE A SECTOR','X','X'] clue3 = ' start of everything' ansr3 = 'a' print(lvl) check(mine3,clue3,ansr3)
Signatures are the only place where assets links still work.
- AslanAslan11
- Scratcher
100+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
points = 0
import random
line1 =
line2 =
line3 =
line4 =
blocks =
def startrando():
global line1, line2, line3, line4
going = random.choice(blocks)
print(going)
lineinput = input('What line? (one, two, three, four): ‘)
sec = int(input(’What sector?'))
if lineinput == ‘1’:
new = sec - 1
line1 = going
elif lineinput == ‘2’:
new = sec - 1
line2 = going
elif lineinput == ‘3’:
new = sec - 1
line3 = going
elif lineinput == ‘4’:
new = sec - 1
line4 = going
print(line1)
print(line2)
print(line3)
print(line4)
def check():
global line1, line2, line3, line4, points
checka = 0
while checka < 3:
if line1 == line2 == line3 == line4:
points += 1
checka += 1
def both():
startrando()
check()
def loop():
print(“Total Points:”, points)
both()
loop()
import random
line1 =
line2 =
line3 =
line4 =
blocks =
def startrando():
global line1, line2, line3, line4
going = random.choice(blocks)
print(going)
lineinput = input('What line? (one, two, three, four): ‘)
sec = int(input(’What sector?'))
if lineinput == ‘1’:
new = sec - 1
line1 = going
elif lineinput == ‘2’:
new = sec - 1
line2 = going
elif lineinput == ‘3’:
new = sec - 1
line3 = going
elif lineinput == ‘4’:
new = sec - 1
line4 = going
print(line1)
print(line2)
print(line3)
print(line4)
def check():
global line1, line2, line3, line4, points
checka = 0
while checka < 3:
if line1 == line2 == line3 == line4:
points += 1
checka += 1
def both():
startrando()
check()
def loop():
print(“Total Points:”, points)
both()
loop()
virus thingy, put it at the top of your signature
Generation 381: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
hello! im a nintendo fan and a major tally hall fan! this is my signatrue lol.
:3 <—- hi! this is ruff! he protects my siggy!
- -cloudcoding-
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
code tags snip
points = 0 import random line1 = [] line2 = [] line3 = [] line4 = [] blocks = ['●', '♠', 'X'] def startrando(): global line1, line2, line3, line4 going = random.choice(blocks) print(going) lineinput = input('What line? (one, two, three, four): ') sec = int(input('What sector?')) if lineinput == '1': new = sec - 1 line1[new] = going elif lineinput == '2': new = sec - 1 line2[new] = going elif lineinput == '3': new = sec - 1 line3[new] = going elif lineinput == '4': new = sec - 1 line4[new] = going print(line1) print(line2) print(line3) print(line4) def check(): global line1, line2, line3, line4, points checka = 0 while checka < 3: if line1[checka] == line2[checka] == line3[checka] == line4[checka]: points += 1 checka += 1 def both(): startrando() check() def loop(): print("Total Points:", points) both() loop()
Last edited by -cloudcoding- (Feb. 19, 2024 19:10:01)
Last edited by kaj (Tomorrow 00:00:00)
-cloudcoding-
"[coding is] like clouds - always evolving and ready to transform!" - ChatGPT :)
Go check out my projects!
- INSERT-USER_NAME
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
I know this is an odd question, but does anybody know of a pygame version that works on python 3.4.3?
- divtrev2013
- Scratcher
26 posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Hello, I'm a Python programmer. I started learning “pandas” however I don't understand creatinfg a database. Here's the code:
import pandas as pd data = { "a": [1, 2, 3, 4], "b": [5, 6, 7, 8] } df = pd.DataFrame(data) print(df)
- dynamicsofscratch
- Scratcher
1000+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
(#978)what do you need explanation for? if you want a summary, here it is in code format but with comments:
Hello, I'm a Python programmer. I started learning “pandas” however I don't understand creatinfg a database. Here's the code:import pandas as pd data = { "a": [1, 2, 3, 4], "b": [5, 6, 7, 8] } df = pd.DataFrame(data) print(df)
# import python library import pandas as pd # set database data data = { "a": [1, 2, 3, 4], "b": [5, 6, 7, 8] } # setup dataframe df = pd.Dataframe(data) # print dataframe print(df)
aII toasters toast toast, but what happens when there are no longer toasters being produced? will their technology simply become obsolete, with humans moving onto bigger, better things? will toast become a distant memory, written in textbooks of the future as foods us simpler generations ate? who's to say! society is constantly moving, changing, evolving, ideas being built upon, improved upon, theories being proven or disproven. are we but a blip on the timeline? sure, our names may not be remembered, but that's not the point. you can make a change. you can make a difference. you can make the world better, even if you don't know yet. and the first step is to go for it. even if you are afraid of failure. going back to the example of toasters, do you know off the top of your head who invented them? no? have you used one? probably. so, even if you don't remember my name, if I was able to help awnser your question, that is enough. if I was able to help you, even in the slightest way, this could push you to continue with scratch and not give up after the program crashes, and maybe one day learn other programming languages and change the world. everything is a cause and effect reaction, new inventions lead to the technology of the future, and even as the generations of the past are slowly forgotten, their influence lives on to this day, affecting how the world eventually turned out and how it will be for generations to come.
and, without toasters, we wouldn't have toast.
and, without toasters, we wouldn't have toast.
Regards
dynamicsofscratch
Anything above that grey line is a signature!
Also, anything can be put in your signature, (also referred as a siggy) including ads but! You cannot do anything else that violates the community guidelines as, you will be reported and you could be banned/muted.
Computer enthusiast, coder, designer and a offline veteran.
700th post
- Mahdir2111
- Scratcher
100+ posts
PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |
Can I become a helper, I know some python and I know how to use vscode, github and replit
- Discussion Forums
- » Advanced Topics
- » PyHelp - The official Scratch Python help forum | Ask, help, discuss, & more! | +800 posts! |