0% found this document useful (0 votes)
10 views

openSAP Python1 Week 1 Unit 2 Variab Presentation

This document discusses using variables in Python programs. It explains that variables store and allow access to data, like objects in the real world. Variables have names and can store one value at a time. Data is assigned to variables using the equals sign and can be read from variables without being consumed. The document also covers basic variable operations like naming, assigning values, and reading values.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

openSAP Python1 Week 1 Unit 2 Variab Presentation

This document discusses using variables in Python programs. It explains that variables store and allow access to data, like objects in the real world. Variables have names and can store one value at a time. Data is assigned to variables using the equals sign and can be read from variables without being consumed. The document also covers basic variable operations like naming, assigning values, and reading values.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Week 1: Python Fundamentals

Unit 2: Using Variables


Using variables
Variables are used in almost any computer program

▪ Computer programs handle data. And like real world


objects, the data must be accessible.
– In the real world you must handle real world
objects. You must place these objects somewhere,
and you must be able to find and access these
objects later on.
▪ In computer programs the data is placed in, and
accessed from variables.
▪ Important:
– A variable can store just one value at a given time.
– If the variable is read, the value is not consumed
and taken away. This is like a book: If you read it,
the words are still available later on.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. open.sap.com Slide 2
Using variables
Basic operations with variables

▪ Variables have names like x or length or


name_of_person.
– There are a few rules for variable names.
▪ Variables can handle data in two ways:
– Data can be assigned to a variable (write access)
– Data can be read from a variable (read access)
▪ Data is assigned to a variable by the = sign
– Example: x = 42
– The value (data) 42 on the right side of the = is
assigned to x
▪ Data can be read by simply calling the variable
– Example x = 2 * y
– The current value of y is read, it is multiplied with 2,
and the result is assigned to variable x

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. open.sap.com Slide 3
Using variables
Showtime

Now it’s time to get hands on


and start programming!

If you like, you can open the


Jupyter Notebook instructions
in parallel to the demo.

If you haven’t done so yet:


▪ Download the Notebook
▪ Start the Jupyter Server
▪ Open the Notebook

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. open.sap.com Slide 4
Using variables
Summary

In this unit you learned ...


▪ … that programs make use of variables
▪ … that data can be written into and read from
variables
▪ … that assignments in programming and assertions
in mathematics are not the same
▪ … that there are a few weird looking statements,
which are used regularly

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. open.sap.com Slide 5
Thank You!

Contact Information:
[email protected]

This under
This work is licensed work isa licensed
Creativeunder a Creative
Commons Commons Attribution-ShareAlike
Attribution-ShareAlike 4.0 International 4.0 International License.
License. open.sap.com Slide 6

You might also like