This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-07-06 18:43:24

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Python's "elif"

I am learning Python (named after the Monty Python shows, not the reptile) and one of the most basic statements is the "elif" statement. It is short of "Else if..." and I think Scratch needs it. After all, what kind of project asks a question and if it gets a "Yes" does one thing, and if it gets "No" does another, and if it gets "qwertyuiop" does "No"?

Offline

 

#2 2010-07-06 19:05:07

scmb1
Scratch Team
Registered: 2009-03-19
Posts: 1000+

Re: Python's "elif"

While I agree that would be useful, it can be done by just sticking and "if else" is the "else," If that made any sense...


http://i48.tinypic.com/2z5pqad.png

Offline

 

#3 2010-07-21 00:19:42

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: Python's "elif"

Somewhat.. you probably meant another 'If Else' block placed inside the 'Else' of a first 'If Else' Block, just to clear up any confusion on the part of maxskywalker.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

#4 2010-07-21 20:42:39

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Python's "elif"

As Ace-of-Spades mentioned, you can in fact place "if else" inside an "if else."

A lot of scripting room could be saved with this block, however - something of a button that creates another "else if" statement without indenting the new block would be really handy, and teach some more accurate programming skills. I certainly agree with this idea  smile

Offline

 

#5 2010-07-21 23:06:31

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: Python's "elif"

In Python, sometimes you need more than just one Elif though, so the If Else in the Else space would be the best way to go at it for now.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

#6 2010-07-22 02:27:33

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Python's "elif"

I think it would be better to simply place two blocks together than create a whole new block.  hmm


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#7 2010-07-22 21:15:14

Jimmy-Jermaine
New Scratcher
Registered: 2010-06-25
Posts: 100+

Re: Python's "elif"

coolstuff wrote:

As Ace-of-Spades mentioned, you can in fact place "if else" inside an "if else."

A lot of scripting room could be saved with this block, however - something of a button that creates another "else if" statement without indenting the new block would be really handy, and teach some more accurate programming skills. I certainly agree with this idea  smile

I don't think you understand. This is how elif is used in python:

x = raw_input("Who's the best Scratcher ever?")
while x != "Jimmy-Jermaine":
    if"Jimmy-Jermaine"in x:
        print "I agree!"
    elif"archmage"in x:
        print "Did you mean Jimmy-Jermaine?"
    elif"RHY3756547"in x:
        print "Did you mean Jimmy-Jermaine?"
    elif"m44"in x:
        print "Did you mean Jimmy-Jermaine?"
    else:
        print "That's not right, the proper answer is Jimmy-Jermaine."

They won't make 10 different blocks with varying lengths of Elif dents in them if it can be done with the simple combination of 2 or more blocks.

Offline

 

#8 2010-07-22 21:48:23

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Python's "elif"

Jimmy-Jermaine wrote:

I don't think you understand. This is how elif is used in python:

...

They won't make 10 different blocks with varying lengths of Elif dents in them if it can be done with the simple combination of 2 or more blocks.

I did, in fact, understand - I was suggesting a button that would add another if statement to the block, much like the arrow that is used in BYOB.

Offline

 

#9 2010-07-22 21:57:05

Jimmy-Jermaine
New Scratcher
Registered: 2010-06-25
Posts: 100+

Re: Python's "elif"

BYOB? Never heard of it. Do you mean BYOND?

Offline

 

#10 2010-07-22 22:20:37

scmb1
Scratch Team
Registered: 2009-03-19
Posts: 1000+

Re: Python's "elif"

Jimmy-Jermaine wrote:

BYOB? Never heard of it. Do you mean BYOND?

BYOB, or "Build Your Own Blocks," is a Scratch modification made by Jens Mönig (Jens) and Brian Harvey (bharvey).


http://i48.tinypic.com/2z5pqad.png

Offline

 

#11 2010-07-22 23:13:09

Jimmy-Jermaine
New Scratcher
Registered: 2010-06-25
Posts: 100+

Re: Python's "elif"

I've never heard of them, and I don't trust any of these 'Scratch Mods', they could be viruses in disguise.

Offline

 

#12 2010-07-23 01:01:10

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Python's "elif"

Jimmy-Jermaine wrote:

I've never heard of them, and I don't trust any of these 'Scratch Mods', they could be viruses in disguise.

It doesn't matter, I was simply using the modification as an example. Besides, this modification is one of, if not the, most well-respected modification.

Offline

 

#13 2010-07-23 02:31:52

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Python's "elif"

coolstuff wrote:

As Ace-of-Spades mentioned, you can in fact place "if else" inside an "if else."

