Friday, October 16, 2020

Project 1: Hello World!

Project 1:  Hello World!

For my first project, I present a mad lib generator!  Writing codes for the first time can seem daunting, but practice makes perfect.  Building a mad lib generator is probably one of the simplest, if not the simplest, assignment to take on when writing code, so definitely give it a try!

Merits on making mad lib generators:
  • Allows you to learn the most basic functions by heart
  • There are many mad libs online to choose from if you find it difficult to make a story of your own
  • It's very fun to play mad libs with friends!

Below is my mad lib code:
(Alternatively, if you would prefer to view the PDF version, click here)


A review of the functions used:

  • def
    • Short for "define"
    • Used to "define" (or name) a new function that the programmer creates
    • Allows the function to be used again and again
      • It is useful for playing the same mad lib again with different people or different word choices
  • print()
    • "Prints" out whatever is contained within the bracket
    • When writing a string in the bracket, make sure to use quotation marks (") or (') or else you may get an error
      • String is a sequence of characters
  • input()
    • Prompts the user to "input" a string 
    • e.g. f=input("Enter name: ")
      • The user is prompted to enter a name
      • f now means the name entered
      • This becomes relevant in print(f) in which the name is printed out in the final line
Other points to keep in mind:
  • +
    • Used for adding strings together (also called "concatenation")
    • For example
      • print("bull")
      • bull
      • print("dog")
      • dog
      • print("bull" + "dog")
      • bulldog
  • ,
    • Used for making a space in between strings
    • For example
      • print("bull")
      • bull
      • print("dog")
      • dog
      • print("bull" , "dog")
      • bull dog

Here is the mad lib generated with my word choices.  Once you've had a good laugh, try and write codes to make your own mad libs and laugh some more!
(Alternatively for the PDF version, click here)









No comments:

Post a Comment

A New Frontier: Building bots without code!!!

 Dear Readers,  Welcome back to this month's Chronicles of a Neurodivergent Programmer.  Last month, I took a break from writing about t...