Roman Gurbanov - Python Handbook For Beginners

Здесь есть возможность читать онлайн «Roman Gurbanov - Python Handbook For Beginners» — ознакомительный отрывок электронной книги совершенно бесплатно, а после прочтения отрывка купить полную версию. В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Год выпуска: 2021, ISBN: 2021, Жанр: Технические науки, Программирование, на русском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Python Handbook For Beginners: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Python Handbook For Beginners»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

This book will provide you with basic knowledge and skills in Python programming, covering topics such as variables, numbers, strings, booleans, conditional statements, loops, lists, dictionaries, functions, classes and objects, modules, and packages.
Every chapter is wrapped up with a small test. Detailed explanations and practical examples accompany every topic to ensure you acquire an essential Python coding skill upon completing the book.
This book is excellent for everyone who wants to learn to code and is just starting. Other great books are available for those who have already mastered basic Python programming skills and looking to improve them.

Python Handbook For Beginners — читать онлайн ознакомительный отрывок

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Python Handbook For Beginners», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

3 Print Function

Print is the function that does what it's called: it "prints" text on a screen. Programmers use this function to show messages to users. Such as "Your session is expired, please log in" or "Your password is too weak, please use a stronger password," etc.

Not only simple text messages, but the print function can also display different calculation results, presented in numeric format. We will learn all this stuff in the coming chapters. For now, we will focus purely on the print function and code some more with it.

Here is the plain text for you. Please use it with the print function, so when you run the code, it shows you the following message: Hey! I keep coding! Here is what you should get:

Have some fun Since now you have learned how to write a program that displays - фото 3

Have some fun. Since now you have learned how to write a program that displays messages, experiment with different messages you want your program to print. Use numbers too. Try adding or removing anything from your code. And then watch what happens; This is the best way to learn how the code operates.

4 How Does Python Read The Code?

As soon as you run the code, the computer starts reading it line by line, from top to button. Just like you're reading this book or anything. It may not sound too important, but it's essential to consider it when building and arranging our code; This is why some elements like modules (we will learn them in the following chapters) belong at the top of the code. We import them first to use them further down.

5 Counting Program

Let's build a program that counts from 1 to 3. Here is the code we need to do that:

print("1")

print("2")

print("3")

Pretty simple, right? Now extend the code so that it could count to 10. Here is the result you should get when you run your extended program:

6 Python Challenge Lets celebrate the completion of the first chapter with a - фото 4

6 Python Challenge

Let's celebrate the completion of the first chapter with a small challenge. You need to complete the below line of code so that it could output the message: "I nailed the first chapter!"

Here is what the output should look like when you fix and run the program:

7 Wrapping Up Chapter One In the first chapter we have accomplished the - фото 5

7 Wrapping Up Chapter One

In the first chapter, we have accomplished the following:

1) Learned what Python is;

2) Understood what a program is;

3) Found out how does Python read the code;

4) Wrote our first line of code;

5) Created a few simple programs;

6) Finally, we learned and applied the print function.

8 Chapter One Test

1. A computer program is a:

1) Set of instructions and rules for a computer, written in a programming language.

2) Piece of code written on a computer.

3) Downloadable game.

2. How do we let a computer know that it needs to display a message on the screen?

1) With a magic word.

2) Using the print() function)

3) Using the command "Display message!"

3. In what order does a computer process (read) the code?

1) When we run the code, the computer reads that code line by line. Top-down.

2) When we run the code, the computer reads that code from bottom to top.

3) When we run the code, the computer doesn't read anything; it remembers everything by heart.

4. Arrange the parts of the code so that the program displays the message "I love Python!"

)

(

"I love Python!"

print

CHAPTER TWO: VARIABLES

1 What is a Variable?

A variable is a simple data structure that has a name and a value. Now, let's figure out what is what.

Imagine a folder on your desktop. In this case, the folder is a variable. The folder has the label "film."; This is the name of the variable. The folder contains a video called "The."; This is the value of the variable.

Here is how this variable looks in Python language:

Lets break it down 1 First we give a name to our variable film 2 Second - фото 6

Let's break it down.

1) First, we give a name to our variable – film

2) Second, we put equal sign =

3) Third, we give a value to our variable "Super Cat."

A value in a variable always goes with quotes, like in our example. Otherwise, a variable will not work.

Now, as we know what a variable is and what it contains, let's make one!

2 How to Create a Variable?

Write our variable from the example above to the console:

film = "Super Cat"

And run the code. Nothing? That's right. There is no message to show on the screen as we did not use the print function. We will combine variables with print function in the following chapters. But, for now, hit the >_REPL button.

You should now see the input field that looks like this Input the name of our - фото 7

You should now see the input field that looks like this:

Input the name of our variable which is the film and hit enter In response - фото 8

Input the name of our variable, which is the film, and hit enter.

In response to the variable name the program returns its value which in our - фото 9

In response to the variable name, the program returns its value, which in our case is "Super Cat."

Now, as you've created your first variable, experiment with it. Change name and value. See what happens.

3 Let's Print Variable Value

We've just learned how to create a variable. Now let's learn how to output its value.

Do you remember the print function we used earlier? Let's combine it with our variable and see what happens. Write this code in the console and hit run:

film = "Super Cat"

print(film)

Let's break it down:

1) First, we declared a variable and gave it a name – film.

2) Then we assigned a value to the variable – Super Cat.

3) Then, on a second line, we wrote a print function.

And finally, we passed the variable name to the print function, putting it in the function brackets.

Every time we create a variable and pass its name to the print function, it will output the variable's value, just like in our example.

Now you know how programmers display variables in Python. It doesn't seem too tricky. Let's have some practice. Below is the code that is missing some elements. You have to fix it so the program could create a variable and display its value.

= " "

()

By now, you should have sufficient knowledge and skills to accomplish this task. When done, iterate on it as long as you like. Change variable names and values. Hone on your new skills!

4 Wrapping Up Chapter Two

In chapter two, we have accomplished the following:

1) Learned what a variable is;

2) Created our first variable;

3) Learned how to display variable values.

5 Chapter Two Test

1. What is the purpose of variables?

1) Computers use variables to store information.

2) Computers use variables to change information.

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Python Handbook For Beginners»

Представляем Вашему вниманию похожие книги на «Python Handbook For Beginners» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Python Handbook For Beginners»

Обсуждение, отзывы о книге «Python Handbook For Beginners» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x