Test your knowledge with free interactive questions on Seneca — used by over 10 million students.

Casting

Casting is the process of converting data from one type to another.

Reasons for casting

Reasons for casting

  • One of the most common reasons for casting is output.
  • Output must be formatted as a string, and so we may need to convert a certain piece of data to a string.
  • All input also comes as a string, and must then be converted to other data types.
Casting functions

Casting functions

  • Casting to a string can be done using the str function. E.g:
    • str(3) gives "3".
  • Casting to an integer can be done using the int function. E.g:
    • int(3.4) gives 3.
  • Casting to a float can be done using the float function. E.g:
    • float("3.4") gives 3.4.
Jump to other topics
1

Computer Systems

1.1

Data Representation

1.2

Data Transmission

1.3

Hardware

1.4

Software

1.5

The Internet & its Uses

1.6

Cyber Security

1.7

Automated & Emerging Technologies

2

Algorithms, Programming & Logic

Practice questions on Casting

Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
Answer all questions on Casting

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium