python variable types code example

Example 1: variables in python

#Variables
#Name your variable

myvar = 'Variable'
Number = 9

print(myvar, Number, 'are the variables I made')

Example 2: python variable

Python variable

Example 3: how to create a variable in python

variable1 = "value" # string
variable2 = 1000000 # integer
variable3 = 10000.0 # real/float
variable4 = True # boolean: True or False

Example 4: python declare int

x = 5

print(type(x))
# Output: <class 'int'>

Example 5: python data types

#use syntax: variable = value
#string
string = 'ASCII text'
#integer
integer = 1234567890
#float
floatnum = 123.456
#list(called arrays in other languages)
numlist = [1,2,3,4,5]
#dictionary(called objects in other languages)
dictionary = {'key','value'}

Example 6: declare float python

myfloat = 7.0