Stuck at boolean


#1



I am very new to coding but its a faciating skill that i wil love to master..i am currently stuck at boolean pretty much the second task in python Set the following variables to the corresponding values: my_int to the value 7 my_float to the value


#2

You will want to assign the variable my_int to 7. In this case your code would look like

my_int = 7

You would repeat this with my_float as well. If they want a boolean, it would look like:

my_float = false


#3

i coded
my_int=7
my_float=flase
my_bool=true

but its not working the, here is the results......
Traceback (most recent call last):
File "python", line 2, in
NameError: name 'true' is not defined


#4
int    =>  Integer
float  =>  Real
bool   =>  Boolean

Python integer  =>  -99, -1, 0, 1, 99
Python float    =>  -99.1, -1.0, 0, 1.1, 9.90
Python boolean  =>  True, False

#5

here is the second result when i code following this instructions below
my_int=7
my_float=1.23
my_bool=true

result is Traceback (most recent call last):
File "python", line 3, in
NameError: name 'true' is not defined

not sure why its not working.....thanks for your help


#6

Check my previous post, the booleans.


#7

thanks for the help, how would you put it in a code ?
i did enter your what you wrote but the result was the same ?


#8

The way you have, just with the correct (valid) token: True or False.

Style guide note:

White space is free, and very helpful if we use it consistently.

my_bool = False

The space on either side of the operator is recommended in most style guides. It lets the operator stand out for better readability.


#9

I know I feel stupid just because I don't know what to do.


#10

Lol i feel a little stupid not sure... why its not working following your intructions.
my_int= 7
my_float= 1.23
my_bool= true or flase..

here is below the result, am not sure what am doing wrong.

Traceback (most recent call last):
File "python", line 3, in
NameError: name 'true' is not defined


#11

Python bool type includes only , False, or, True. The capital is important.


#12

thanks so much, it worked... my_bool=True or False
the result is NONE


#13

That may be ignored It is console behavior that hasn't been filtered out.


#15

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.