Chapter 2.2 - Exercise
Be more friendly
Your goal is to extend the hello world program to be more friendly. Instead of greeting the whole world, it should ask the user for their name and greet them specifically. The program should be stored in a script and executing it should look like this:
Please enter your name: nomike
Hello, nomike. Nice to meet you!
Calculate the sum of two values
After greeting the user, the program should ask them to input two numbers and it should print the sum on the screen:
Please enter a number: 4700
Please enter another number: 11
The sum of those numbers is 4711.
Solution
When you're done, you could compare your code with the solution. Does your code look similar? Does it produce the same results as the example above?
Invalid input
For now this simple program could not handle invalid user input. Try inputting text instead of integers when asked for numbers.
This requires more complex code and I will show you how to make your code more resilient in a later chapter.
But let's have a look at conditions now, which are the main topic of chapter 3.