Skip to main content

Back to the full dot-point answer

SingaporeComputer ScienceQuick questions

Programming in Python

Quick questions on Python variables and data types explained: O-Level Computing

6short Q&A pairs drawn directly from our worked dot-point answer. For full context and worked exam questions, read the parent dot-point page.

What are the core data types?
Show answer
Python has four data types you must know:
What is input always returns a string?
Show answer
The input() function always gives back a string, even if the user types digits. So age = input() makes age the text "15", not the number 1515. Doing arithmetic on it directly causes an error.
What are converting between types?
Show answer
To convert a value, wrap it in the type's function:
What is q1?
Show answer
State the data type of the value "42" in Python. [1 mark]
What is q2?
Show answer
Write a line that reads a price (which may have decimals) from the user as a number. [2 marks]
What is q3?
Show answer
Explain why int(input("Age: ")) + 1 works but input("Age: ") + 1 does not. [2 marks]

Have a question we have not covered?

This dot-point answer is short enough that we have not extracted many short questions yet. Read the full dot-point answer or ask Mo, our study assistant, in the chat for follow ups.

All Computer ScienceQ&A pages