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

Python: Problems and Solutions (Chapter 4. For Loops, Strings, and Tuples. The Anagram Game).

We continue to practice programming. After the fourth chapter in the book: Michael Dawson “Programming in Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), where I learned how to use the for statement and create tuples, tasks were suggested. Let’s do them together. I will give my solution, and you write your options in the comments.

1. Write a “Counting” program that would count at the request of the user. We should allow the user to enter the beginning and end of the count, as well as the interval between called integers. Читать

Python: Problems and Solutions (Chapter 5 Lists and Dictionaries Hangman Game).

We continue to practice programming. After the fifth chapter in the book: Michael Dawson “Programming in Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), where I learned how to make dictionaries and use lists, it’s time to move on to practice. Let’s do our homework together!

Task: Write a program that will display a list of words in random order. All words from the presented list should be printed on the screen without repetition.

Читать

Python: Lists and Dictionaries

We continue to learn the Python programming language Python. We turn to the study of chapter 5 of the book: Michael Dawson “Programming in Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), where we will master lists, list methods and dictionaries.

Lists in Python

Lists are similar to tuples, which we studied in the last chapter. It’s important to remember that, unlike tuples, lists can change. The general principles for working with tuples apply to lists.

Читать

Python – логические операторы и условия

Основные условия в Python:

  • < (одно меньше другого)
  • > (одно больше другого)
  • <= (одно меньше или равно другому)
  • >= (одно больше или равно другому)
  • != (одно не равно другому)
  • == (одно равно другому)

Примеры использования условий:

print(5 > 4)

True #результат

print(‘cat’==’dog’)

False #результат Читать

Python – loops (for, while, break, continue)

Loops in Python are pieces of code that repeat multiple times.

range(start,stop,step) – this is how the forLoop loop looks in general, where start and stop describe the actual beginning and end of the loop, including the start point, but not including the end point; step – the step with which the computer moves from the start point to the end point (another step is called increment).

Example:

range(1,10,2) means 1, 3, 5, 7, 9

Читать

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. Наслаждаемся и пишем коммент к этомук посту 😉 А вот и видео с наглядным гайдом:

Читать