Python 3 Programming Tutorial: Variables

Python

Video is ready, Click Here to View ×


In almost every single Python program you write, you will have variables. Variables act as placeholders for data. They can aid in short hand, as well as with logic, as variables can change, hence their name.

Variables help programs become much more dynamic, and allow a program to always reference a value in one spot, rather than the programmer needing to repeatedly type it out, and, worse, change it if they decide to use a different definition for it.

Variables can be called just about…

46 thoughts on “Python 3 Programming Tutorial: Variables

  1. Hey, thank you for your tutorial.
    I have question. (to anyone here)
    How could I do something like this:

    characters = [character1, character2]
    traits = [ ["Good", "Professional"] , "Bad"]

    So assign "Good" and "Professional" to character1 and "Bad" to character2.
    And how can I get the values of traits by just asking for character1 or 2.
    I know I could ask for characters[0] and traits[0] and traits[1], but I want to have it tagged to the character. Is this possible?

    Sorry if that is very easy, I'm a beginner 🙂
    Thanks in advance!

  2. Hi i just started doing programming and i have 3 questions on assignments that o just can't work out ! I need help please

    Question 1: The if statment that validates variable x for a value between 500 and 5000 (both included) is :
    Possible answers given :
    1. If(500x<=x<5000):
    2. If(x>=500 and x<=5000)

    Question 2:
    What is the value of num4 after executing the following code?
    num1=2
    num2=3
    If(num1%num2 != 0 ) :
    num4=2*num1+num2
    elif(num2%num >0) :
    num4=num1+num2*2
    else:
    num4=num1+num2
    Possible answers:
    1. 14
    2. 12
    3. 8
    4. 7

    Question 3:
    The format code for an integer variable is….

    Possible answers:
    1. %f
    2. %e
    3. %d
    4. %c

  3. Great tutorials, but I am confused
    variable=print ("hello")

    Output
    hello

    BUT when I write.
    variable=print ("hello")
    variable("yes")

    Output.
    hello
    Error: nonetype object is not callable

    And when I write.
    variable=print
    variable(yes)

    Output.
    Yes
    I'm confused please help

  4. Thanks for helping me my brother learned from u and now made an app and is going to R.I.T this September and he started to teach me and told me to watch u if i want to learn more and its really helping i subscrubed thanks a ton!

  5. this error is coming in python please help
    Command "c:python27python.exe -u -c "import setuptools, tokenize;__file__='c:\users\gaurav\appdata\local\temp\pip-build-khdrkc\scipy\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, _file_, 'exec'))" install –record c:usersgauravappdatalocaltemppip-vz8ua7-recordinstall-record.txt –single-version-externally-managed –compile" failed with error code 1 in c:usersgauravappdatalocaltemppip-build-khdrkcscipy

  6. when we do like d=print("hello world") we get hello world but after that statement when we try to print d it returns none.Generally, If a function returns a value that should store in a variable right but in this case, it did not store the value what's the reason.And can you tell me for example int a=10 and when we try to print "a" it's returns an error.And can you tell me how to use data types on variables and how to print values of them and how to access those variables.

Leave a Reply

Your email address will not be published. Required fields are marked *