Created
March 27, 2024 18:35
-
-
Save makwanadeepam/1c54b93d978be8e54db31db3e9deb241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initializing a variable (declaration is done at the time of initialization) | |
x=5 | |
y="Hello World" | |
truthValue=True | |
# variableName = value | |
# Primitives: bool, int, float, complex, string | |
booleanVariableTrue=True | |
booleanVariableFalse=False | |
integerVariable=5 | |
integerVariable2=-5 | |
floatVariable=5.5 | |
floatVariable2=-5.5 | |
# Name doesn't define datatype | |
# Datatype can be changed later | |
integerVariable=6.66 | |
complexVariable=6+4j | |
stringVariable="Hello World!" | |
print( | |
booleanVariableTrue, | |
booleanVariableFalse, | |
integerVariable, | |
integerVariable2, | |
floatVariable, | |
floatVariable2, | |
complexVariable, | |
stringVariable | |
) | |
# Type conversion: bool(), int(), float(), complex(), str() | |
print( | |
int(floatVariable2), | |
complex(floatVariable), | |
str(floatVariable) | |
) | |
# More on bool | |
# Everything except "", False, Empty Collection and 0 is false | |
print( | |
bool(""), | |
bool(False), | |
bool([]), | |
bool(0) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment