The problem is the rapid time out on input. When you press Run, quickly click in the console and enter a value. You have about two or three seconds.
I am sorry. If it prints “6 times 7 equals 42” to the console then is it not printing the values (or literals, as I understand it) of a and b rather than the variables?
My end-goal in asking this question is learning what exactly the term literal means because I am confused.
One can see how that would be confusing. Values in memory are just values, and variables only refer to them, not store them.
What is a literal?
a = 6
Above, a
is the variable to which is assigned a reference to the value, 6
. In the above, 6
is a literal since it is literally a 6.
If we say,
a = 3 * 2
then the referenced value is still 6
but the literals are, 3
and 2
. So when we see the actual numbers, or in the case of strings, actual text in quotes, those are literals. That means it is visible as hard-coded values. They are part of the program.
my code is correct but nothing is appearing on console. what can i do?
Can you copy/paste your code here? It may offer some clues as to the nature of the issue.
You can click the </>
button. This will create a pair of three backticks. Paste your code on a new line in between the pair of three backticks.
```
paste code on new line between backticks
```
here i am defining the meals of the day
meal = “english muffin”
print( “breakfast”)
print(meal)
meal = “pulao”
print(“lunch”)
print(meal)
meal = “EVM”
print(“dinner”)
print(meal)
/
The code you have posted prints the following strings:
breakfast
english muffin
lunch
pulao
dinner
EVM
Are you trying to complete an exercise? If so, can you share the link to the exercise?
Are you getting an error message? If so, what does the message say?
If the posted code is run, then it does produce output.
hi I tried to run code again and it showed up the same result as you mentioned. I guess there was some problem from my end. thank you
I’m right in thinking there is supposed to be an output on the terminal for this exercise?
All the ticks turn green so I know I’ve filled it in correctly but it just shows movie_review and nothing else in the output.
Thank you
I am trying to figure this out as well. How do we print the numbers and string on the same line?
Thank you. I was trying to figure out how to print a string and integer on the same line. Not sure if this is correct or the most efficient way but it worked:
release_year = 2024
runtime = 128
rating_out_of_10 = 8.5
ry = f"Release Year: {release_year}"
rt = f"Run Time: {runtime}"
r = f"Rating: {rating_out_of_10}"
print (ry)
print (rt)
print (r)
I ran the program and the output was what I wanted:
Release Year: 2024
Run Time: 128
Rating: 8.5
There is nothing wrong if you are getting the output you desire. It can be done in one print statement:
print (f"Release Year: {release_year}\n\
Run Time: {runtime}\n\
Rating: {rating_out_of_10}")
All in all, there is no big difference apart from keeping all the potential future edits in one statement.