Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
[tutorial] If - elsif - else statments
Author Message
wtd

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".

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

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?

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

Here is a better tutorial (sorry tony). It's nice and in-depth.
http://compsci.ca/v3/viewtopic.php?t=14656
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 2 of 2  [ 26 Posts ]
Goto page Previous  1, 2
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: