Posted: Tue Dec 20, 2005 12:14 am Post subject: (No subject)
thuvs wrote:
'If's are nice but case statments become lot easier and faster when you are dealing for known values like yes and no or 1 and 0!
code:
var answer : string
loop
put "Is compsci.ca cool?"
get answer
case answer of
label "Yes", "Y", "yes", "y" :
put "You are so right"
exit
label "No", "no", "n", "N" :
put "Are you crazy?"
exit
label :
put "You did not answer correctly!"
end case
end loop
You're doing too much work. Make the answer all upper or lowercase and you can cut the number of things you're looking for in half. Plus, you don't have to think about things like "nO" or "yEs".
Sponsor Sponsor
Guest
Posted: Mon May 29, 2006 8:47 pm Post subject: (No subject)
theguru wrote:
this tutorial has everything you need to know about the if statement. i was wondering why turing has elsif instead of elseif. isn't that wierd.
Why not elif? =p
wtd
Posted: Mon May 29, 2006 9:08 pm Post subject: (No subject)
vahnx wrote:
theguru wrote:
this tutorial has everything you need to know about the if statement. i was wondering why turing has elsif instead of elseif. isn't that wierd.
Why not elif? =p
Because that is widely considered to be one of the less than wonderful quirks of Python syntax.
kay188
Posted: Wed Dec 06, 2006 7:19 pm Post subject: Re: Im using Turing 4.0.4c Problem
Namis wrote:
this is my code, im new so bare with me :\
var one:string
var two:string
put " Yes or No? "
if one = "Yes" then
put " Good Choice! "
elsif No = "No" then
put " Bad Choice! "
Im getting an error in
elsif No = "No" Then
Whats wrong? Thanks
you're missing somethings in there
try this
code:
var one : string
put " Yes or No? "
get one
if one = "Yes" then
put " Good Choice! "
elsif one = "No" then
put " Bad Choice! "
end if
tooring
Posted: Mon Dec 11, 2006 9:43 pm Post subject: (No subject)
learned some new stuff, thanks
Clayton
Posted: Mon Dec 11, 2006 9:52 pm Post subject: (No subject)
It's very nice that you learned some new stuff, but we generally discourage just posting to say "good stuff". Please refrain from doing so in the future. Other than that, welcome to CompSci!
[Gandalf]
Posted: Tue Dec 12, 2006 8:19 pm Post subject: (No subject)
Freakman wrote:
It's very nice that you learned some new stuff, but we generally discourage just posting to say "good stuff". Please refrain from doing so in the future. Other than that, welcome to CompSci!
Nothing wrong with saying "thanks" once in a while...
There is, however, something wrong with being nitpicky with every thread, and replying for the sole purpose of critisizing a post that, really, didn't break any rules. Just something to ponder about, no harm done.
Reira
Posted: Fri Nov 02, 2007 3:07 pm Post subject: (No subject)
code:
var answer : string
loop
put "Is compsci.ca cool?"
get answer
case answer of
label "Yes", "Y", "yes", "y" :
put "You are so right"
exit
label "No", "no", "n", "N" :
put "Are you crazy?"
exit %is this the only option?
label :
put "You did not answer correctly!"
end case
end loop
When an unwanted value has been input, the "exit" command is usually input. But is it possible to continue the program after this happens, without exiting it, such as goto but without the need of inputting another loop? In general, is it possible to clear the value of a variable after it has been defined (through "get"), within an "if" statement?
Sponsor Sponsor
CodeMonkey2000
Posted: Fri Nov 02, 2007 7:27 pm Post subject: RE:[tutorial] If - elsif - else statments
variable:=""%or what ever you like.
And you do realize that you are posting in thread that is nearly four years old?
Reira
Posted: Fri Nov 02, 2007 7:40 pm Post subject: RE:[tutorial] If - elsif - else statments
lol umm well it was on the first page...
Thanks for bringing it to my attention, though!
I'll watch better next time ^^
CodeMonkey2000
Posted: Fri Nov 02, 2007 7:51 pm Post subject: Re: [tutorial] If - elsif - else statments