Creating Karel’s world Let’s start simple. This challenge will help you practice the basics of writing functions. Define three new functions: 1) to ask the user for a positive integer (representing the size for Karel’s world),

computer science

Description

# Challenge 1: Creating Karel’s world Let’s start simple. This challenge will help you practice the basics of writing functions. Define three new functions: 1) to ask the user for a positive integer (representing the size for Karel’s world), 2) to display the dimensions of Karel’s world to the console, and 3) main(), which organizes and calls your other functions. Details are below. 


Function definition (main): In main(), is where you will organize and call your other functions. It’s always good practice to write main() first, so you can plan what your program needs to do.


In your function definitions, it is good practice to put main() either first or last so it is easy to find. (This means - Don’t put the main() function definition in the middle of your function definitions. Even though your code will still compile, this is bad programming practice because it’s confusing for other programmers who may read your code later).


Your main() function should: - call your (own) function to get user input. The get user input function should return a value, representing the dimension of Karel’s world. - Next, call your (own) function to display the dimensions of Karel’s world. We pass one parameter into this function (the variable representing the dimension of Karel’s world, that was just returned from the get user input function). 


Since it’s your first time writing functions, here is a really big hint! You can use or adapt this code to get yourself started.


Related Questions in computer science category