python

python.org

𝟭: Книги: https://vk.com/topic-84392011_37640354
𝟮: Проект Эйлера: http://euler.jakumo.org/
𝟯: Awesome Python: https://github.com/vinta/awesome-python
𝟰: Курс по написанию ботов для Telegram: https://groosha.gitbooks.io/telegram-...

        IDLE
        >>> print("")

a = 1 + 1 # integer
b = 1.0 + 1.0 # float
string = "John" # string
string = "John" * 2 # JohnJohn
string = "John" + 2 # error
string = "John" + str(2)
users = ["John", "Artur", "Kate"] #list
users[0] # John
users[1] # Artur
users[2] # Kate
users[-2] # Artur

true_test = 10 > 5 # True
false_test = 10 != 5 # True
false_test = 10 == 5 # false

a = input("1st number >>> ")
b = input("2nd number >>> ")

if a > b:
    print(a)
elif a == b:
    print("equals")
else:
    print(b)

number = 200
while number < 500:
    print("Not ready")
    number += 2
else:
    print("ready")

users = ["John", "Artur", "Kate"]

for user in users:
    print(f"hello, {user}!")

def hello_user(name):     // объявление функции
    print(f"hello, {name}!")

def hello_all(user_list):
    for user in user_list:
        hello_user(user)

hello_all(users)    // запуск функции

def string_multiple(value, count):
    return value * count

temp_string = string_multiple("Text0", 3)  # Text0Text0Text0
print(temp_string)

class User:
    name: str

    def hello(self):
        print(f"Hello, {self.name}!")

john = User()
john.name = "John"

john.hello()
---
class User:
    name: str

    def __init__(self, first_name, last_name="Undefined"):
        self.name = first_name
        self.last_name = last_name

    def hello(self):
        print(f"Hello, {self.name}!")

john = User("John", "Doe")
john.hello()
artur = User("Artur")
artur.hello()
---
class Human:
    first_name: str
    last_name: str

    def __init__(self, first_name, last_name="Undefined"):
        self.first_name = first_name
        self.last_name = last_name

    def __str__(self):
        return f"Human: {self.first_name} {self.last_name}"


class User(Human):
    _passport: str = "1234 123123" # _ блокирует извне изменение параметра
    __pasort: str = "1234 123123" # __ закрытый доступ private *

    def hello(self):
        print(f"Hello, {self.first_name}!")


john = User("John", "Doe")
# john.hello()
artur = User("Artur")
# artur.hello()
# print(john)
print(john._passport)
---
import requests

response = requests.get('https://jsonplaceholder.typicode.com/users')
users = response.json()

email = users[0]['email']

print(email)

new_user = {
    'email': 'john@doe.com',
    'first_name': 'John'
}

response = requests.post('https://jsonplaceholder.typicode.com/users', new_user)
print(response.content)
---

      
Как программировать на Python
Основы Python
Работа с сетью (TCP) skillbox-chat

Как создать игру на Python