> Can anyone help me with teh problem of "converting a decimal number into its
> binary equivalent"??
this sounds like a homework problem, so no code here. however, the
answer is trivial once you realize that all integers are natively
available in any base, whether it be 2, 8, 10, 16, etc. sinc
cimjls wrote:
>
> number = int(raw_input("Please enter a number between
> 1 and 10: "))
> if number < 1:
> print "That is an incorrect number. Please try
> again."
> raw_input("Please enter a number between 1 and 10:
> ")
> if number > 10:
> print "That is an incorrect numb
> if number > 10:
> print "That is an incorrect number. Please try
> again."
Maybe you could do better if you check for all valid numbers first, and
finally if no valid number has been entered, then print an error
message, instead of checking for all possibilities of error. Hint: check
that
cimjls wrote:
> Here is what I need to do:
>
> Create an IF branching statement that will take the
> users input from 1-10 and return the English word for
> the number. (1 is One, 2 is Two, etc.) If the user
> enters a value outside of the range of 1-10, display
> an error message, and ask the u
> How do I get it to work after an incorrect number is
> entered? I am stuck on this and would appreciate and
> help or suggestions?
Use exception
>>> try:
... int("hoge")
... except(ValueError):
... print('incorrect')
...
incorrect
> elif number == 1:
> print "One"
> elif number == 2:
Here is what I need to do:
Create an IF branching statement that will take the
users input from 1-10 and return the English word for
the number. (1 is One, 2 is Two, etc.) If the user
enters a value outside of the range of 1-10, display
an error message, and ask the user to enter a valid
selecti
On Tue, 19 Sep 2006, [EMAIL PROTECTED] wrote:
> so, how register(?) all imported modules to convert all unicodes to
> str() with a coder, for eg. encode('cp1251')
Hi Emilia,
Unfortunately, this isn't so clean: changing the systemwide
default encoding may cause things to break. See:
ht
hi list
is there a way to solve the error in case of :
# ...
return str(val) #where val is unicode (eg val = u'u')
so, how register(?) all imported modules to convert all
unicodes to str() with a coder, for eg. encode('cp1251')
thanks in advance
-e-
-
Део и Фани
I missed the OP on this so if its already been done
to death, my apologies. But its such an important
point I'll risk repeating it...
> Bryan Leber wrote:
>> then exit. Right now I have something like this
>>
>> Size = len(argsList)
>> If size = 4
This is obviously pseudo code but in future wh
> You should be able to find a tutorial on this on-line somewhere.
>
> you know that
> decimal: 1 = binary: 0001
> decimal: 2 = binary: 0010
> decimal: 4 = binary: 0100
> decimal: 8 = binary: 1000
>
> Do you see the pattern here?
> It's powers of 2.
You can use the math approach or a slightly s
10 matches
Mail list logo