What dose “str” mean??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What dose “str” mean???

1st Jun 2019, 5:10 PM
oscar jones
oscar jones - avatar
8 Answers
+ 8
You can add two numbers like this: 5 + 5 = 10 You can concatenate two strings like this: 'hello ' + 'world' But you can't add a string and an integer: 'hello' + 123 # error To concatenate a string and an integer, turn the integer into a string: 'hello' + str(123) = 'hello123' You'll often see this in a print statement: print('You are ' + str(age) + ' years old.')
1st Jun 2019, 5:23 PM
Anna
Anna - avatar
+ 7
str(obj) returns type(obj).__str__(obj) >>> str(12) '12' >>> str(1.2) '1.2' >>> str(int) "<class 'int'>" >>> str(object()) '<object object at 0x7771fd30e0>' >>> class A: ... def __str__(self): ... return "A" ... >>> str(A()) 'A'
1st Jun 2019, 6:08 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 7
Conversation operator. Convert the value to string
1st Jun 2019, 6:10 PM
Muhammad Rashid
Muhammad Rashid - avatar
+ 3
str is standing for string means 'a word' or a line in between two quotes that is (').
1st Jun 2019, 6:28 PM
SωAti
SωAti - avatar
+ 2
It is a function that converts certain datatypes into strings. str(12) returns "12"
1st Jun 2019, 5:12 PM
Trigger
Trigger - avatar
+ 1
thanks😭
1st Jun 2019, 5:13 PM
oscar jones
oscar jones - avatar
+ 1
can you give me an example?
1st Jun 2019, 5:16 PM
oscar jones
oscar jones - avatar
0
Str is keyword in Python means string.
4th Jun 2019, 12:46 AM
Nandan Kumar
Nandan Kumar - avatar