Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
39ce3d1
Added favicon to assets
shorodilov Nov 24, 2022
69cede0
Updated dependencies
shorodilov Nov 24, 2022
f6f393f
Updated project dependencies list
shorodilov Jan 28, 2023
2907c50
Added problem sets
shorodilov Jan 28, 2023
f9abecb
Updated Sphinx configuration
shorodilov Jan 28, 2023
5081108
Added bibliography
shorodilov Jan 28, 2023
780c735
Introduction to Python (#28)
shorodilov Jan 29, 2023
1236535
Moved images to "assets"
shorodilov Jan 29, 2023
2771c8f
fix Django initial lectures
vladyslavPonomaryovInBev Jan 21, 2023
433ec09
Add details how to push HWs
vladyslavPonomaryovInBev Jan 26, 2023
e748688
Added 'make all' instruction (target)
shorodilov Jan 29, 2023
2c556fb
Added appx.: userful software list
shorodilov Feb 4, 2023
2421ebf
Added docker to software list appx
shorodilov Feb 18, 2023
d95c3a3
Minor change - updated appxs headings
shorodilov Mar 12, 2023
f30d64f
Added operator precedence appendix
shorodilov Mar 12, 2023
98d86d2
Added string formating appendix
shorodilov Mar 13, 2023
120e1aa
Added appendecies files to Sphinx builder config
shorodilov Mar 13, 2023
2b0b981
Completed variables document
shorodilov Mar 12, 2023
5360ef0
Added syntax document
shorodilov Mar 12, 2023
db3d149
Updated data types overview
shorodilov Mar 12, 2023
028224c
Updated strings: indexes, slices, immutable
shorodilov Mar 12, 2023
e160272
Added string operations
shorodilov Mar 12, 2023
2ea10d6
Rebased 'feature/basics' onto 'devel' branch
shorodilov Mar 13, 2023
fb1c218
Added general sequence types description and operations
shorodilov Mar 12, 2023
7d945ac
Updated numeric types with values comparison section
shorodilov Mar 12, 2023
fcb9b41
Updated sequences types with value comparison section
shorodilov Mar 12, 2023
3cc83ba
Updated sets types with values comparison section
shorodilov Mar 12, 2023
4e38fd5
Minor changes in subsection headings
shorodilov Mar 12, 2023
3ab42da
Updated mapping type with value comparison section
shorodilov Mar 12, 2023
57f4267
Update string type with value comparison section
shorodilov Mar 12, 2023
79ed5e8
Added list operations
shorodilov Mar 12, 2023
7e4591a
Added list constructor
shorodilov Mar 12, 2023
0578406
Added tuple constructor
shorodilov Mar 12, 2023
19c3515
Added string methods placeholder
shorodilov Mar 12, 2023
e2d8239
Added brief mapping type description
shorodilov Mar 13, 2023
9894683
Removed deprecated datatypes file
shorodilov Mar 17, 2023
f856c5a
Fixed "stdtypes" footnotes
shorodilov Mar 21, 2023
f1ceb5f
DB - Aggregate functions
shorodilov Mar 23, 2023
3d47126
DB - Group by and having
shorodilov Mar 23, 2023
1fc36bf
DB - Normalization
shorodilov Mar 23, 2023
fe41592
DB - Relationships
shorodilov Mar 23, 2023
eb9213c
DB - Joins
shorodilov Mar 23, 2023
b668174
Merge branch 'gh-pages' into feature/basics
shorodilov Mar 23, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Completed variables document
  • Loading branch information
shorodilov committed Mar 13, 2023
commit 2b0b981b2bbaa3586f8eeef6e1a19923093d7ad8
51 changes: 45 additions & 6 deletions src/basics/variables.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,51 @@
Variables
*******************************************************************************

Variables are container for storing data. There is no syntax for declaring
variables in Python. A variable is created the moment you first assign a value
to it.
In computer science a **variable** is a named storage location in memory that
can hold a value (*data*). The value stored in a variable can be changed or
accessed by the program during its execution.

In Python, variables are created dynamically once a value is assigned to them.
This makes Python a dynamically typed language, which means that the data type
of a variable is inferred from the value assigned to it. So, you do not need
to declare a variable before using it, as in statically typed languages.

The ability to create variables dynamically and infer their data type makes
Python code more concise and easier to read. However, it also requires careful
attention to variable naming and assignment to avoid unexpected behavior.

In Python ``=`` (assignment operator) is used to set a value to some variable,
the portion on the left of the operator is a *variable name* and the portion
on the right is a *value* to assign to a variable.

.. code-block:: python
:caption: Variable assignment in Python

number_of_students = 10
greeting = "hello"
pi = 3.14

.. code-block:: java
:caption: Variable assignment in Java

int number_of_students = 10;
String greeting = "hello";
double pi = 3.14;

Naming
======

In Python there are several rules that describe how to name your variables.
Some of these are requirements and cannot be ignored, others are rather
recommended than required and can be omitted. For now note, that a variable
name **cannot**:

- a language keyword (like ``pass``, ``def`` or ``class``)
- start with a number (e.g. ``123``, ``1_something``)
- contain special operators in it (``+``, ``-``, ``=`` etc.)
- contain white spaces

Also here are some general recommendation on naming anything:

foo = 42
bar = "some string data"
foobar = 42.0
- do not use built-in functions as a variable name (e.g. ``len = 42``)
- keep names meaningful (``x = 10`` vs ``number_of_student = 100``)