New in python,questions at the numbers datatype


#1

You are going shopping. Let’s make a grocery list so that you can plan your budget.

Store the number of cucumbers you want to buy in a variable called cucumbers. Make sure it’s at least 1, and that it’s the appropriate datatype! The store doesn’t sell partial cucumbers.

so I declare int cucumbers=1

but when i run it, it says wrong.


#2

You are thinking Java, but in python you don’t need the int. The way you define variables in python is like this:

variableName = "yourString"
variableName2 = 4
variableName3 = True

(@mtf https://www.codecademy.com/courses/learn-python/lessons/python-syntax/exercises/numeric-datatypes?action=resume_content_item)


#3

python automatically assigns the right data type, this is different from language like C and Java where you have to specify the data type.


#4

Please post a link to the exercise you are on or this topic will never make sense.


#5

Huh, for some reason I wasn’t able to reply but its good now(which was why I put the link in my original post).


#6

Thank you so much! Now I got it


#7

ok I got it I was wondering why it would be wrong, thank you !


#8

@gtang2015 Awesome! Congrats :tada:


#9

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