Discuss Scratch
- Discussion Forums
- » Things I'm Making and Creating
- » Python programming language
- mybearworld
-
1000+ posts
Python programming language
Yes, but only in conditions like these:
But you don't use it like this:
Elif stands for “else if”.
if 1==1: print("The world is sane.") elif 2==2: print("Okay, 2 is 2.") else: print("WHAT IS GOING ON")
if 1==1: print("The world is sane.") elif 2==2: print("Okay, 2 is 2.") else 3==3: print("Uh...")
- dertermenter
-
1000+ posts
Python programming language

With help from @MyBearWorld , this is my first python game.
If you want to play here is the code!!!!
import random
computer = random.randint(1,10)
number = int(input(“Pick a number between 1 and 10!”))
if computer > number:
print(“Sorry, you lose. The computers number was bigger than yours! The computers number was”,computer,“and your number was”,number,“. \n That is a difference by”,computer - number,“. Better luck next time!”)
elif number > computer:
print(“Woop woop! You win! Your number was bigger than the computers! Your number was”,number,“And the computers was”,computer,“. /n That is a difference by”, number - computer,“!”)
elif number == computer:
print(“Draw. You and the computers number was the same! You both picked”,computer,“!”)
I hope it is OK lol. Enjoy!
still prefer javascript a lot more
- mybearworld
-
1000+ posts
Python programming language
Code tags are better, because copy and paste doesn't work.
With help from @MyBearWorld , this is my first python game.
If you want to play here is the code!!!!import random
computer = random.randint(1,10)
number = int(input("Pick a number between 1 and 10!"))
if computer > number:
print("Sorry, you lose. The computers number was bigger than yours! The computers number was",computer,"and your number was",number,". \n That is a difference by",computer - number,". Better luck next time!")
elif number > computer:
print("Woop woop! You win! Your number was bigger than the computers! Your number was",number,"And the computers was",computer,". /n That is a difference by", number - computer,"!")
elif number == computer:
print("Draw. You and the computers number was the same! You both picked",computer,"!")
I hope it is OK lol. Enjoy!
still prefer javascript a lot more
Cool, but it's “\n”