A lot of scripting room could be saved with this block, however - something of a button that creates another "else if" statement without indenting the new block would be really handy, and teach some more accurate programming skills. I certainly agree with this idea  smile

Agreed. If you had to stack a lot of "If, else" blocks inside each other, looking at all those C blocks could get confusing really fast. This solution would work really well, in a similar fashion to BYOB's "The list: [] <-  ->" blocks. (The arrows add/remove a space for an argument in the block.)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#14 2010-07-24 10:53:46

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: Python's "elif"

You can just put an if block inside the else if.
I don't think it really needs to be added, it would take up more space and if you cant be bothered to place 1 more block then sorry but I think you are just being lazy.

Offline

 

#15 2010-07-24 11:03:09

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Python's "elif"

Jimmy-Jermaine wrote:

I've never heard of them, and I don't trust any of these 'Scratch Mods', they could be viruses in disguise.

that's a fair guess. actually, BYOB is probably the safest, as jens was once a part of the scratch team.  wink


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#16 2010-07-24 12:45:59

terminator68
Scratcher
Registered: 2008-02-26
Posts: 1000+

Re: Python's "elif"

I work with python too, and I actually do agree that Scratch should have it  smile

I actually had trouble with my "Vanishing Bridge" project relating to this. When it asks for difficulty, they could type stuff and it will continue with the game at difficulty 0  sad .

Last edited by terminator68 (2010-07-24 12:47:46)


--------------------Scratcher since '08--------------------
http://images1.wikia.nocookie.net/__cb20110314152018/mlpfanart/images/5/5d/Applejack_chewing.gif

Offline

 

#17 2010-07-24 17:14:54

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Python's "elif"

colorfusion wrote:

You can just put an if block inside the else if.
I don't think it really needs to be added, it would take up more space and if you cant be bothered to place 1 more block then sorry but I think you are just being lazy.

I think you misunderstand - it's not the time we're worried about, it's the space. If you had a little arrow to add another "if" statement to add another item, it would take up a LOT less space - the endless line of "if... else" statements in most projects is a little unsettling, to be honest  smile

Offline

 

#18 2010-07-26 23:41:36

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: Python's "elif"

In Scratch you can do this:

[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...

Offline

 

#19 2010-07-27 00:09:39

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Python's "elif"

ThePCKid wrote:

In Scratch you can do this:

[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...

Well yeah, but once you start getting a lot of those stacked inside each other, it gets really oversized, cluttered, and confusing.  sad  An Else-if alternative would be much better.

Last edited by Harakou (2010-07-27 00:10:06)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#20 2010-07-27 00:11:18

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: Python's "elif"

Harakou wrote:

ThePCKid wrote:

In Scratch you can do this:

[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...

Well yeah, but once you start getting a lot of those stacked inside each other, it gets really oversized, cluttered, and confusing.  sad  An Else-if alternative would be much better.

That would be confusing

Offline

 

#21 2010-07-27 00:15:52

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Python's "elif"

ThePCKid wrote:

Harakou wrote:

ThePCKid wrote:

In Scratch you can do this:

[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...

Well yeah, but once you start getting a lot of those stacked inside each other, it gets really oversized, cluttered, and confusing.  sad  An Else-if alternative would be much better.

That would be confusing

How so? If you can understand If-else, than Else-if doesn't seem that hard to comprehend.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#22 2010-07-27 07:39:13

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Python's "elif"

ThePCKid wrote:

Harakou wrote:

ThePCKid wrote:

In Scratch you can do this:

[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...

Well yeah, but once you start getting a lot of those stacked inside each other, it gets really oversized, cluttered, and confusing.  sad  An Else-if alternative would be much better.

That would be confusing

I'm with Harakou on this one - it's actually just as easy to understand as if-else. It's really cluttered and hard to use right now.

Offline

 

#23 2010-08-17 11:07:18

midnightleopard
Scratcher
Registered: 2007-09-13
Posts: 1000+

Re: Python's "elif"

I am learning python as well and I can't get elif to work


http://pwp.wizards.com/5103673563/Scorecards/Landscape.png

Offline

 

#24 2010-08-18 15:20:51

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Python's "elif"

You mean like this?
If <>
Do ''
Else if<>
do ''
Else if <>
do ''
Else [v](selector to add another)
do ''
End if

Like that?


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#25 2010-08-18 19:55:04

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Python's "elif"

I support! I think that in place of the arrows, however, a little (+) button at the bottom of the block would be better, and a little (x) next to the deletable else-if constructs.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

Board footer