Python Variables Tutorial

365 Careers
A free video tutorial from 365 Careers
Creating opportunities for Business & Finance students
4.5 instructor rating • 57 courses • 985,511 students

Lecture description

In this lesson, we will start coding. We will also introduce you to one of the main concepts in programming – variables.

Learn more from the full course

Python for Finance: Investment Fundamentals & Data Analytics

Learn Python Programming and Conduct Real-World Financial Analysis in Python - Complete Python Training

08:14:45 of on-demand video • Updated April 2020

  • Learn how to code in Python
  • Take your career to the next level
  • Work with Python’s conditional statements, functions, sequences, and loops
  • Work with scientific packages, like NumPy
  • Understand how to use the data analysis toolkit, Pandas
  • Plot graphs with Matplotlib
  • Use Python to solve real-world tasks
  • Get a job as a data scientist with Python
  • Acquire solid financial acumen
  • Carry out in-depth investment analysis
  • Build investment portfolios
  • Calculate risk and return of individual securities
  • Calculate risk and return of investment portfolios
  • Apply best practices when working with financial data
  • Use univariate and multivariate regression analysis
  • Understand the Capital Asset Pricing Model
  • Compare securities in terms of their Sharpe ratio
  • Perform Monte Carlo simulations
  • Learn how to price options by applying the Black Scholes formula
  • Be comfortable applying for a developer job in a financial institution
English [Auto] All right great warm up your fingers in this lesson we will start coding. What are the main concepts in programming is variables. They are your best friends you will deal with them all the time. You will use them to store information. They will represent your data input. Let's say you want to have a variable x that is equal to the value of five. And then ask the computer to tell you the value of that variable. So we must tell the machine that X equals 5. And this is how you could do this in Python type X equals five to go through the process of programming the line that says X equals 5 is called a command or a program. This is just a line of text to make something out of it. We must execute it. Only then will the computer carry out operations with it. Press shift and enter not just enter and a variable called X will be created and assigned with a value of five to be more precise equality in Python and in programming means assign or bind to OK we carry this operation but we see nothing right now. How could we ask the computer to show us the output of what we just did. It would be sufficient to write X. And then press shift and enter. And here's the result five great as you can see typing in a single line of code. Intel's a few concepts of programming simultaneously in the next few lectures will make sure everything falls in place. Now let's assign the value 8 to a variable we call y. All right shift plus enter. And we can check why. However I'll type capital Y O an error. This shows us that Python is case sensitive. So pay attention to that. It matters if you use lowercase or uppercase letters an alternative way to execute the instruction that will provide the value we assigned to Y would be to use the print command at first sight. It seems redundant as we showed we can just type. Why. Nevertheless this command is applied often. You'll see it in most of the code produced by professionals. It complements the logical flow of your instructions. For instance if we say print why the machine will simply execute this command and provide the value of y as a statement. And this is all a programmer must see sometimes print exists in Python 3 as well. Its functionality is practically identical to the one just described for Python 2 with the sole difference that here. You must place the name of the variable within parentheses. In this case why then you can press shift and enter to execute the code in the cell and see that you will obtain an identical output. The number 8 the difference stems from the fact that Python 3 treats print as a function while Python 2. Rather as a command. But we will not dig deeper into explaining this as there's a whole section devoted to Python functions where everything about functions will become much clearer. Therefore from now on if you are using Python 3 and you see print followed by a name of a variable please just add parentheses around the variable name and you'll be good to go great. We hope you found this comparison useful. Now let's continue by talking about Python variables. The last thing I'd like to share with you in this lecture is you can assign a certain number of values to the same number of variables to create the variables x and y. We have to assign two values say one in two. We must separate each of the variables in each of the values with a comma. The parentheses here are not obligatory but we use them to improve the readability of our code. Now if I call X or Y separately the computer will correctly give me their respective values. It is very important that the number of variables on that line equals the number of values. Otherwise you'll get an error message. See. Great. This is a great start to our journey in Python. Make sure you go through the exercises attached to this lecture. We'll see you in the next one.