Exercises Python logo
Exercises Python
Course Practice Editor Get started free
  1. Python course
  2. Data types
  3. Generate a random number
29 Data types
Fundamentals concepts
  • Variables
  • Fundamentals of data types
  • Basic data types
  • Type conversion
  • Strings: indexes and slices
  • String methods
  • Formatting the output
  • Comparisons and logical values
  • Random numbers with random
  • Mutability, identity and copies
  • Truth value and safe conversions
Practice exercises
  • Reverse chars
  • Simple geometric calculator
  • Speed unit converter
  • Generate a random number
  • Swap two variables
  • A number in several types
  • Initials
  • Text profile
  • Spaces to hyphens
  • Slices of a word
  • Is it a palindrome?
  • Comparison table
  • Invoice with format
  • Digits of a number
  • Spot the alias
  • Shallow versus deep copy
  • Truthy or falsy
  • Safe conversion to integer
Data types · 15 / 29 Exercise Easy

Generate a random number

Objective

Create a Python program that prompts the user for 2 integers and displays a random number on the screen between those values.

Input
3
3
Output
3

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise
← PreviousSpeed unit converter Next →Swap two variables
Exercises Python logo
Exercises Python

Learn Python by solving practical exercises, free and right in your browser.

Get it on Google Play

Learn

  • Home
  • Course
  • Practice
  • Editor

More

  • Features
  • Contact

Account

  • Log in
  • Sign up

Legal

  • Privacy policy
  • Cookies policy
  • Terms and conditions
  • Cookie settings
  • Sitemap

© 2026. Made with 💙 by Jaracoder.

English
  • Español

We use necessary cookies to keep your session. With your consent we also use cookies for advertising and analytics, which keep the course free and help us improve it. Cookies policy