🐍 Python for Everyone

← Back to practice bank

Chapter 1 Interview Prep 8 min read

Interview Questions: Your First Python Program

These are the kinds of questions that come up in early screening interviews and coding bootcamp assessments once someone claims "I know Python basics." Each one includes what a strong answer sounds like, common red flags, and a natural follow-up an interviewer might ask next. Click any question to expand it.

1 What does print() do, and how is it different from just typing text into your code?

print() is a function that outputs its argument to the console/terminal so a human can see it. Text that isn't inside print() just sits in the source code and does nothing when the program runs — Python doesn't display arbitrary lines of code, only what you explicitly ask it to output.

Thinking every line of code "shows up" somewhere automatically, or confusing print() with return.

"What's the difference between print() and return in a function?"

2 What's the difference between = and == in Python?

= is assignment — it stores a value in a variable. == is comparison — it checks whether two values are equal and returns True or False. Mixing them up is one of the most common beginner bugs.

Saying they're "basically the same" or being unable to give an example of each.

"What would if x = 5: do in Python?" (Answer: it's a syntax error — Python doesn't allow assignment inside an if condition like that.)

3 What are the three basic data types you've learned so far, and how do you tell them apart?

String (text, always in quotes, e.g. "hello"), integer (whole numbers, no decimal point, e.g. 12), and float (numbers with a decimal point, e.g. 4.9). You can also check a value's type directly with type(value).

Not knowing that "12" (quoted) is a string even though it looks numeric.

"What would type("12") return, and why?"

4 Why does print("Age: " + 25) raise an error, and how do you fix it?

+ means different things for different types — for numbers it adds, for strings it concatenates. Python won't silently guess which one you meant when you mix a string and an int, so it raises a TypeError. Fix it by converting the number to a string first: print("Age: " + str(25)).

Guessing the error is a "syntax error" rather than a type error, or not knowing str() exists.

"What's the reverse conversion called, if you have a string like "25" and want it as a number?" (Answer: int() or float().)

5 What does input() return, and what type is it always?

input() displays an optional prompt, pauses execution, and returns whatever the user typed — always as a string, even if they typed digits. This surprises a lot of beginners: input("Enter your age: ") followed by trying to do math on the result directly will fail unless you convert it with int() first.

Assuming input() automatically knows if the user meant to type a number.

"How would you get a number from the user and immediately add 5 to it?" (Answer: age = int(input("Age: ")); print(age + 5).)

6 What's a variable, in your own words?

A named location that holds a value, which can be read or changed later in the program. It's a way of giving a piece of data a memorable label instead of retyping the raw value everywhere.

Confusing a variable with the value itself (e.g., saying "a variable is just text") or thinking variable names must match their content's type in the name.

"Can a variable's value change after it's first set? Show me an example."

Rapid-Fire Review

Quick recall check — fill in each blank and hit Check.

🎉 5 for 5 — you're ready to talk about this chapter in an interview.

Strategy Tips

← Practice Bank Build the Project →