Skip to content
Learnearn.uk » Python Unit Home » Functions

Functions

Challenge 55

Challenge 55 – getANumber(question)  function

Create a function that:

  • Allows an input parameter of a question
  • Repeatedly asks the question until a number is entered.
  • Returns the number

Challenge 56

Challenge 56 – getLetters(question) function

Create a function that:

  • Allows an input parameter of a question.
  • Repeatedly asks the question until only a string of letters is entered.
  • Returns the string.

Challenge 57

Challenge 57 – getALetter(question) function

Create a function that:

  • Allows an input parameter of a question
  • Repeateadly asks the question until a single letter is entered
  • Returns the letter

Challenge 58

Challenge 58 – getASingleDigitNumber(question) function

Create a function that:

  • Allows an input parameter of a question
  • Repeateadly asks the question until a single number is entered
  • Returns the number

Challenge 59

Challenge 59 – getYesNo(question) function

Create a function that

  • Allows an input parameter of a question.
  • Repeatedly asks the question until a yes / no answer has been entered.
  • Valid inputs – Yes,No,Y,N   (lowercase or uppercase or mix)
  • Returns Boolean True / False depending on the answer.

Challenge 60

Challenge 60 – getEmail(question) function

Create a function that:

  • Allows an input parameter of a question.
  • Repeatedly asks the question until a valid email address is entered.
  • Returns the email address

Challenge 61

Challenge 61 lettersToMorse(letters) function

Create a function that:

  • accepts a string as an argument
  • Translates each letter in to more code.
  • Returns a string of morse code in the following format
    • Each letter is separated by a space
    • Each word is separated by a /
    • g. Mr West goes to : — .-. / .– . … –

Challenge 62

Challenge 62 createPassword(question) function

Create a function that:

  • Allows an input parameter of a question.
  • Repeatedly asks the question until a valid password has been input.
    • Must have a mix of uppercase and lowercase letters
    • Must contain a number
    • Must contain a symbol from !”£$%^&*()_+
    • Must be at least 8 characters long.
  • Returns the password