
Basic Python coding questions
Basic Python coding questions with runnable practice lessons.
Use this page like a question bank for Python fundamentals. Each linked prompt is meant to be solved in code, not just read as an answer, so it is useful for warmups, placement prep, and early interview foundations.
Question level
Beginner and fundamentals
Best use
Warmups, review, and early interview prep
Answer style
Write code and pass tests in the browser
Coverage
Values, branches, loops, collections, functions
Practice plan
Do not just read basic Python questions. Solve them.
Many lists of basic Python coding questions show the final answer too quickly. That can feel productive, but it does not prove you can turn a prompt into working code when the exact wording changes.
The better routine is simple: read the question, name the input and output, write the first version, run visible tests, then fix edge cases. The prompts below are grouped from easiest to more structured so you can build that routine without jumping straight into hard DSA.
Lesson groups
Pick the group that matches what you need to practice next.
Question set 1
Warmup questions for variables and types
These questions check whether you can represent data correctly. They are intentionally short because a clean answer here prevents confusion in longer problems.
Question set 2
Condition and comparison questions
Branching questions ask your code to choose. Practice even or odd, sign checks, maximum values, and simple text patterns until the condition order is obvious.
Conditionals
Check Even or Odd
Use modulo and if statements to make a simple decision.
Branching
Determine Positive, Negative, or Zero
Handle three possible cases with clear condition order.
Comparisons
Compare Two Numbers
Use equality and greater-than checks to return the right result.
Function logic
Implement a Function to Find the Maximum of Three
Combine comparisons inside a function body.
Strings
Check If String Is a Palindrome
Compare text forward and backward to test a simple pattern.
Question set 3
Loop, list, and dictionary questions
Collection questions are the next step after syntax. These prompts ask you to iterate, count, slice, filter, transform, and look up values with a dictionary.
Loops
Print List Items
Walk through each list item in order and produce output.
Accumulation
Sum List Numbers
Keep a running total while a loop visits numeric values.
Counting
Count List Elements
Track how many items a list contains without relying on shortcuts.
Lists
Create a List of Integers From 1 to N
Build a list from a numeric range and return the expected values.
Indexing
Access Elements by Positive and Negative Index
Read from the front and back of a list with confidence.
Slicing
Slice a List to Get First and Last Three Items
Use slice boundaries to return the part of a list you need.
Dictionaries
Build a Phonebook Dictionary
Map names to values and return structured lookup data.
Dictionary lookup
Get a Value From a Dictionary With a Default
Avoid missing-key failures by returning a fallback value.
Question set 4
Function and input-safety questions
Most real coding questions expect a function. Finish with prompts that make you define a function, return a value, validate input, and handle failure cases predictably.
Functions
Define a Function That Adds Two Numbers
Write a reusable function with parameters and a return value.
Return values
Write a Function That Returns a Greeting
Use a parameter to build predictable text output.
Input validation
Validate Integer Input
Check input before using it in a calculation.
Errors
Safe Divide With Default
Handle division edge cases without crashing the program.
Parsing
Parse Float or None
Convert numeric text and return a safe fallback for bad input.
Free preview vs full access
Why these questions link only to public lessons
Every lesson link on this page was checked as a logged-out public URL before being used. That avoids the SEO problem of sending crawlers or new learners from a public hub into a login redirect.
Some harder lessons still belong behind the full-access curriculum, and that is fine. This page is meant to own the basic question intent first, then guide learners into the wider Python practice hub and curriculum when they are ready for more depth.
Public preview
Open selected beginner lessons and practice in the browser before signing in.
Full curriculum
Unlock the broader lesson sequence, premium practice, and full AI assistance.
Related practice paths
Continue with the next public practice hub.
Python practice hub
Use the broader hub for topic practice, DSA, and interview-style problems.
Python beginner exercises
Start with short beginner exercises before moving into larger topics.
Python basics practice
Review core syntax, collections, functions, and input handling.
Full Python curriculum
Browse the complete learning path, modules, and free preview lessons.