53 Python Exercises and Questions for Beginners

53 Python Exercises and Questions for Beginners

In this post, I’m going to list a bunch of Python exercises and questions for beginners.

In this post, I’m going to list a bunch of Python exercises and questions for beginners.

So, be sure to come back for new coding exercises. If you enjoy this post, please spread the love by share it with others.

Let’s get started!

Questions

Basics

  1. What is an expression?
  2. What is a syntax error?
  3. What is PEP8?
  4. What does a linter do?
  5. What is the result of this expression: “*” * 10
  6. What is CPython?
  7. How is CPython different from Jython?
  8. How is CPython different from IronPython?

    Primitive Types

  9. What is a variable?
  10. What are the primitive built-in types in Python?
  11. When should we use “”” (tripe quotes) to define strings?
  12. Assuming (name = “John Smith”), what does name[1] return?
  13. What about name[-2]?
  14. What about name[1:-1]?
  15. How to get the length of name?
  16. What are the escape sequences in Python?
  17. What is the result of f“{2+2}+{10%3}”?
  18. Given (name = “john smith”), what will name.title() return?
  19. What does name.strip() do?
  20. What will *name.find(“Smith”) *return?
  21. What will be the value of name after we call name.replace(“j”, “k”)?
  22. How can we check to see if name contains “John”?
  23. What are the 3 types of numbers in Python?

    Control Flow

  24. What is the difference between 10 / 3 and 10 // 3?
  25. What is the result of 10 ** 3?
  26. Given (x = 1), what will be the value of after we run (x += 2)?
  27. How can we round a number?
  28. What is the result of float(1)?
  29. What is the result of bool(“False”)?
  30. What are the falsy values in Python?
  31. What is the result of 10 == “10”?
  32. What is the result of “bag” > “apple”?
  33. What is the result of not(True or False)?
  34. Under what circumstances does the expression 18 <= age < 65 **evaluate to True?**
  35. What does range(1, 10, 2) return?
  36. Name 3 iterable objects in Python.

    Functions

  37. What is the difference between a parameter and an argument?
  38. All functions in Python by default return …?
  39. What are keyword arguments and when should we use them?
  40. How can we make a parameter of a function optional?
  41. What happens when we prefix a parameter with an asterisk (*)?
  42. What about two asterisks (**)?
  43. What is scope?
  44. What is the difference between local and global variables?
  45. Why is using the global statement a bad practice?

    Coding Exercises

  46. Write a function that returns the maximum of two numbers.
  47. Write a function called fizz_buzz *that takes a number. If the number is divisible by 3, it should return “Fizz”.If it is divisible by 5, it should return “Buzz”.If it is divisible by both 3 and 5, it should return “FizzBuzz”.Otherwise, it should return the same number.1. Write a function for checking the speed of drivers. This function should have one parameter: speed. If speed is less than 70, it should print “Ok”.Otherwise, for every 5km above the speed limit (70), it should give the driver one demerit point and print the total number of demerit points. For example, if the speed is 80, it should print: “Points: 2”.If the driver gets more than 12 points, the function should print: “License suspended”1. Write a function called *showNumbers *that takes a parameter called *limit. *It should print all the numbers between 0 and limit with a label to identify the even and odd numbers. For example, if the limit is 3, it should print: 0 EVEN1 ODD2 EVEN3 ODD 5 - Write a function that returns the sum of multiples of 3 and 5 between 0 and *limit (parameter). For example, if limit is 20, it should return the sum of 3, 5, 6, 9, 10, 12, 15, 18, 20.

6 - Write a function called show_stars(rows). *If *rows is 5, it should print the following:


7 - Write a function that prints all the prime numbers between 0 and *limit *where limit is a parameter.

python

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.

How To Compare Tesla and Ford Company By Using Magic Methods in Python

Magic Methods are the special methods which gives us the ability to access built in syntactical features such as ‘<’, ‘>’, ‘==’, ‘+’ etc.. You must have worked with such methods without knowing them to be as magic methods. Magic methods can be identified with their names which start with __ and ends with __ like __init__, __call__, __str__ etc. These methods are also called Dunder Methods, because of their name starting and ending with Double Underscore (Dunder).

Python Programming: A Beginner’s Guide

Python is an interpreted, high-level, powerful general-purpose programming language. You may ask, Python’s a snake right? and Why is this programming language named after it?

Hire Python Developers

Are you looking for experienced, reliable, and qualified Python developers? If yes, you have reached the right place. At **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")**, our full-stack Python development services...

Python any: How to Check If Element is Iterable or Not

Python any() function returns True if any element of an iterable is True otherwise any() function returns False. The syntax is any().