Архив рубрики: Публикации

Python: подготовка к работе с БД MySQL

Я часто “переезжаю” от одного окмпа на другой и приходится с нуля настраивать энвайромент для работы с MySQL. В итоге я каждый раз смотрю видос Штукенции на эту тему (он будет внизу этой статьи), что не очень удобно, когда ты в сотый раз это делаешь. Решил сделать шпаргалку по Питону 🙂

Итак, допустим, у нас есть скрипт на Питон.

  1. Первым делом – устанавливаем сам Питон.
  2. Далее надо, чтобы скрипт открывался в IDLE. Для этого:

    – ПКМ на файл -> Open with… -> More apps… -> Look for another app… -> C:Python310Libidlelibidle.bat
  3. Также зайдем сразу в настройки IDLE и выберем там тёмную тему: Options → Configure IDLE → Highlights → жмяк на кнопку IDLE Classic → выбираем IDLE Dark
  4. Теперь обновляем Пип в CMD: py -m pip install --upgrade pip
  5. Ставим MySQL коннектор: pip install mysql-connector-python
  6. Наслаждаемся и пишем коммент к этомук посту 😉 А вот и видео с наглядным гайдом:

Читать

Python: нестандартные функции. Игра “Крестики-нолики”.

Продолжаем учить язык программирования пайтон Python. Переходим к изучению 6 главы “Функции. Игра Крестики-нолики” по книге: Майкл Доусон “Программируем на Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), чтобы создавать собственные функции и работать с глобальными переменными.

Как создать функцию?

Общий вид функции в Python: название_функции()

Чтобы создать собственную функцию, нужно ее объявить.

Общий вид объявления функции

def название_функции(параметр1, параметр2...):

    '''Документирующая строка'''

    Блок выражений функции

Читать

Python: non-standard functions. Game “Tic-tac-toe”.

We continue to learn the Python programming language Python. Let’s move on to chapter 6 “Functions. Tic-Tac-Toe Game” from the book: Michael Dawson “Python Programming”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition) to create our own functions and work with global variables .

How to create a function?

General view of a function in Python: function_name()

To create your own function, you need to declare it.

General form of a function declaration

def function_name(parameter1, parameter2...):

    '''Document string'''

  Function expression block

Читать

Python: if, elif, else branching, while loops, random number generation

We continue to learn programming. Let’s move on to the study of the third chapter of the book: Michael Dawson “Programming in Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), where we will study if, elif, else conditional statements and while loops and learn how to generate random numbers using a module with the functions random.randint() and random.randrage().

Summary of chapter 3 with examples of programs I wrote:

Random Number Generation in Python

We load the import random module – it generates random numbers based on the built-in formula. To assign a random value to a variable, after calling the module, call one of its functions, for example,

Читать

Python – installation

To install Python on your computer, simply search Google for download python and follow the first link to www.python.org/downloads

The easiest way is to click on the bright button with the latest version of Python and then follow the installation process.

In addition to Python itself, you will probably need to install additional programs, which we will discuss next. When installing Python, remember that it is an interpretive programming language. If you write the code in notepad, it won’t work. And the code doesn’t need to be compiled like in C++. To run your code, you use either the built-in interpreter – Python 3.6.exe, or you can activate the interpreter in other text editors or programming environments.