how to make a variable in python

Solutions on MaxInterview for how to make a variable in python by the best coders in the world

showing results for - "how to make a variable in python"
Heston
16 Nov 2018
1my_name = "your name here "# you can add perenthisis
2print(my_name)
Constanza
16 Oct 2018
1# in python you can declare a variable by simply typing the variable name and assigning a value to it, no keywords needed. like so:
2
3variable_name = 'value'
4
5# there are 4 types of values you can store in python, just like most languages.
6
7# a string: 'Helo word!'
8# an integer: 1010001
9# a float: 1010101.7
10# and last, a boolean: True or False
11
12# when you have declared a variable you can call it by simpely typing its name
13
14print(variable_name)
15
16# happy coding!
Paul
11 Jan 2019
1Python Variables are like boxes that store some values
2
3Example of delcaring a variable:
4
5number = 1
6name = "Python"
7isUseful = True
8number_2 = 1.5
Mattia
10 Apr 2018
1variable = 2
Riccardo
17 Sep 2018
1variable_name = "what your variable stores."
2number = 633.098
3print(variable_name)
4
5#you can also print things together
6print(variable_name, number)
7
8#you can also put them in loops
9running = True
10while running:
11  for i in range(5):
12    print(number)
13  running = False
14  
15#you can use variables for math
16number = 10
17number2 = 30
18print(number+number2)
19  
Victoria
15 Mar 2017
1integer = 4 #int
2string = "STRING" #string
3boolean = True #Boolean. Can set it to False, too