Code: Select all
for x in card:
for s in suit:
print x+suit[s],
print
Dd
Code: Select all
for x in card:
for s in suit:
print x+suit[s],
print
Code: Select all
card = ('A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K')
suit = ('c', 'd', 'h', 's')
for x in card:
for s in suit:
print x + s,
print
btw, Klast, if you haven't installed ActiveState Python then you're making it hard on yourself.Python Docs wrote:6.6. The print statement
print_stmt ::= "print" ([expression ("," expression)* [","]]
| ">>" expression [("," expression)+ [","]])
print evaluates each expression in turn and writes the resulting object to standard output (see below). If an object is not a string, it is first converted to a string using the rules for string conversions. The (resulting or original) string is then written. A space is written before each object is (converted and) written, unless the output system believes it is positioned at the beginning of a line. This is the case (1) when no characters have yet been written to standard output, (2) when the last character written to standard output is '\n', or (3) when the last write operation on standard output was not a print statement. (In some cases it may be functional to write an empty string to standard output for this reason.)
Note
Objects which act like file objects but which are not the built-in file objects often do not properly emulate this aspect of the file object’s behavior, so it is best not to rely on this.
A '\n' character is written at the end, unless the print statement ends with a comma. This is the only action if the statement contains just the keyword print.
Standard output is defined as the file object named stdout in the built-in module sys. If no such object exists, or if it does not have a write() method, a RuntimeError exception is raised.
print also has an extended form, defined by the second portion of the syntax described above. This form is sometimes referred to as “print chevron.” In this form, the first expression after the >> must evaluate to a “file-like” object, specifically an object that has a write() method as described above. With this extended form, the subsequent expressions are printed to this file object. If the first expression evaluates to None, then sys.stdout is used as the file for output.
Never heard of ActiveState Python. I know some IDEs do a lot of helping you write code. But if it helps too much it might be a crutch that prevents me from learning the language at a deeper level. Would I be risking that if I used ActiveState Python?Ddrak wrote:
btw, Klast, if you haven't installed then you're making it hard on yourself.
Dd
I really like Notepad++ but I've never used Textpad so I can't compare.Barious wrote:If you're just looking for something that will assist, without being a full blown IDE, just get a decent text editor. My personal favorite is Textpad.
Nothing. It's not really an IDE, just a nice UI and (more importantly) help system built around the standard Python install. It has some debugging ability and stepping but if you really wanted that type of thing I'd just say to get PyDev working inside Eclipse (what I use at work).Klast Brell wrote:Never heard of ActiveState Python. I know some IDEs do a lot of helping you write code. But if it helps too much it might be a crutch that prevents me from learning the language at a deeper level. Would I be risking that if I used ActiveState Python?Ddrak wrote:
btw, Klast, if you haven't installed then you're making it hard on yourself.
Dd
Debugging is pretty nice once you get into it. I was pretty against it during school (lazy) but now I'm starting to see the use of it very clearly.Klast Brell wrote:I need to learn what step debugging and all that other stuff is.
Code: Select all
##define a function named rate score
##if the score is less than 1000 return "less than 1K"
##if the score is 1000 to less than 10000 "1-10K"
##if the score is 10K or more return "more than 10K"
def rate_score(score=0):
if score < 1000:
answer = "less than 1K"
elif score >= 1000 and score < 10000:
answer = "1-10K"
elif score >= 10000:
answer = "more than 10K"
else:
answer = "Huh?:"
return answer
#call the function several times and print the
#results for 50 5,000 50,000 and for passing it no value
scores=["",50,5000,50000]
for score in scores:
print rate_score(score)
My first thought was that it was trying to multiply the ASCII values of the double quotes together, but that value only gives us 1,156 which isn't larger than 10k. Since you are comparing an empty string to an integer, maybe python interprets that string as the maximum value an int could hold (much larger than 10k)?Klast Brell wrote: Am i passing an empty value correctly? I don't want to pass it a zero. I want to pass it a null. I think it's reading the quote marks as a value in and off themselves. How do you add an empty value to a list of integers?
A null value and an empty string are two very different things. Null basically says "I know what I am, but I don't have a value assigned to me yet" where an empty string is more "I know what I am, I have a value, but that value is empty."Klast Brell wrote:I want to pass it a null.