Jump to content
  • Advertisement
Sign in to follow this  
The Ice Master

Learning python

This topic is 4834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I decided to go with Python for my first language. I have been workin with it for about half an hour now, and its really fun! 1 minute into it I learned that typing in:
import sys; sys.exit()
will exit the program. I could just click the X, but thats cool too. ;) I kept reading, and I saw an example of an "if" statement, and tried to make one I made up.
the_world_got_blown_up = 1
if the_world_got_blown_up:
     print "We are screwed."
And after pressing enter twice, it said we are screwed! Heh this is great. :) I then learned for the if statement all I had to put was:
if 1:
I am learning slower at this point. It is talking about stuff like Unix, BSD, UTF, BOM, and stuff. Should I do something before trying to learn more so I can understand this? Or is this kind of stuff useless information that I should just skip?

Share this post


Link to post
Share on other sites
Advertisement
Unix and BSD are OSes (and your post makes it sound like you don't use them, so you can probably skip that). UTF is a character encoding. I don't know what BOM is. Maybe you meant DOM? Anyway, those are all things that you shouldn't need to get into for a while.

Share this post


Link to post
Share on other sites
Thanks. I also learned it was a calculator. It handled an incredibly complex simplifying problem in 1 second. (I just typed in about 6 lines full of numbers, multiplication, and division signs.)

*sigh*

Man I sound like a noob. Well, I am!

Share this post


Link to post
Share on other sites
Quote:
Original post by Roboguy
UTF is a character encoding. I don't know what BOM is. Maybe you meant DOM?

A BOM is a Byte Order Mark. UTF-* text files can have them at the beginning to indicate what endianness the file has (and, of course, the presence of a BOM also tells editors etc they are indeed dealing with an UTF encoded file).

Share this post


Link to post
Share on other sites
BOM in this context probably means byte order marker for Unicode files. You should learn that stuff probably eventually, but if you just want to write a game as soon as possible you can probably skip those topics for now.

Share this post


Link to post
Share on other sites
Ok, I am trying this variable thing now. (I guess you could call this a game - a very simple one.)

I have assigned the variables to numbers.

The variables are my 'characters', and the numbers are their body weight.

At the end, based on my logic (I never actually saw this was possible), I should be able to see how much they all weigh together on a scale.


idiot = 103
unusually_fat_man = 609
Me = 135
Car = 2500

Those are my variables and their assigned numbers.

Now I have the next little piece of code:

all_of_us_on_a_scale = idiot+unusually_fat_man+Me+Car


Now when I run this through, I get the error:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'me' is not defined


But it is defined! I defined it as Me = 135! Why does it pick on me?!

Pun intended.

Share this post


Link to post
Share on other sites
Haha, it's refreshing to see this kind of enthusiasm!

Have you seen this tutorial yet: http://www.freenetpages.co.uk/hp/alan.gauld/ ?

It's a great ground-up introduction to programming, with a strong emphasis on Python; seems like it could be useful.

Keep up the good attitude, and I wish you the best of luck!

Edit: as for your problem, Python is case sensitive, meaning 'Me' is different from 'me'; make sure that you've been consistant in your capitalisation, because it looks like that could be the problem (interpreter output has lowercase 'm' in 'Me').

Share this post


Link to post
Share on other sites
Look at the error, it is telling you that me is undefined. me and Me aren't the same thing. A good many programming language are case-sensitive. Python is one of them.

Share this post


Link to post
Share on other sites
I already had a look at that. I have them both as "Me". What else could it be?

Edit: I assigned the same thing to
me
, and put
me
as
us_on_a_scale
, and it worked. Are caps not allowed?

Share this post


Link to post
Share on other sites
Caps are allowed, but, as has been said before, everything is case sensitive so you'll need to be careful.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!