Python 3 - Tutorial 001. Introduce

Python, Python 3

Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during 1985- 1990. Like Perl, Python source code is also available under the GNU General Public License (GPL). Python is named after a TV Show called ‘Monty Python’s Flying Circus’ and not after Python-the snake.

Python 3.0 was released in 2008. Although this version is supposed to be backward incompatibles, later on many of its important features have been backported to be compatible with version 2.7.

Audience

This tutorial is designed for software programmers who want to upgrade their Python skills to Python 3. This tutorial can also be used to learn Python programming language from scratch.

Audience

This tutorial is for software developers who want to upgrade their Python skills to Python 3. This tutorial can also be used to learn the Python programming language from scratch.

The necessary conditions

You must have a basic understanding of the terms of computer programming. The basic understanding of any of the programming languages is a plus.

Executing Python programs

The Python program files has the extension py. Programs are run using the Python interpreter.

For example, such a program written in the file main.py

#!/usr/bin/python3

print ("Hello, Python!")

You can run it by running the following command in the console

python3 main.py

The output will be as follows

Hello, Python!

Overview

Python is a high-level, interpretable, interactive and object-oriented scripting language. Python is designed to be readable. He often uses English keywords, while other languages use punctuation. It has fewer syntactic constructions than other languages.

  • Python is interpreted - Python is processed at run-time by the interpreter. You do not need to compile your program before executing it. This is similar to PERL and PHP.
    Python is interactive - you can use Python hints and interact directly with the interpreter to write your own programs.
    Python is object-oriented. Python supports an object-oriented programming style that is encapsulated within objects.
    Python is a language for beginners. Python is an excellent language for novice programmers and supports the development of a wide range of applications from simple text processing to web browsers for games.

History of Python

Python was developed by Guido van Rossum in the late 80s and early nineties at the National Research Institute of Mathematics and Informatics in the Netherlands.

  • Python is derived from many other languages, including ABC, Modula-3, C, C ++, Algol-68, SmallTalk and Unix shell and other scripting languages.
  • Python is protected by copyright. Like Perl, the Python source code is now available under the GNU General Public License (GPL).
  • Python is now supported by the core development team at the institute, although Guido van Rossum still plays a vital role in guiding his progress.
  • Python 1.0 was released in November 1994. In 2000, Python 2.0 was released. Python 2.7.14 is the latest version of Python 2.
  • Meanwhile, Python 3.0 was released in 2008. Python 3 is not compatible with Python 2. Compatibility with Python 3 was to remove duplicate software constructs and modules to "have one, and maybe one, an obvious way to do this." Python 3.6.4 is the latest version of Python 3.

Python Features

Ease of learning - Python has several keywords, a simple structure and a well-defined syntax. This allows the student to quickly pick up the language.

  • Easily readable - the Python code is more clearly defined and visible to the eyes.
  • Easy-to-maintain - Python source code is fairly easy to maintain.
  • Wide standard library - the main part of the Python library is very portable and cross-platform compatible with UNIX, Windows and Macintosh.
  • Interactive mode - Python supports interactive mode, which allows you to interactively test and debug code snippets.
  • Portable - Python can run on a variety of hardware platforms and have the same interface on all platforms.
  • Expandable - you can add low-level modules to the Python interpreter. These modules allow programmers to add or customize their tools to improve efficiency.
  • Databases - Python provides interfaces for all major commercial databases.
  • Programming GUI - Python supports graphical applications that can be created and transferred to many system calls, libraries and Windows systems, such as Windows MFC, Macintosh and X Window Unix systems.
  • Scalability - Python provides better structure and support for larger programs than shells.

In addition to the above functions, Python has a large list of good functions. A, few are listed below -

  • It supports functional and structured programming methods, as well as OOP.
  • It can be used as a scripting language or can be compiled into bytecode to create large applications.
  • It provides very high-level dynamic data types and supports dynamic type checking.
  • It supports automatic garbage collection.
  • It can be easily integrated with C, C ++, COM, ActiveX, CORBA and Java.
We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.
Support the author Donate
AP
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> #!/usr/bin/python3
>>> print(Hello,Python!)
python3 main.py
SyntaxError: invalid syntax
>>>
=============================== RESTART: Shell ===============================
>>> #!/usr/bin/python3
>>> print("Hello,Python!")
python3 main.py
SyntaxError: invalid syntax
>>> Hello,Python!
SyntaxError: invalid syntax
>>>  помогите плиз почему у меня так пишет,

Добрый день!

Вот это линуксовая директива

#!/usr/bin/python3

Указывает, где находится python пакет в системе. А вы видимо под windows разрабатываете.

Попробуйте просто удалить эту строку.


