Convert to String in Python
To convert a number to a string, you need to apply the str function. Let's use this function to make a string out of a number:
pythontest1 = 'abc'
test2 = 1
test3 = test1 + str(test2)
print(test3) # 'abc1'
Задание 1
Given variables:
pythonnum1 = 1
num2 = 2
Add these variables as strings:
python'12'
Задание 2
Given variables:
pythontst1 = 'abc'
txt2 = 123
Add these variables as strings:
python'abc123'
Задание 3
Given a number:
pythontst = 123
Find the number of digits of this number.
Задание 4
Given a number:
pythontst = 456
Find the sum of the digits of this number.