COMPUTER SCIENCE CAFÉ
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
CODING CHALLENGES | DATATYPES AND OPERATORS
Enjoy the journey of learning to code, explore and be creative
ON THIS PAGE
​CHALLENGE 1 | PRINTING PI
​CHALLENGE 2 | FIRST CALCULATOR
​CHALLENGE 3 |  MEAL CALCULATOR
Picture
​SUBSCRIBE FOR SAMPLE SOLUTIONS
ALSO IN THIS TOPIC
LEVEL 1 | GETTING STARTED
 LEVEL 2 | VARIABLES AND USER INTERACTION
YOU ARE HERE |LEVEL 3 | DATATYPES AND OPERATORS
LEVEL 4 | IF STATEMENTS
LEVEL 5 | LOOPS
​LEVEL 6 | ARRAYS / LISTS
LEVEL 7 | FUNCTIONS
LEVEL 8 | ALGORITHM DESIGN
LEVEL 9 | OOP
LEVEL 10 | EXTERNAL DATA HANDLING
TURTLE CHALLENGES
DEBUGGING AND TRACING​
CHALLENGE SOLUTIONS

Picture
WATCH THIS VIDEO TO HELP YOU WITH THIS SECTION
Picture
​CHALLENGE 1 | PRINTING PI
When using numbers we can write our programs to manage and manipulate numbers, at an early stage of coding you may be tempted to simply enter the answer manually, however an important part of mastering code is learning how to get the computer to do the work for you. Can you write a program to manipulate the value of Pi: 3.1415. 
Create a program to do the following:
1: Store the value of Pi to 4dp in a variable
2: Use a method to output the value stored as an integer, with no decimal places.
3: Use a method to output the value stored as a float to 2dp with no rounding.
EXAMPLE OUTPUT
3
3.14

EXTENSION TASK
Output the values in a user friendly way by concatenating a string with the number.
EXAMPLE OUTPUT
Pi with zero decimal places is 3
Pi two 2 decimal places is 3.14
Picture
​CHALLENGE 2 | FIRST CALCULATOR
Create a program to produce the sums and output for the following:​
1: Use a method to calculate 21 + 5. Output the result.
2: Use a method to calculate 21 - 5. Output the result.
3: Use a method to calculate 21 * 5. Output the result.
4: Use a method to calculate 21 / 5. Output the result.
5: Use a method to calculate the exponent of 21 ^ 5. Output the result.
6: Use a method to calculate the integer division of 21 div 5. Output the result.
7: Use a method to calculate the modulus of 21 mod 5. Output the result.
​NOTE: All outputs should be in a user friendly string. (use concatenation)
EXAMPLE OUTPUT
The addition of 21 + 5 = 26
The subtraction of 21 - 5 = 16
The multiplication of 21 * 5 = 105
The division of 21 / 5 = 4.2
The exponent of 21 ^ 5 = 4084101
The integer division of 21 / 5 = 4
​The modulus of 21 / 5 = 1
Picture
​CHALLENGE 3 |  MEAL CALCULATOR
CREATE A PROGRAM THAT DOES THE FOLLOWING:

1: Ask the user to 'Enter the cost of the main course' - store in a variable
2: Ask the user to 'Enter the cost of the drink' - store in a variable
3: Ask the user to 'Enter the cost of the desert' - store in a variable
4: Add up the 3 values and store in a variable called 'subtotal'
5: Add 20% tax to the subtotal and store in a variable called 'total'
6: Output/print the total value of the meal.
Picture
Picture
NAVIGATION
LEVEL 1 | GETTING STARTED
LEVEL 2 | VARIABLES AND USER INTERACTION
LEVEL 3 | DATATYPES AND OPERATORS
LEVEL 4 | IF STATEMENTS
LEVEL 5 | LOOPS
​LEVEL 6 | ARRAYS / LISTS
LEVEL 7 | FUNCTIONS
LEVEL 8 | ALGORITHM DESIGN
LEVEL 9 | OOP
LEVEL 10 | EXTERNAL DATA HANDLING
TURTLE CHALLENGES
DEBUGGING AND TRACING​
CHALLENGE SOLUTIONS
Picture
SUGGESTIONS
We would love to hear from you
SUBSCRIBE 
To enjoy more benefits
We hope you find this site useful. If you notice any errors or would like to contribute material then please contact us.