+ 4
Whats the difference between string and print?
hi guys whats the differen between a string an a print? why would i use print to echo it out if i can just write it down to echo it out?
6 Answers
+ 7
a string is a type of value. 1 is an integer. 3.5 is a float. 'hello' is a string.
print means, like you said, a way to show things on your screen.
they don't have anything in common though, and you can use string to transform numbers into words and add them together to form numbers such as
print(str(1)+str(2)) #12
print(1+2) #3
+ 5
print() is a function only, displays something; string is first of all data type, secondary - func to convert any other type into string. Syntax: str(non_string_var).
example:
number = 10
string = "spam"
print(number*3) #30
print(string*3) #spamspamspam
test = number + string #error
test = str(number) + string #10spam
test = number + int(string) #error
+ 2
A string is something that you can use to make words in without vars.
A print is a function that prints a string, number and or variables.
+ 1
there are three types of data :-
1) integer- it contains whole numbers and variables
example- 1,50,a,b,z.
2) floats- it contain decimal values
example- 5.5,0.9,6.99.
3)strings- it contains words or a string of alphabets
example - name,car,pathway
to print the values of any of the above three data types we use the print function:-
1) printing an integer
print(5+4)
output=9
2) printing a float
print(5.0+4.0)
output=9.0
3) printing a string
print ("path"+"way")
+ 1
string is an variable and stores text , on the other hand print gives the output of string or output of parameter written in it.
0
lo scroto