Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
198 views

Python Basics

Python is a high-level programming language that emphasizes code readability and uses significant whitespace. The document discusses installing Thonny, an integrated development environment for Python that supports stepping through code and visualizing concepts, making it well-suited for beginners. It also covers basic Python concepts like variables, data types that can be stored in variables, how to assign values to variables, and how to store user input in a variable.

Uploaded by

lunAr- creator
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
198 views

Python Basics

Python is a high-level programming language that emphasizes code readability and uses significant whitespace. The document discusses installing Thonny, an integrated development environment for Python that supports stepping through code and visualizing concepts, making it well-suited for beginners. It also covers basic Python concepts like variables, data types that can be stored in variables, how to assign values to variables, and how to store user input in a variable.

Uploaded by

lunAr- creator
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Basics — Getting Started

What is Python?
Python is an interpreted, high-level and general-purpose programming language.
Created by Guido van Rossum and first released in 1991, Python's design philosophy
emphasizes code readability with its notable use of significant whitespace. Its language
constructs and object-oriented approach aim to help programmers write clear, logical
code for small and large-scale projects.

Installing an Integrated Development


Environment
To install an editor, visit this link and find this box
in the top right-hand corner, then follow the
download steps and you will have your Text Editor
ready to go: https://thonny.org/.

I recommend using Thonny, as it is an integrated development environment for


Python that is designed for beginners. This means that you don’t have to install
python, which means that you can start writing code straight away! However, if you
decide to carry on with downloading, Python I suggest getting the latest python
release found at Welcome to Python.org

Afterwards, download a text editor to go with it (you can use notepad++ for example
that should be installed if you are on Windows or any other well-known text-editors
such as VS Code or Sublime text).

Right then! Back to Thonny! Thonny, supports different ways of stepping through the
code, step-by-step expression evaluation, detailed visualization of the call stack and a
mode for explaining the concepts of references and heap. This means that it will be
perfect for a beginner!

Continue to the next page to start learning the basics of Python! ->
Python Basics — Applying Variables

What exactly is a variable?


I like to think of a variable as a carboard box. A cardboard box in which you can store an object
of your choice. Then when you need to get its contents later, there’s a handy label on the side
telling you exactly what is inside that box. Now, here’s the more in-depth answer: In
programming, a variable is a container in which data is stored. The programmer can choose
any name for this variable, except the Python Keywords of course (see Index). It’s also noted
that you should call your variable something that reflects on what you have stored inside it.
For example, putting a notepad into a box and labelling the box as ‘Lampshade’ isn’t a very
good idea.

What types of data can be stored in a variable?


In a python, a variable can store a wide variety of data types such as Booleans, floats, integers
and strings. Note: this book will be focusing on the six standard data types: Numbers (floats,
int’s, long integers and complex numbers), Strings (Characters), Lists , Tuples, Dictionary’s
and Booleans.

How do I use a variable?


To store data in a variable, the name must be followed by an equal’s sign. For example, to
store the integer 2 in a variable named ‘number’ you would write this: number = 2. The stored
value (2) can be referenced using the variable’s name, followed by using the statement
print(number) This will output the stored variable – which is 2. You can also add the contents
of two variables together like so: var_1 + var_2 = var_3

Quick Tip: In Python, a variable must be assigned to something, otherwise Python will throw a
‘Not Defined’ error right in your face. We don’t want that do we?

Conclusion
A variable is used to store
information that can later
be accessed and used by
the program. If a variable is
not given any data, Python
says that there is a ‘Not
Defined’ error. There a 6
main data types: Numbers,
Strings, Lists , Tuples, Dictionary’s and Booleans.
Python Basics — Applying Variables Continued

Storing user input in a variable


To store user input, we must assign an input to a variable. This can be achieved by
writing the line: var = input(‘What is your name? ’) We can then use the data that the
user entered, add a friendly greeting, and print it out like so: print(‘That is a nice
name’ + var + ‘!’ ). By doing this, we have created our very first program that displays
our understanding of variables and user input!

You might also like