Я надеюсь вы уже разобрались в чем дело, но если вдруг нет, то проблема состоит в том, что вы пытаетесь запустить программу из интерпретатора питона.

Файл main.py это уже готовая программа которая выводит в терминал (командную строку) текст:

Hello, Python!

Эту (готовую) программу нужно запускать из интерпретатора команд вашей ОС (Windows: cmd, powershell; UNIX: bash, zsh, csh ...) а не из интерпретатора питона.

Текст файла main.py :

#!/usr/bin/python3
print ("Hello, Python!")

Программа для запуска из выполняемой среды ОС (открыть файл main.py в программе python ):

python main.py

если же вы уже запустили интерпретатор python, то вам достаточно просто написать команду:

print('Hello, Python!')

Comments

Only authorized users can post comments.
Please, Log in or Sign up
How to become an author?

Contribute to the evolution of the EVILEG community.

Learn how to become a site author.

Learn it
Donate

Good day, Dear Users!!!

I am Evgenii Legotckoi, developer of EVILEG. And it is my hobby project, which helps to learn programming another programmers and developers

If the site helped you, and you want also support the development of the site, than you can donate by following ways

PayPalYandex.Money
Timeweb

Let me recommend you the excellent hosting on which EVILEG is located.

For many years, Timeweb has been proving his stability.

For projects on Django I recommend VDS hosting

View Hosting Timeweb
AS
May 26, 2020, 12:29 p.m.
Artem Sun-Dun-Chan

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
MN
May 25, 2020, 12:33 p.m.
Mitja Nagibin

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
f
May 25, 2020, 6:05 a.m.
falcon

C++ - Test 001. The first program and data types

  • Result:66points,
  • Rating points-1
Last comments
May 29, 2020, 7:30 a.m.
Evgenij Legotskoj

Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column?

У меня работает. Исправлял в проекте, который приложен к статье. А что происходит в вашем коде, с учётом места вызова этого кода, я знать не могу ;) Дебажьте и добавляйте условия, кото…
MA
May 29, 2020, 7:27 a.m.
Mihail A

Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column?

QModelIndexList rowIndexes = ui->tableView->selectionModel()->selectedRows(); model->removeRows(rowIndexes.first().row(), rowIndexes.size()); model-&…
May 29, 2020, 7:14 a.m.
Evgenij Legotskoj

Django - Tutorial 036. How to add authentication through social networks. VKontakte

Неправильно прописали URL, на который возвращается ответ от OAuth ВКонтакте. Настраивайте ваше приложение в консоли разработчика ВКонтакте
AL
May 29, 2020, 6:24 a.m.
Aleksandr Leonidov

Django - Tutorial 036. How to add authentication through social networks. VKontakte

Здравствуйте! После клика на ссылку авторизации выдает json словарь с ошибкой: {"error":"invalid_request","error_description":"redirect_uri is incorrect, check application redirect uri in …
May 28, 2020, 4:14 p.m.
Evgenij Legotskoj

Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column?

Ну в моём примере, который в статье сработало так model->setData(model->index(1, 1), 7); Поскольку model->index(1, 0) - это индекс колонки id, которая скрыта, поэтому…
Now discuss on the forum
May 29, 2020, 8:52 a.m.
Vladimir Sergeevich

Масштабирование двумя пальцами на мобильных платформах

Я планировал описать этот момент на блоге, но никак руки не доходят (уже год). Летом дойдут. Тем не менее, у меня в репозитории лежит рабочий код игрушки "пазлы", где есть все это. …
May 29, 2020, 7:51 a.m.
Evgenij Legotskoj

Графическое ускорение

Зависит от платформы и поддерживаемых технологий. В QML в первую очередь используется OpenGL и отрисовка производится средствами GPU. Но может переключаться на использование CPU и прог…
IP
May 29, 2020, 2:55 a.m.
Igor' Poroshin

QTablwView + QSqlQueryModel скрыть пустой столбец

Да, понятно. В данном случае лучше использовать серверную процедуру (если такие поддерживаются), в которой будет проверяться наличие всех пустых строк у нужного столбца и вызываться соответ…
RG
May 28, 2020, 7:21 p.m.
Rovshan Gurbanov

Сборка под старые версии Android

У меня SDK почти все версии есть, NDK есть версии 10, 17, 21. Но собирается приложение только с NDK v21 под Android версии 7.0 и выше Версия Qt у меня 5.14.2
May 28, 2020, 8:58 a.m.
Evgenij Legotskoj

Освобождение памяти QMainWindow::setCentralWidget

Да, соглашусь. Просто удаление происходит позже, а не сразу.
About
Services
© EVILEG 2015-2020
Recommend hosting TIMEWEB