learning 1

 avatar
unknown
plain_text
4 years ago
1.7 kB
4
Indexable
print('a' + 'b')
print('a' + ' ' + 'b')
print('This' + 'is' + 'a' + 'sentence.')
print('This' + ' ' + 'is' + ' ' + 'a' + ' ' + 'sentence.')

#Output
#ab
#a b
#Thisisasentence.
#This is a sentence.

print('a' * 1)
print('a' * 4)
print('a ' * 5)
print('a' * 0) # No output for this line
print('a' * -1) # No output for this line

#Output
#a
#aaaa
#a a a a a

print('4' + 1 

cant be printed typeerror: can only concatenate str (not "int") to str
-----------------------
facebook = "Facebook's rating is"
fb_rating = 3.5

fb_rating_str = str(3.5)
fb = facebook + ' ' + fb_rating_str

print(fb)

===========================
Assign the string Facebook's rating is to a variable named facebook.
Assign the float 3.5 to a variable named fb_rating.
Convert fb_rating from a float to a string using the str() command, and assign the converted value to a new variable named fb_rating_str.
Concatenate the strings stored in facebook and fb_rating_str to form the string Facebook's rating is 3.5.
Assign the concatenated string to a variable named fb.
You'll need to add a space character between Facebook's rating is and 3.5 to avoid ending up with the string Facebook's rating is3.5.
Display the fb variable using print() — this is necessary for answer-checking
-----------------------------------------
row_2 = ['Instagram', 0.0, 'USD', 2161558, 4.5]
row_3 = ['Clash of Clans', 0.0, 'USD', 2130805, 4.5]

==========
Store the second row ('Instagram', 0.0, 'USD', 2161558, 4.5) as a list in a variable named row_2.
Store the third row ('Clash of Clans', 0.0, 'USD', 2130805, 4.5) as a list in a variable named row_3.

------------------
Editor is loading...