Forums

ForumsProgramming Forum

How do I Turing?

Posted Sep 25, '12 at 9:11pm

BRAAINZz

BRAAINZz

797 posts

So, I am in Grade Ten Programming and we're primarily using Turing with a dash of C# and I want to ask you something: How do I make the computer recognize all numbers within certain parameters during an if?

Or if you would rather:
Eg.

if answer = 1 through 5
then
put "blah-blah."
end if

Something like this, but I can't figure it out.

I want to do this because my class hasn't learned this yet and I feel like going a bit "Above and Beyond" because the work is boring and I feel like making it more entertaining with Easter eggs because I don't want to lose interest half-way through the course.

Please help.

 

Posted Sep 26, '12 at 3:43am

gaboloth

gaboloth

1,635 posts

I'm not sure I have 100% understood your question, but it seems you should use those "less than or equal to", "greater than or equal to" things:

if (answer >= 1 && answer = 1 && answer

 

Posted Sep 26, '12 at 3:49am

gaboloth

gaboloth

1,635 posts

Uh, I think my post either didn't show up, or it showed up wrong... let me try again...

I'm not sure I have 100% understood your question, but it seems you should use those "less than or equal to", "greater than or equal to" things:

if (answer >= 1 && answer = 1 && answer

 

Posted Sep 26, '12 at 3:53am

gaboloth

gaboloth

1,635 posts

I apologize, I didn't think the &lt signs would have messed up with the HTML...

I'm not sure I have 100% understood your question, but it seems you should use those "less than or equal to", "greater than or equal to" things:

if (answer &gt= 1 && answer &lt= 5)
{
put "blah-blah."
}


I don't know Turing so I wrote this in AS3 syntax, tell me if you have trouble understanding it. However, this is what I think it should look like in the language you're using:

if answer &gt= 1 && answer &lt= 5
then
put "blah-blah."
end if

 

Posted Sep 26, '12 at 6:11pm

thepunisher93

thepunisher93

1,863 posts

in python:-
>>>If answer in range[4:10]:
>>> print " bla bla"
>>>else:
>>> print "BS BS BS"
>>>bla bla bla

 

Posted Sep 27, '12 at 7:32pm

BRAAINZz

BRAAINZz

797 posts

[quote]if answer >= 1 && answer

 

Posted Sep 27, '12 at 7:39pm

BRAAINZz

BRAAINZz

797 posts

Sorry, my post got cut off.

[quote]if answer >= 1 && answer

 

Posted Sep 27, '12 at 7:42pm

BRAAINZz

BRAAINZz

797 posts

This is getting stupid, the site won't post my whole post.

I'll try again. gabolath, good idea, but they wouldn't work. The compiler says that it requires Booleans, which makes little sense to me because Booleans are normally "True" or "False" right? I'll see what my teacher has to say.

 
Reply to How do I Turing?

You must be logged in to post a reply!