Introduction to Python
  • Introduction
  • Preface
  • Background
  • Installing Python
  • Getting Started
  • Basics
    • More Printing
    • Strings
    • Numbers
    • Exercises
    • Comments
  • Variables
    • Operators
    • Type Conversion
    • Exercises
    • A Brief Introduction to Lists
    • Game Exercise
  • Human Input
  • Functions
    • First Functions
    • Why Functions
    • Exercises
  • Indentation
  • Decisions
    • Booleans
    • Logical Operators
    • If Statements
    • Elif and Else Statements
    • Exercises
    • Rock, Paper, Scissors
    • Game Exercise
    • Game Exercise 2
  • Lists
  • Loops
    • For Loops
    • While Loops
  • More Data Structures
    • Tuples
    • Dictionaries
  • Pygame
  • Extra Content
    • Computers and Code
    • More About Python
    • For Loops with Range
    • List Slicing
Powered by GitBook
On this page
  1. Basics

Exercises

PreviousNumbersNextComments

Last updated 6 years ago

Create a new file called basics.py. Write code in it to do the following:

  1. Print your favourite video game on the console.

  2. Print your favourite animal as well.

  3. Use the print function once to output the two previous strings separated by a newline.

  4. Print the following expressions in Python

    1. 61 + 4

    2. 25 - 12.5

    3. 25÷225 \div 225÷2

    4. 5×55 \times 55×5

    5. 6×2+56 \times 2 + 56×2+5

    6. 6×(2+5)6 \times (2 + 5)6×(2+5)

    7. 10÷(4×(5÷2))10 \div (4 \times (5 \div 2))10÷(4×(5÷2))