Evgenii Legotckoi
Evgenii LegotckoiFeb. 14, 2018, 4:02 a.m.

Python 3 - Tutorial 001. Introduce

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.

Do you like it? Share on social networks!

AP
  • Oct. 19, 2018, 1:54 p.m.
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
>>>  помогите плиз почему у меня так пишет,

Evgenii Legotckoi
  • Oct. 19, 2018, 1:59 p.m.

Добрый день!

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

#!/usr/bin/python3

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

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


Konstantin Grudnitskiy
  • April 3, 2020, 6:06 p.m.

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

Файл 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
m

C++ - Тест 003. Условия и циклы

  • Result:85points,
  • Rating points6
в

C++ - Тест 003. Условия и циклы

  • Result:50points,
  • Rating points-4
l

C++ - Test 005. Structures and Classes

  • Result:91points,
  • Rating points8
Last comments
k
kmssrFeb. 9, 2024, 7:43 a.m.
Qt Linux - Lesson 001. Autorun Qt application under Linux как сделать автозапуск для флэтпака, который не даёт создавать файлы в ~/.config - вот это вопрос ))
Qt WinAPI - Lesson 007. Working with ICMP Ping in Qt Без строки #include <QRegularExpressionValidator> в заголовочном файле не работает валидатор.
EVA
EVADec. 25, 2023, 11:30 p.m.
Boost - static linking in CMake project under Windows Ошибка LNK1104 часто возникает, когда компоновщик не может найти или открыть файл библиотеки. В вашем случае, это файл libboost_locale-vc142-mt-gd-x64-1_74.lib из библиотеки Boost для C+…
J
JonnyJoDec. 25, 2023, 9:38 p.m.
Boost - static linking in CMake project under Windows Сделал всё по-как у вас, но выдаёт ошибку [build] LINK : fatal error LNK1104: не удается открыть файл "libboost_locale-vc142-mt-gd-x64-1_74.lib" Хоть убей, не могу понять в чём дел…
G
GvozdikDec. 19, 2023, 10:01 a.m.
Qt/C++ - Lesson 056. Connecting the Boost library in Qt for MinGW and MSVC compilers Для решения твой проблемы добавь в файл .pro строчку "LIBS += -lws2_32" она решит проблему , лично мне помогло.
Now discuss on the forum
AC
Alexandru CodreanuJan. 20, 2024, 12:57 a.m.
QML Обнулить значения SpinBox Доброго времени суток, не могу разобраться с обнулением значение SpinBox находящего в делегате. import QtQuickimport QtQuick.ControlsWindow { width: 640 height: 480 visible: tr…
BlinCT
BlinCTDec. 27, 2023, 9:57 p.m.
Растягивать Image на парент по высоте Ну и само собою дял включения scrollbar надо чтобы был Flickable. Так что выходит как то так Flickable{ id: root anchors.fill: parent clip: true property url linkFile p…
Дмитрий
ДмитрийJan. 10, 2024, 5:18 p.m.
Qt Creator загружает всю оперативную память Проблема решена. Удалось разобраться с помощью утилиты strace. Запустил ее: strace ./qtcreator Начал выводиться весь лог работы креатора. В один момент он начал считывать фай…
Evgenii Legotckoi
Evgenii LegotckoiDec. 12, 2023, 7:48 p.m.
Побуквенное сравнение двух строк Добрый день. Там случайно не высылается этот сигнал textChanged ещё и при форматировани текста? Если решиать в лоб, то можно просто отключать сигнал/слотовое соединение внутри слота и …

Follow us in social networks