Also:
Pick a number between 1 and 10!11
Woop woop! You win! Your number was bigger than the computers! Your number was 11 And the computers was 2 . /n That is a difference by 9 !
Last edited by mybearworld (April 9, 2021 10:17:30)
- Vaibhs11
-
1000+ posts
Python programming language
You should've used code=py more than quote.import random computer = random.randint(1,10) number = int(input("Pick a number between 1 and 10!")) if computer > number: print("Sorry, you lose. The computers number was bigger than yours! The computers number was",computer,"and your number was",number,". \n That is a difference by",computer - number,". Better luck next time!") elif number > computer: print("Woop woop! You win! Your number was bigger than the computers! Your number was",number,"And the computers was",computer,". /n That is ", "a difference by ", number - computer,"!") elif number == computer: print("Draw. You and the computers number was the same! You both picked",computer,"!")
I'll make the game better.
import random computer = random.randint(1,10) number = int(input("Pick a number between 1 and 10!")) while 1==1: if computer > number: print("higher \n") elif number == computer: print("Draw \n") break elif number > computer: break print("Woop woop! You win! Your number was bigger than the computers! Your number was ",number," and the computers was ",computer,". /n That is a difference by ", number - computer,"!")
still prefer javascript a lot moreThat's the spirit!
Last edited by Vaibhs11 (April 9, 2021 10:36:29)
- mybearworld
-
1000+ posts
Python programming language
NO.import random computer = random.randint(1,10) number = int(input("Pick a number between 1 and 10!")) while 1==1: if computer > number: print("higher") elif number == computer: print("Draw. You and the computers number was the same! You both picked",computer,"!") elif number > computer: break print("Woop woop! You win! Your number was bigger than the computers! Your number was",number,"And the computers was",computer,". /n That is a difference by", number - computer,"!")
NOO.
NOOOOOO.
- Vaibhs11
-
1000+ posts
Python programming language
too late I corrected my code.NO.import random computer = random.randint(1,10) number = int(input("Pick a number between 1 and 10!")) while 1==1: if computer > number: print("higher") elif number == computer: print("Draw. You and the computers number was the same! You both picked",computer,"!") elif number > computer: break print("Woop woop! You win! Your number was bigger than the computers! Your number was",number,"And the computers was",computer,". /n That is a difference by", number - computer,"!")
NOO.
NOOOOOO.
- roketH77
-
1000+ posts
Python programming language
Hey, I’m getting into python, but I don’t know much lol. Can you give me some beginner tutorials you recommend/used? Thanks!
Edit: I plan on using visual studio on windows, if this bears any weight.
Edit: I plan on using visual studio on windows, if this bears any weight.
Last edited by roketH77 (April 17, 2021 12:39:33)
- gosoccerboy5
-
1000+ posts
Python programming language
Honestly, Python is a pretty intuitive language if you know Scratch already, I would recommend w3schools.com but I'm probably gonna get yelled at for that (tbh you should use w3schools for simpler stuff only) Hey, I’m getting into python, but I don’t know much lol. Can you give me some beginner tutorials you recommend/used? Thanks!
Edit: I plan on using visual studio on windows, if this bears any weight.
- -EmeraldThunder-
-
1000+ posts
Python programming language
Does anyone know how to change things like your about me and what I'm working on in python?
- gosoccerboy5
-
1000+ posts
Python programming language
The best url I could get with the network log while saving my About Me was Does anyone know how to change things like your about me and what I'm working on in python?https://scratch.mit.edu/site-api/users/all/${username}/, which does something weird when I try to visit the url.
Last edited by gosoccerboy5 (April 17, 2021 13:47:25)
- PowerOfStars
-
100+ posts
Python programming language
I am advanced in python
Last edited by PowerOfStars (April 17, 2021 13:49:15)
- roketH77
-
1000+ posts
Python programming language
I’ll just look on YouTube lolHonestly, Python is a pretty intuitive language if you know Scratch already, I would recommend w3schools.com but I'm probably gonna get yelled at for that (tbh you should use w3schools for simpler stuff only) Hey, I’m getting into python, but I don’t know much lol. Can you give me some beginner tutorials you recommend/used? Thanks!
Edit: I plan on using visual studio on windows, if this bears any weight.
Edit: I was gonna look on there anyway
Last edited by roketH77 (April 17, 2021 16:34:41)
- mrcoat
-
100+ posts
Python programming language
Hello I'm using python to make something that accesses my scratch messages, but it keeps giving me an access denied thing, how would I be able to get access to it using python? Thank yu!
also
also
guy if your advanced can i get help with this? I am advanced in python
- roketH77
-
1000+ posts
Python programming language
You have to have some sort of key that you get through JavaScript, but that’s all I know. Hello I'm using python to make something that accesses my scratch messages, but it keeps giving me an access denied thing, how would I be able to get access to it using python? Thank yu!
alsoguy if your advanced can i get help with this? I am advanced in python
- mybearworld
-
1000+ posts
Python programming language
You need to give your token, what I have no idea how t get Hello I'm using python to make something that accesses my scratch messages, but it keeps giving me an access denied thing, how would I be able to get access to it using python? Thank yu!
alsoguy if your advanced can i get help with this? I am advanced in python
- mrcoat
-
100+ posts
Python programming language
You mean your crsftoken thingy? Or your scratch session id?You need to give your token, what I have no idea how t get Hello I'm using python to make something that accesses my scratch messages, but it keeps giving me an access denied thing, how would I be able to get access to it using python? Thank yu!
alsoguy if your advanced can i get help with this? I am advanced in python
- roketH77
-
1000+ posts
Python programming language
I would assume crsftokenYou mean your crsftoken thingy? Or your scratch session id?You need to give your token, what I have no idea how t get Hello I'm using python to make something that accesses my scratch messages, but it keeps giving me an access denied thing, how would I be able to get access to it using python? Thank yu!
alsoguy if your advanced can i get help with this? I am advanced in python
- ScratchCatHELLO
-
1000+ posts
Python programming language
so uh
this is obscure but I don't have an account in a place where anyone is likely to know this
so I'm trying to use SLY (Sly Lex Yacc) to make a “”'programming language“”" in python (you can search the SLY docs for info). the thing is, I keep getting shift-reduce errors even though I've specified the priority of commands. the errors seem to come from my if() implementation.
precedence of tokens (IF is the token for if, obviously)
definitions (yes this is sloppy and bad but I have no idea how to make it any better):
I highly doubt the definition is causing this, but I'm adding it anyway just in case.
From what I can tell, a shift/reduce error is just when it can't tell weather to resolve what it has or check the next token.
The IF command works fine, so I don't know what the error is.
I'm close to just ignoring the errors because they don't seem to affect anything but I'd like to figure out the cause.
I probably won't get an answer, but it's worth a shot
this is obscure but I don't have an account in a place where anyone is likely to know this
so I'm trying to use SLY (Sly Lex Yacc) to make a “”'programming language“”" in python (you can search the SLY docs for info). the thing is, I keep getting shift-reduce errors even though I've specified the priority of commands. the errors seem to come from my if() implementation.
precedence of tokens (IF is the token for if, obviously)
# resolve vs shift priority, shift to resolve order precedence = ( ('left', 'ASSIGN', 'PLUSASSIGN', 'MINUSASSIGN', 'TIMESASSIGN', 'DIVASSIGN', 'EXPASSIGN' ), ('left', 'EQ', '>', '<' ), ('left', 'IF'), ('left', '+', '-', 'INCREMENT', 'FACTASSIGN' ), ('left', '*', '/'), ('left', '^', '!'), ('right', 'UMINUS'), )
definitions (yes this is sloppy and bad but I have no idea how to make it any better):
# if attempt (making 27 shift/reduce conflicts somehow) # :IF(a==1)a+b # if a = 1, it returns b @_('IF "(" expr EQ expr ")" expr') def expr(self, p): if (p.expr0 == p.expr1): return p.expr2 else: return 0 @_('IF "(" expr ">" expr ")" expr') def expr(self, p): if (p.expr0 > p.expr1): return p.expr2 else: return 0 @_('IF "(" expr "<" expr ")" expr') def expr(self, p): if (p.expr0 < p.expr1): return p.expr2 else: return 0
From what I can tell, a shift/reduce error is just when it can't tell weather to resolve what it has or check the next token.
The IF command works fine, so I don't know what the error is.
I'm close to just ignoring the errors because they don't seem to affect anything but I'd like to figure out the cause.
I probably won't get an answer, but it's worth a shot