![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Programmer
Join Date: Nov 2007
Posts: 64
Rep Power: 1
![]() |
Re: I'm a Beginner
ok that made absolutely no sense
Anyways I need to stop programming since the computer I had the command line on, I had to blow the hard drive away because of problems. The computer had originaly came with 95 but got upgraded with 98SE. The 98SE CD suddenly decided not to work (I checked it before I re formatted the computer and it worked). Then I tried XP. But XP is just to big and causes the computer to freeze right after I log in. This means I am going to have trouble reformating again, even though I got 98SE loaned to me. If you didn't understand any of that you will know why I say, I HATE COMPUTERS lol
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. |
|
|
|
|
|
#22 |
|
Programmer
Join Date: Jun 2007
Posts: 99
Rep Power: 2
![]() |
Re: I'm a Beginner
|
|
|
|
|
|
#23 |
|
Programmer
Join Date: Nov 2007
Posts: 64
Rep Power: 1
![]() |
Re: I'm a Beginner
how?? it freezes when I press the start button and I am having trouble with safe mode. (I tell it to run safe mode and a list of commands pop up, then it freezes.)
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. |
|
|
|
|
|
#24 |
|
Programmer
|
Re: I'm a Beginner
Xubuntu isn't a piece of windows software; it's an Ubuntu-linux derived operating system that is supposed to work well with older / slower hardware. Python comes preinstalled, so it would make continuing your education a simple matter.
|
|
|
|
|
|
#25 |
|
Programmer
Join Date: Nov 2007
Posts: 64
Rep Power: 1
![]() |
Re: I'm a Beginner
but I can't even go online to install it. Or get into windows long enough to put in a disk I burn from this computer.
Anyways could someone tell me if this would work. This is my very first original program, even though it is just a single loop. For i in b
print '%d*%d=%d' % (i,b,i*b)
i= range (1,13)
b= range (1,11)
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. |
|
|
|
|
|
#26 |
|
Programming Guru
![]() |
Re: I'm a Beginner
No it would not. Let's look at what you're trying to do:
1) First Line For i in b Commands are case sensitive. For is not a valid command. for is the command you're looking for.It assigns i to each element in b sequentially. But what's b? You have not defined it at this part of the program. Remember that a program executes one line at a time, and at this point in time, there is no value for b.Later you do give a value to b: b= range (1,11). If you want to stay consistent with this, your first line becomes:for i in range (1,11) Then you need a colon at the end to denote the start of a new block. Everything that proceeds the colon, and is indented, will execute for each element in b. for i in range(1, 11):
# Do some stuff here for each element in range(1, 11)It's important to note... since b is range(1, 11), Python will convert this to [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].So the same code could also be written as: for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
# Do some stuff here for each element in range(1, 11)But that's not as modifiable. 2) Looking at your Second Line print '%d*%d=%d' % (i,b,i*b) You're trying to output i*b and b, but b is a list of elements 0 through 10. That's an invalid operation. You can't multiply numbers by lists. It looks like you're trying to do something like multiply 1 to 11 by 1 to 13 like a grid. You'll need to understand for loops a bit better before you can do that. 3) Using a for loop If we go back to my previously posted code, and modify it to print the number each iteration: for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
print iYou get the output: 1 2 3 4 5 6 7 8 9 10 Which will be the same output for: for i in range(1, 11):
print iIf we extend this to make a loop within a loop, you'll get this: for i in range(1, 11):
for j in range(1, 11):
print i, jWhich will output: 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 4 9 4 10 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 5 9 5 10 6 1 6 2 6 3 6 4 6 5 6 6 6 7 6 8 6 9 6 10 7 1 7 2 7 3 7 4 7 5 7 6 7 7 7 8 7 9 7 10 8 1 8 2 8 3 8 4 8 5 8 6 8 7 8 8 8 9 8 10 9 1 9 2 9 3 9 4 9 5 9 6 9 7 9 8 9 9 9 10 10 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 You could then modify this to do the multiplication grid you wanted. Last edited by Sane; Dec 12th, 2007 at 6:50 PM. |
|
|
|
|
|
#27 |
|
Programmer
Join Date: Nov 2007
Posts: 64
Rep Power: 1
![]() |
Re: I'm a Beginner
I think I will continue "paper" programming and run them once the computer is up and running
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. |
|
|
|
|
|
#28 |
|
Programmer
Join Date: Nov 2007
Posts: 64
Rep Power: 1
![]() |
Re: I'm a Beginner
I have decided to try making a text adventure game. This seems easy as it is simply a bunch of documents that you open by moving in directions. Of course a combat system is way beyond me
here is what I wrote, I know I am wrong but here is what I mean to do
1=Beginning of yellow brick road
2=Middle of yellow brick road
3=End of yellow brick road, yeah! you just played my first game and wasted 10 seconds of your life
#level= 1 2 3#
east= %d + %d = %d % (1, the number you are currently on, the solution)So if you see what I am trying to do please walk me throught what i need to do to create this.
__________________
There are 10 kinds of people in this world, those who can read binary and those who can't. |
|
|
|
|
|
#29 |
|
Expert Programmer
|
Re: I'm a Beginner
Actually you can, and the result is sensible:
>>> print '%s' % ([1,2] * 2) [1, 2, 1, 2] |
|
|
|
|
|
#30 | |||
|
Programming Guru
![]() |
Re: I'm a Beginner
Quote:
@Chuckiferd: As far as a "proper" implementation of this idea can go, it would take some familiarity with Python. For a personal learning exercise, I'd say just go with if, print, and input statements. Those three things in conjunction could make your game. If you want to actually do visible movement, you won't be able to do it this way... A print statement outputs something to the user: print "You Are At The Beginning Of A Yellow Brick Road" The input function gets something from the user: choice = input("""What do you want to do?
1) Walk In To The House
2) Pick Up A Penny Off The Ground
3) Twiddle Thumbs
Enter A Number: """)That will output to the screen: Quote:
An if statement can branch your program in an alternate direction, according to the value of a variable. So if we wanted to do one thing if the user selected "1", and another if the user selected "2", it's as simple as: if choice == 1:
# The user selected 1. Do something here.
elif choice == 2:
# The user selected 2. Do something different here.
else:
# The user did not select 1 or 2. Make it default to option #3. And do something else!These three things, "if", "print", and "input" could be combined to make your text adventure: Python Syntax (Toggle Plain Text)
Get it? Here's an example of me running the programming, and playing the adventure: Quote:
|
|||
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Beginner Problem | proudnerd | C++ | 16 | May 18th, 2006 6:48 PM |
| call of a beginner | web_master | HTML / XHTML / CSS | 34 | Dec 6th, 2005 12:08 AM |
| function help for a beginner | melee28 | C | 6 | Sep 5th, 2005 9:45 AM |
| what open source code is good to read for a beginner? | linuxpimp20 | Other Programming Languages | 22 | Aug 30th, 2005 3:01 PM |
| Beginner program problem (else if) | Hadrurus | Java | 13 | Aug 14th, 2005 7:07 PM |