TGViewer
Coding Interview Preparation Coding Interview Preparation @coding_interview_preparation · 5.89K subscribers
Post #995 931
Let's analyze the Python code step by step:

python
a = "Sun"
b = "Moon"
c = a
a = b
b = c
print(a + " and " + b)

Step-by-step breakdown:
1. `a = "Sun"` → variable `a` now holds `"Sun"`.
2. `b = "Moon"` → variable `b` now holds `"Moon"`.
3. `c = a` → variable `c` is assigned the value of `a`, which is `"Sun"`.
4. `a = b` → variable `a` is now assigned the value of `b`, which is `"Moon"`.
5. `b = c` → variable `b` is now assigned the value of `c`, which is `"Sun"`.

Final values:
-a = "Moon"
-b = "Sun"`

So, the `print(a + " and " + b)` will output:


Moon and Sun

✅ Correct answer: A. Moon and Sun
  • ❤ 2
More from @coding_interview_preparation
  1. Oct 14, 2026📷 15 SQL Coding Questions All Interviewer Asks
  2. Oct 12, 2026Java Coding Interview Questions Easy 1. Reverse a string without using a built-in reverse…
  3. Oct 10, 2026100 SQL interview questions
  4. Oct 8, 2026If you're prepping for system design interviews, this repo is gold It contains a curated,…
  5. Oct 6, 2026document post
  6. Oct 4, 2026💼 Why Your Resume Gets Rejected Before a Human Reads It You may have good skills and proj…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →