Strings and Console Output 11/16


#1

I am trying to print off my variable, however I am getting an error. I am trying to print off my string the_machine_goes = "Print!"

it gives me the error

Oops, try again. Did you remember to print out "Ping!"?


#2

you should type print("string")


#3

its telling you that it wants the variable to equal the string "Ping!"
so make the_machine_goes = "Ping!" and then print that variable


#4

the_machine_goes = "Ping!"

print the_machine_goes

I hope this would be usefull, I strongly recommend that check the concept of variable in a python book. Look for Python for kids , which is very simpple to undestand for people that are making it´s firsts steps in programming


#5

the_machine_goes = "Ping!"

print "the_machine_goes"

could u plz tell me why don't type the code in this way, with the "" for the the_machine_goes


#6

@ajaxsurfer70740
I see nothing wrong with you print statement. It is doing what you told it to.

Now in you want it to print what the computer does that is different. You have to tell it that you want it to print what is inside the variable.

print("%s" % the_machine_goes)

#7

can i ask a question? what the difference between print *** and print " *** "?
it is my first time to learn things about code, and English is not my native language, it is little difficult for me to learn by this web, though it is very helpful.
thank you very much for your patience, thank you very much


#8

@ajaxsurfer70740

Unlike a natural langue which you speak/write to other people, a programming langue has rules that have to be followed or the computer will not know what to do.

In python when you call up the built-in print function it will print what is after it.

You can use print in several different ways.

variable = 'string'

print("This is a %s" % variable)
print("This is a ", string)
print("This is a " + string)

If you do not follow what the syntac of the language requires you will get bugs and errors. When you do not understand a specific part of the language loop up the docs preferably in your native language. If you can't find it in your language have google translate it for you.


#9

i feel really grateful for your help.

i konw i can use print in different ways, but i haven't get this part firmly

variable = 'string'

print("This is a %s" % variable)
print("This is a ", string)
print("This is a " + string)

what do you mean about %s , + this three.
any difference?

hope u won't feel angry for my foolish....


#10

it is amazing, when i go to the class 14.String Formatting with %, Part 1, i know what do you mean in last message!

thank u for your help!!!!

i feel very grateful, hope u can have a nice day


#11

Only fools get angry when someone asks a question. You have a good day as well!


#12

the first part is the_machine_goes = "Ping!" and goes on line 4
the second part is print the_machine_goes and goes on line 6


#13

That's a hero answer right there


#14

the_machine_goes = "Ping!"
print the_machine_goes