Simple coding
Simple coding

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

5.2 A conversion function

The solution is to use the built-in function int that takes a string and converts it to an integer, which is a number like –2, –1, 0, 1, 2, etc. If the string represents a decimal number, int will give an error.

Interactive feature not available in single page view (see it in standard view).

Activity 9

Change the restaurant program (repeated below) so that it asks the user for the number of people.

Interactive feature not available in single page view (see it in standard view).

Next, in Section 6, you’ll learn a different form of iteration..

Take your learning further

Making the decision to study can be a big step, which is why you'll want a trusted University. The Open University has 50 years’ experience delivering flexible learning and 170,000 students are studying with us right now. Take a look at all Open University courses.

If you are new to University-level study, we offer two introductory routes to our qualifications. You could either choose to start with an Access module, or a module which allows you to count your previous learning towards an Open University qualification. Read our guide on Where to take your learning next for more information.

Not ready for formal University study? Then browse over 1000 free courses on OpenLearn and sign up to our newsletter to hear about new free courses as they are released.

Every year, thousands of students decide to study with The Open University. With over 120 qualifications, we’ve got the right course for you.

Request an Open University prospectus371