Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Print Your String | Рядки
Типи даних у Python
course content

Зміст курсу

Типи даних у Python

Типи даних у Python

1. Знайомство з числами в Python
2. Істина чи брехня?
3. Рядки
4. Поєднання всіх тем разом

book
Print Your String

Good to see you again!

It's time to talk about a data type that has become an inseparable part of coding: strings. Strings are a way to input your everyday words into a Python program. Python recognizes specific words like "print," "if," and others as special, but for your own words, you need to enclose them in single quotes ('word') or double quotes ("word") – you can use either of these two ways.

Let's look at the example:

1234
string1 = "cat" string2 = 'cat' print("The first output is", string1) print("The second output is", string2)
copy

There's another way to define strings that's not used as often, and it involves using triple quotes:

1234567
string = """ Hello, I am learning Python to receive the job of my dream. By the way, even one task a day helps me inch my way towards success! I am in control of my life, and I improve it every day! """ print(string)
copy

This type of definition can be used when our string consists of several lines (we will receive an error otherwise):

123
string = 'Hello, I am learning Python to get the job of my dreams. By the way, even one task a day helps me inch my way towards success! I am in control of my life, and I improve it every day!'
copy
Завдання
test

Swipe to begin your solution

  1. Tell me about the weather in your city. Assign bad to the variable string1 if the weather outside is bad; otherwise, assign good.
  2. Tell me about your mood today! Assign could be better to the variable string2 if your mood is not okay; otherwise, assign could not be better.
  3. Now tell me if your mood depends on the weather. Assign yes to the variable string3 if it depends; otherwise, assign no.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 1
toggle bottom row

book
Print Your String

Good to see you again!

It's time to talk about a data type that has become an inseparable part of coding: strings. Strings are a way to input your everyday words into a Python program. Python recognizes specific words like "print," "if," and others as special, but for your own words, you need to enclose them in single quotes ('word') or double quotes ("word") – you can use either of these two ways.

Let's look at the example:

1234
string1 = "cat" string2 = 'cat' print("The first output is", string1) print("The second output is", string2)
copy

There's another way to define strings that's not used as often, and it involves using triple quotes:

1234567
string = """ Hello, I am learning Python to receive the job of my dream. By the way, even one task a day helps me inch my way towards success! I am in control of my life, and I improve it every day! """ print(string)
copy

This type of definition can be used when our string consists of several lines (we will receive an error otherwise):

123
string = 'Hello, I am learning Python to get the job of my dreams. By the way, even one task a day helps me inch my way towards success! I am in control of my life, and I improve it every day!'
copy
Завдання
test

Swipe to begin your solution

  1. Tell me about the weather in your city. Assign bad to the variable string1 if the weather outside is bad; otherwise, assign good.
  2. Tell me about your mood today! Assign could be better to the variable string2 if your mood is not okay; otherwise, assign could not be better.
  3. Now tell me if your mood depends on the weather. Assign yes to the variable string3 if it depends; otherwise, assign no.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 1
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt