Unknown | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Unknown

animal = “lion” animal = “zebra” Print(animal) I can’t understand ?

10th Feb 2020, 1:51 AM
Md Jahirul Islam
Md Jahirul Islam - avatar
7 Antworten
10th Feb 2020, 2:58 AM
Pedro H.J
Pedro H.J - avatar
+ 3
We can store something using variable. animal is a variable. So we will print the value using print( animal )
10th Feb 2020, 3:02 AM
Pedro H.J
Pedro H.J - avatar
+ 1
You must use ", not slanted ` p of print must not be capitalized. https://code.sololearn.com/c0JSGT4P9c5I/?ref=app
10th Feb 2020, 2:59 AM
Gordon
Gordon - avatar
+ 1
thanks you brother
10th Feb 2020, 3:26 AM
Md Jahirul Islam
Md Jahirul Islam - avatar
+ 1
Imagine you are writing a program that tells visitors where animals are in a zoo. First you ask them to pick their location. If they choose area1, then the program will say lion. If area2, then zebra. If area3, maybe penguins or whatever. The “location” and “animal” variables are just names that your program uses, so that it can describe the connections between many locations and many animals. Does this help?
10th Feb 2020, 3:31 AM
Isabel
Isabel - avatar
+ 1
animal = "lion" assigns animal variable to string "lion", after this where ever you use animal variable you would get the string "lion". animal = "zebra" reassigns the animal variable to string "zebra", the old string "lion' will be ignored. Where ever you use animal variable you would now get the string "lion". print(animal) Prints the latest value of variable animal "zebra". Output would be: zebra
10th Feb 2020, 2:00 PM
Seb TheS
Seb TheS - avatar
+ 1
First of all, Python is case sensitive so you need to write print instead of Print. And when you declare variable with same name multiple times. It takes the value that was given lastly. For eg: A=1 A=2 A=3 Here the value of A becomes 3 because it 3 was declared at last
11th Feb 2020, 6:56 PM
TheNetNinja