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

Python: лайфхаки по настройке среды программирования

Как только вы установили на компьютер Python, лучше сразу позаботиться о небольших нюансах, которые облегают жизнь программистам. Давайте пройдемся по основным настройкам среды программирования и Windows для комфортной работы:

1. Изменение системных переменных среды

Эта настройка позволит запускать программу, написанную на Python, в CMD операционной системы Windows (интерпретатор командной строки). Чтобы это сделать, нажимаем “Пуск” -> Изменение системных переменных среды: Читать

Python: lifehacks for setting up a programming environment

Once you’ve installed Python on your computer, it’s best to take care of the little nuances that make life easier for programmers. Let’s go through the basic settings of the programming environment and Windows for comfortable work:

1. Changing System Environment Variables

This setting will allow you to run a program written in Python in the CMD of the Windows operating system (command line interpreter). To do this, click “Start” -> Change system environment variables:

Читать

Python – forbidden variable names

To find out which names cannot be given to variables in Python, use the command:

import keyword

keyword.kwlist

For Python 3.6 this words are: Читать

Python – branching structures (if else, if, ifelif statements)

The if statement (if) is used to set conditions (if so, then…), for example:

cat_say = ‘mew’

if cat_say = ‘mew’ of cat_say = ‘myavki’:

….print(‘Dear, cat! Here’s your food!’)

Important: when using if conditions, you need to write double equals and put a colon at the end of the expression to show the end of the condition; before the rest of the code related to the condition, and print is indented with a tab (or 4 spaces).

Читать

Python: Challenges and Decisions (Chapter 2. Types, Variables, and Basic I/O. Useless Facts Program).

We continue to learn programming. After the second chapter in the book: Michael Dawson “We Program in Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), where I studied the features of working with text in the Python programming language, tasks were offered. Let’s do them together. I will give my solution, and you write your options in the comments.

1) Come up with two lists: valid and invalid variable names. Explain why each of the names is valid or not valid, respectively. Then come up with two more lists—of “good” and “bad” valid names—and explain your choice.

Valid variable names: name, price, password, age, size (these can be any words that are not reserved in the programming language for functions / operators)

Читать

Python: Challenges and Solutions (Chapter 1. Getting Started. The Game Over Program).

We continue to learn programming. After the second chapter in the book: Michael Dawson “We Program in Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), where I studied the features of working with text in the Python programming language, tasks were offered. Let’s do them together. I will give my solution, and you write your options in the comments.

1) Learn how to trigger a bug: Interactively enter the name of your favorite ice cream brand. Then fix the error and create a command that will correctly display the name on the screen this type of ice cream.

Читать