Aye, more challenging tasks, savvy?

Skip to content

Avast ye, this be a machine-translated text an’ may contain errors, aye!

Task 1 - “Loggin’ In”

Craft a simple program that asks the user for a password. If the password matches the correct password, the program shall print a message.

Hint: Store the correct password in a variable and compare it to that variable.

Eksempel Utskrift
Type yer password: password123
Aye, that be the right password!

Tips til framgangsmåte
  • How to pluck text from the landlubber 👉[Python 1, Level 1]
  • How to check if the text be matchin’ somethin’.
  • Ye must use if for this task.
  • Feel free to use else to print a message if the password doth not match.

Task 2a

Ask the scallywag for a colour, then print a message based on the colour they chose.

Add at least 4 colours to check. Examples: Red, Green, Blue, Yellow

Eksempel Utskrift
Write a colour: red
Red be a warm colour, aye!

Tips til framgangsmåte
  • How to check if the text be like somethin’.
  • Here ye must use if, elif and else.
  • Hint: Ye can have more than one elif.

Task 2b

Aye, a thing worth ponderin’ be that, for a computin’ machine

Alter the code to function no matter what ye scribble in for the color.

For example: Ye write røD, it still gives ye the message for red, savvy?

A new concept! lower() function!

To solve this ye must use somethin’ not mentioned in Level 1:

lower(). This function turns all the text to “lowercase”, meanin’ only small letters.

It can be used like this:

tekst = "hELlo WoRLd!"
sma_bokstaver = tekst.lower()
print(sma_bokstaver) # prints out "hello world!"

There be also upper() to turn everythin’ to CAPITAL letters.

Eksempel Utskrift
Write a colour: red
Red be a warm colour, aye!

Tips til framgangsmåte
  • Once ye’ve plundered the text from the landlubber, turn it to lowercase first afore checkin’ the colors.

Task 3

Behold, is the weather fair or foul? Ask the landlubber for a temperature in Celsius. Then, give ‘em a message dependin’ on whether ‘tis warm or cold.

Eksempel Utskrift
What be the temperature: 30
'Tis a warm day, aye!

Tips til framgangsmåte
  • How to pluck numbers from the landlubber 👉[Python 1, Level 1]
  • Check if a number be higher or lower than a certain mark. 👍[Python 2, Level 1]

Task 4 - Compare Two Numbers

Create a program where ye ask the user for two numbers. Compare these two numbers to each other and give a message if the “first” or “second” number be larger.

Tips til framgangsmåte
  • How do we compare two variables, aye?

Task 5 - Be it Weekend, Aye?

Craft ye a program that asks the user for a day o’ the week, then checks if ‘tis the weekend or not. Print a message if ‘tis the weekend, or a message if ‘tis not!

A new concept! or the keyword!

In this task, it may be useful to employ or. We haven’t spoken about this yet, but it be very simple!

Ye can use this to compare two things at once!

if number == 2 or number == 3:
    print("That be correct!")     

There be also and, where both cases must match at once for it to work.

Eksempel Utskrift
Write a day o' the week: Saturday
'Tis a weekend! Woohoo!

Ekstra utfordring

Ye can accomplish this with nothin’ but a if and a else, how might ye do it?

Task 6 - Grade System

Craft a program that takes a score between 0 and 100 and returns a “Grade” for it.

Score Grade
Over 90 6
Between 75 and 89 5
Between 60 and 74 4
Between 50 and 59 3
Between 40 and 49 2
Under 40 1

Tips til framgangsmåte
  • How do we check if a number be exceedin’ a certain value, aye?
  • Hint: We need never check if a value be below a given value here, so long as ye check in order from the highest grade to the lowest.

Task 7 - A Simple Calculator

Ask the landlubber for two numbers, then ask for an “operator” for the reckonin’. Start with addition + and subtraction -. Do the calculatin’ and print the answer to the scallywag.

Eksempel Utskrift
Write ye a number: 14
Write ye yet another number: 18
Write ye an operator: +
The answer be: 32

Tips til framgangsmåte
  • First, let’s be learnin’ how do we add two numbers together, aye?
  • How do we be gettin’ numbers from the user, savvy?
  • How do we be addin’ two variables together, eh?
  • Now, let’s be fetchin’ the operator as well.
  • How do we be checkin’ which operator be writ, arr?