Why does 1 + 2 show a result in a notebook but not in my script?
I put 1 + 2 into app.py and ran it. There is no printed result, even though a notebook shows 3. ```python 1 + 2 ``` CookieSensei starter Q&A · example discussion.
Loading…
Questions worth sharing
See what others are asking. Browse every published question by topic, find an answer, or add your own experience.
I put 1 + 2 into app.py and ran it. There is no printed result, even though a notebook shows 3. ```python 1 + 2 ``` CookieSensei starter Q&A · example discussion.
A cell uses total, but it fails after I restart the notebook kernel. What am I missing? ```python print(total / count) ``` CookieSensei starter Q&A · example discussion.
My function runs, but I am not sure whether it returns the correct answer. What is a simple first test? ```python def add(a, b): return a - b assert add(2, 3) == 5 ``` CookieSensei starter Q&A · example discussion…
My dictionary does not always contain a city. Using the key directly gives an error. ```python profile = {"name": "Asha"} print(profile["city"]) ``` CookieSensei starter Q&A · example discussion.
Printing the list shows brackets and commas. How can I display one item on each line? ```python topics = ["Python", "Web", "AI"] print(topics) ``` CookieSensei starter Q&A · example discussion.
The list has three names. Why does using index 3 fail? ```python names = ["Asha", "Ravi", "Mira"] print(names[3]) ``` CookieSensei starter Q&A · example discussion.
The function prints the result I want, but the value stored in result is None. ```python def double(number): print(number * 2) result = double(3) print("Stored:", result) ``` CookieSensei starter Q&A · example dis…
I tried to print a value, but Python says that the name is not defined. ```python print(score) ``` CookieSensei starter Q&A · example discussion.
I expected 15, but this code prints 105. What is the difference? ```python first = "10" second = "5" print(first + second) ``` CookieSensei starter Q&A · example discussion.
I wrote an if statement, but the following print line gives an indentation error. ```python ready = True if ready: print("Ready to learn") ``` CookieSensei starter Q&A · example discussion.
I expected the numbers 1 through 5, but the output stops at 4. Why? ```python for number in range(1, 5): print(number) ``` CookieSensei starter Q&A · example discussion.