Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

python problom

Name: Anonymous 2009-07-17 14:10

hi im lerning python and i need help with this i try to make lots of ifs but its not working well it looks funny heres my code

c=3

if c==1:
    print'one'
else:
    if c==2:
        print'two'
    else:
        if c==3:
            print'three'
        else:
            if c==4:
                print'four'
            else:
                print'no number'


i want to make one for 1 to 100 but if i keep going it will get to big what do i do help plz

Name: Anonymous 2009-07-17 14:17

what is this I don't even

Name: Anonymous 2009-07-17 14:18

Nice indentation. FIOC LOL etc.
In any case, 1/10 i responded

Name: Anonymous 2009-07-17 14:18

print {1: 'one', 2: 'two', 3: 'three', 4: 'four'}.get(c, 'no number')

Name: Anonymous 2009-07-17 14:21

Just define a string array with 100 elements, each containing its index corresponding english number. THen just take whatever c is, cast it to an int, put it in the array index and PRESTO!

Name: Anonymous 2009-07-17 14:23

>>4
Needs more indentation.

Name: Anonymous 2009-07-17 14:45

>>1
lololol I get it xD FIOC xD

Name: Anonymous 2009-07-17 15:01

>>1
>c=3
haha, an asian penis

Name: Anonymous 2009-07-17 15:06

>>1
And this is why you shouldn't teach FIOC as a first programming language

Name: Anonymous 2009-07-18 7:44

>>9
Because idiots exist? There's no language that will guard against that.

Name: Anonymous 2009-07-18 7:53


(format t "~R" (read))
123
one hundred twenty-three

Name: Anonymous 2009-07-18 8:16

>>11
Where's my and?

Name: Anonymous 2009-07-18 8:28

>>12
At the end of your arm, stupid.

Name: Anonymous 2009-07-18 9:09

>>13
But I'm on i386 :(

Name: Anonymous 2009-07-18 18:53

lol u stupid op it werk fine c i did it u dumb

http://i27.tinypic.com/308gy9y.jpg

Name: Anonymous 2009-07-18 18:56

>>15 YHBT, IHBT, WHABT

Name: Anonymous 2009-07-18 18:56

>>12
What about you are and?

Name: Anonymous 2009-07-18 19:42

>>12
Shouldn't it be "at the end of your rm"?

Name: Anonymous 2009-07-18 20:42

elif says hi.

Name: Anonymous 2009-07-18 20:48

>>19
[b][i]Don't Help Him![/i][/b] What's next? Tell him that for large numbers of items he should dispatching based on a dictionary? What is /prog/ coming to?

Name: Anonymous 2009-07-18 21:09

I wrote some code like this on here a while ago, let me find it.

Ahh, here we go. http://dis.4chan.org/read/prog/1242279244
See post 11.

Name: Anonymous 2009-07-18 23:12

>>21

Isn't avoiding this kind of shit the reason they invented the decimal system in the first place?

Name: Anonymous 2009-07-18 23:46

>>22
No, they invented it because they're fags. 10 is a bad base.

Name: Anonymous 2009-07-19 0:48

10 is a bad base
explain

Name: Anonymous 2009-07-19 2:02

>>24
Divisible by: 2, 5. Shitsux. Even 12 would be more usefully divisible, with 2, 3, 4, 6.

But what we ought to do is this thing: convert to base 360 wholesale to unify our system of angle measure with our other calculations.

Name: Anonymous 2009-07-19 2:12

>>25
Yeah, let's add 350 more digits just so it's easier to do trig.

Name: Anonymous 2009-07-19 2:25

>>26
Trig is a special case. Radians are more appropriate than degrees. Also you act like 350 more digits would be less than awesome.

Name: Anonymous 2009-07-19 8:15

>>26
Enjoy multiplying by PI/180 when you write code in a serious language.

Name: Anonymous 2010-12-09 18:43

Name: Anonymous 2013-01-18 23:47

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List