Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Concatenation | Common data types
Learn Python from Scratch
course content

Зміст курсу

Learn Python from Scratch

Learn Python from Scratch

1. The basics
2. Arithmetic operations
3. Common data types
4. Conditional statements
5. Other data types
6. Loops
7. Functions

Concatenation

There are also some interesting operations available for strings in Python. One of them is concatenating strings, which means gluing one string to another. In Python, it can be easily done with + sign (ensure that both sides must be either both strings or numbers)

Also, you can easily calculate the number of each symbol met in your row. Use s.count(x) to do it where s - is a variable where string stores and x - symbol you are interested in.

Also, you can replicate one string multiple times by just using multiplication. string * n will produce n copies of string.

For example,

1234567
# let's concatenate strings print("I " + "can " + "concatenate " + "strings") # let's count number of a in specific string s = "Linear discriminant analysis" print(s.count("a")) # replicate string multiple times print("test " * 5)
copy

Завдання

Given two variables: name and surname with values "Alex" and "Ferguson" respectively.

  1. You need to create variable fullname and assign the result of the concatenation of name and surname. Do not forget about the blank space between name and surname (use + " ")! Then print this fullname.
  2. Count number of letter 'e' is fullname.

Завдання

Given two variables: name and surname with values "Alex" and "Ferguson" respectively.

  1. You need to create variable fullname and assign the result of the concatenation of name and surname. Do not forget about the blank space between name and surname (use + " ")! Then print this fullname.
  2. Count number of letter 'e' is fullname.

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

Все було зрозуміло?

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

Concatenation

There are also some interesting operations available for strings in Python. One of them is concatenating strings, which means gluing one string to another. In Python, it can be easily done with + sign (ensure that both sides must be either both strings or numbers)

Also, you can easily calculate the number of each symbol met in your row. Use s.count(x) to do it where s - is a variable where string stores and x - symbol you are interested in.

Also, you can replicate one string multiple times by just using multiplication. string * n will produce n copies of string.

For example,

1234567
# let's concatenate strings print("I " + "can " + "concatenate " + "strings") # let's count number of a in specific string s = "Linear discriminant analysis" print(s.count("a")) # replicate string multiple times print("test " * 5)
copy

Завдання

Given two variables: name and surname with values "Alex" and "Ferguson" respectively.

  1. You need to create variable fullname and assign the result of the concatenation of name and surname. Do not forget about the blank space between name and surname (use + " ")! Then print this fullname.
  2. Count number of letter 'e' is fullname.

Завдання

Given two variables: name and surname with values "Alex" and "Ferguson" respectively.

  1. You need to create variable fullname and assign the result of the concatenation of name and surname. Do not forget about the blank space between name and surname (use + " ")! Then print this fullname.
  2. Count number of letter 'e' is fullname.

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

Все було зрозуміло?

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

Concatenation

There are also some interesting operations available for strings in Python. One of them is concatenating strings, which means gluing one string to another. In Python, it can be easily done with + sign (ensure that both sides must be either both strings or numbers)

Also, you can easily calculate the number of each symbol met in your row. Use s.count(x) to do it where s - is a variable where string stores and x - symbol you are interested in.

Also, you can replicate one string multiple times by just using multiplication. string * n will produce n copies of string.

For example,

1234567
# let's concatenate strings print("I " + "can " + "concatenate " + "strings") # let's count number of a in specific string s = "Linear discriminant analysis" print(s.count("a")) # replicate string multiple times print("test " * 5)
copy

Завдання

Given two variables: name and surname with values "Alex" and "Ferguson" respectively.

  1. You need to create variable fullname and assign the result of the concatenation of name and surname. Do not forget about the blank space between name and surname (use + " ")! Then print this fullname.
  2. Count number of letter 'e' is fullname.

Завдання

Given two variables: name and surname with values "Alex" and "Ferguson" respectively.

  1. You need to create variable fullname and assign the result of the concatenation of name and surname. Do not forget about the blank space between name and surname (use + " ")! Then print this fullname.
  2. Count number of letter 'e' is fullname.

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

Все було зрозуміло?

There are also some interesting operations available for strings in Python. One of them is concatenating strings, which means gluing one string to another. In Python, it can be easily done with + sign (ensure that both sides must be either both strings or numbers)

Also, you can easily calculate the number of each symbol met in your row. Use s.count(x) to do it where s - is a variable where string stores and x - symbol you are interested in.

Also, you can replicate one string multiple times by just using multiplication. string * n will produce n copies of string.

For example,

1234567
# let's concatenate strings print("I " + "can " + "concatenate " + "strings") # let's count number of a in specific string s = "Linear discriminant analysis" print(s.count("a")) # replicate string multiple times print("test " * 5)
copy

Завдання

Given two variables: name and surname with values "Alex" and "Ferguson" respectively.

  1. You need to create variable fullname and assign the result of the concatenation of name and surname. Do not forget about the blank space between name and surname (use + " ")! Then print this fullname.
  2. Count number of letter 'e' is fullname.

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