In a modify task you take code that already works and adapt it so that it does something else.
The editor starts you off with a sub program that says where someone is from, and one call to it:
def my_function(country):
print("I am from " + country)
my_function("Brazil")
Adapt the code so that it reports two countries: a fixed one, and one the user chooses.
my_function
tells a reader nothing at all. Pick something meaningful, write it in lower
case with underscores between the words, and remember to rename it at the call
as well. Python matches the two names character for character, so if you change
one and not the other the program stops working.Sweden instead of Brazil.print, exactly as written:
Which country are you from?
Read the answer with a bare input() and store it in a variable.
Do not change the body of the sub program. It is already right, and the
sub program’s own print should still be the only one that prints a country
line.
Your program prints exactly three lines, in this order:
I am from Sweden
Which country are you from?
I am from Belgium
The first line is always the same, because Sweden is written into the call.
The second line is the question, printed exactly as written above. The third
line ends with whatever the user typed, so it changes from run to run.
Input:
Belgium
Output:
I am from Sweden
Which country are you from?
I am from Belgium
Input:
New Zealand
Output:
I am from Sweden
Which country are you from?
I am from New Zealand
Input:
Brazil
Output:
I am from Sweden
Which country are you from?
I am from Brazil
The question is part of the output that is checked here, so its spelling,
capital letters and punctuation count. Ask it with its own print, exactly
Which country are you from?, and read the answer with a bare input() on
the next line, rather than passing the question to input(...).
Renaming the sub program is part of the task, but it is not something Dodona can check: the tests compare what your program prints, and the output is the same whatever the sub program is called. Do it anyway. A name that says what the code does is worth more than a name that runs.
Make sure that you check for the following things:
def line and at both calls. Capital letters count.def line.def line has exactly one
parameter.