Hi, Python Variables


Joined
Jun 23, 2022
Messages
1
Reaction score
0
Hi, There can someone pls explain the python variable. I'm a beginner programmer and i need to understand it more better.
 
Ad

Advertisements

Joined
May 11, 2022
Messages
47
Reaction score
3
so there are several types a variable can be. Integer, Float, String, Array, True, False, Nil, Dictionary, or Object.
integer is clear, float means numbers after the decimal point, string is a group of letters or other symbols in parenthesis,
array is generally a list of related data, such as several integers, in square brackets, like so, [1,2,3,4,5]. you can immediately access a array value, by referring to it's index. the left most index is 0, so if you want the 3, x = [1,2,3,4,5]; x[2] will result as 3. True, False and nil are fairly self explanatory. dictionary is similar to an array, except the index instead of a number is a key word you assign to it.
exe. x = {chess : "queen", check : "king"}; x[chess] will resolve as "queen".
object is hard to describe, i like to think of it as a mini program. a collection of related variables, and functions.
note that a variable of any type can be reassigned to a different type at any point.
hope this helps
 
Joined
Jun 28, 2022
Messages
2
Reaction score
0
Variable is a container that store values. It is a name that is used to refer to memory location. In Python, we don't need to specify the type of variable because Python is a infer language and smart enough to get variable type.
 
Ad

Advertisements

Joined
Jul 27, 2022
Messages
2
Reaction score
0
Hello I know you have recieved answers, but i'm just gonna say also:

Variables are used to store data. For exaple, if i make a program where someone puts there name in (we'll say they put in jake), and i want to say 'Hello jake', I would do this:

PersonsUserName = Input(str('Please input a username> '))
print("Hello " + PersonsUserName)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top