If you want to learn programming but have little to no experience, congratulations, you have come to the right place. Python is an excellent choice for the absolute beginner to get started. There are various Python desktop tools available to make the task easier, let’s take a look a selection of them now.
Table of Contents
1. How to install Python?
Obviously, you have to install python on your computer in order to start using it. It is available for download from python.org or alternatively, you can search for the Anaconda distribution that comes with various packages pre-installed.
2. Which version of Python should I use?
The Python language got some major modifications, including syntax changes, making old scripts and packages incompatible. For example, in Python 2, the print statement did not use brackets but in Python 3, you need to give the variable to be printed as an argument to the print function. Version 2.7 got retired in 2018, so a beginner should definitely start learning Python 3.
3. What computers can run Python?
Python is available for Windows, Mac and Linux computers, so you can use it practically anywhere, even on your phone, though that quickly becomes tedious when you have just a touch keyboard. Python code is portable and can be executed anywhere as long as the required packages are installed.
4. How to run Python Desktop?
The default Python installation allows you to call Python directly from a terminal, though that can be overwhelming if you have little experience with the command line. In fact, it is recommended to use it through a graphical user interface. There are various IDEs, such as the free feature-rich PyScripter available for download here.
5. What is Python good for?
Python is a versatile language, and being easy to use means that there are libraries for virtually anything. It is used in countless fields, from running components of the Linux operating system to simple everyday scripting, data visualization and scientific research, including data science and machine learning. In my professional experience as a software developer, I have also used Python to prototype algorithms to be later translated to C.
6. What is Python not suitable for?
As versatile as Python may be, it comes with some limitations. For example, simple microcontrollers that come with just barely kilobytes of memory are not capable of running Python code. Yet, in the future that might be possible, too. The MicroPython language is being developed, so you can even program an Arduino with sensors without having to learn C. This is yet another reason why it is worth learning Python.
7. How stable is Python?
Python programs are stable, and the good thing about them compared to C, for example, is that Python cannot crash your computer easily since the Python interpreter would catch the problem before the computer hangs.
8. How fast is Python?
Some old-school seasoned programmers may complain that Python is slow. This is true in some cases when comparing the performance to a C or a Fortran program. However, some libraries are written in C, meaning that there is little to no sacrifice in speed, combined with the elegance and ease of Python coding.
9. How to structure Python code?
Python is sensitive to the number of tabs and spaces. This can be annoying at first but it actually keeps the code nice and tidy. There are tools to ensure that there are no redundant spaces or cases with tabs and spaces mixed together. A GUI helps massively with the task.
10. How difficult is it to get started with Python?
Python is quite easy to use once you grasp the basics of programming. It doesn’t require learning memory management, compilation and complicated debugging tools from the very beginning, though these concepts should definitely be on your to-learn list.
11. How to learn Python?
You only learn programming by doing it. Reading tutorials and books will give you background knowledge but you have to roll up your sleeves and start trying. You will inevitably run into errors, though, they are your opportunity to learn the language and programming as a whole.
12. Where to start when learning to program in Python?
The best way to learn is to look at what others are doing. There are countless online tutorials available for free. We have a post about how to master Python when you are an absolute beginner.
13. How can I store values with Python?
Values are stored in what is known as variables. They are simply quantities that hold numbers, characters or abstract entities called objects. The simplest data types include integers, floating-point numbers, and strings, i.e., characters, words or even whole sentences. Python also supports some complex data structures called lists, tuples and dictionaries. If you are a beginner Python programmer, you should take your time to understand how they work, so that you can get the most out of the programming language.
14. How to see the output from a Python program?
Earlier I mentioned the print function. It can take any number and any type of arguments. It is useful to format the output, especially when there are floating-point numbers that, by default, are printed with all significant digits after the decimal. Here is a simple example.
1 2 3 4 5 6 |
a = 3.890 b = 3.422 print("Result:", a*b) # Result: 13.311580000000001 print("Result: %.2f" % (a*b)) # Result: 13.31 |
15. How to read and write data using Python?
Python programs often process user input. It can be done by either directly asking the user to enter something from the keyboard, or by reading a file. There are various ways of reading and writing files. The function open
comes built-in, though more often one should use packages such as
numpy
or
pandas
which give more flexibility and advanced features.
16. How to use loops in Python?
Often times it is necessary to repeat the same command many times. That can be done easily inside a loop. There are different loops based on what is the requirement for the number of iterations.
1 2 3 4 5 6 7 8 9 10 |
print("for loop") for i in range (0,5): print("i = ", i) print() print("while loop") j = 3 while (j < 7): print("j = ", j) j = j + 1 |
This gives the output
1 2 3 4 5 6 7 8 9 10 11 12 |
for loop i = 0 i = 1 i = 2 i = 3 i = 4 while loop j = 3 j = 4 j = 5 j = 6 |
17. What if a function is missing in a Python program?
It is possible and highly recommended to write own function when possible. Functions can take arguments, do an action and return a value.
1 2 3 4 5 6 7 8 9 |
def my_function(a,b): result = a*b/2 return result x = 5 y = 7 z = my_function(x,y) print(z) |
This code returns 17.5.
18. What if I need more functionality?
The flexibility and versatility of Python is based on the countless packages available for download. They can be installed using the pip command from the command line, or from the GUI. Below I am using the highly recommended PyScripter.
19. How to debug Python Desktop code?
Debugging can be hard. The Python interpreter prints error messages, including the line of code where it fails. Print statements are a useful way of tracing whether the variables make sense. However, GUIs such as PyScripter take debugging to the next level. The error lines are highlighted before even running the code.
20. How to get help on using Python?
The Python community is huge, and there are countless of places to ask for hints and advice. Even a simple Google search with your particular issue will most likely give you the solution since beginners tend to run into the same problems as part of their learning curve.