Архив метки: Python

Python – среда программирования и дополнительные программы

Когда вы установили Python, возникает вопрос – как начать изучать этот язык? Писать ли команды через консоль или нужно установить на компьютер что-то еще? Для Python есть множество сред программирования и разных решений, но для новичка предпочтительно выбрать из двух:

  • вы изучаете Python в научных целях, тогда скачивайте Anaconda с сайта www.continuum.io/downloads – в эту среду уже входит Python, а также такие полезные программы для программирования и аналитики как Spyder, Jupyter, IPython, R и другие.
  • вы изучаете Python для общих разработок, тогда установите крутой текстовый редактор кода Sublime Text с сайта sublimetext.com; в этом случае нужно будет вручную настроить интерпретатор Python, чтобы запускать программу, написанную в этом редакторе.

Читать

Python ООП – объектно-ориентированное программирование

Продолжаем практиковаться в программировании. После восьмой главы в книге: Майкл Доусон “Программируем на Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), где я изучила принципы ООП и программные объекты / классы, пора переходить к практике. Сделаем домашнее задание вместе!

Краткий конспект ООП на Python

Программный объект – формальное представление реального объекта в языке программирования. Объекты создаются на основе классов. Читать

Python OOP – Object Oriented Programming

We continue to practice programming. After the eighth chapter in the book: Michael Dawson “Programming in Python”, 2014 (Michael Dawson “Python Programming for the Absolute Beginner”, 3rd Edition), where I learned the principles of OOP and program objects / classes, it’s time to move on to practice. Let’s do our homework together!

A Brief Summary of OOP in Python

A program object is a formal representation of a real object in a programming language. Objects are created based on classes.

Читать

Python – показать пользователю результат

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

print(…) обязательно с маленькой буквы Читать

Python: Problems and Solutions (Chapter 3. Branching, while Loops, and Pseudocode. Guess the Number Game).

We continue to learn programming. After the third 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 proposed. Let’s do them together. I will give my solution, and you write your options in the comments.

Program “Guess the number” from Igroglaz without looking at the solution:

import random



guess = ""

guess_num = 0

number = int(random.randint(1,100))



print ("I made a guess: number 1-100. Can you guess it?n")



while guess != number:

    guess = int(input("Enter your proposal: n"))

    if guess > number:

        print("No, it's smaller..n")

    elif guess < number:

        print("No, it's bigger..n")

    else:

        print("Finally, you got it!n")

    guess_num += 1



print ("Number was ", number, ". You guessed it with", 

guess_num, "times. Good job!")

    

input()


By the way, there is a bug in this program in the book. Outside the loop there is tries = 1; whereas it should start from zero.

1) Write a program – a simulator of a “surprise” pie – that would display one of five different “Surprises” at startup, chosen at random.

Читать

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. Читать