Code Monkey home page Code Monkey logo

deafgrandma's Introduction

Deaf Grandma

This small challenge comes from Chris Pine's "Learn to Program". Ensure that you read everything and click every link before starting the work.

Premise

Write a program which can imitate a Grandma who's hard of hearing and follows these constraints:

  • If you don't input anything (just hit enter) she responds with WHAT?!

  • If you ask a question with any lower-case letters, she responds with SPEAK UP, KID!

  • If you talk to her in all upper-case letters, she responds with NO, NOT SINCE 1946!

  • The first time you say GOODBYE! she says LEAVING SO SOON?

  • The second time you say GOODBYE! she says LATER, SKATER! and the program exits.

Example

HEY KID!
> hi, grandma
SPEAK UP, KID!
> I SAID HI, GRANDMA
NO, NOT SINCE 1946!
>
WHAT?!
> Goodbye!
SPEAK UP, KID!
> GOODBYE!
LEAVING SO SOON?
> GOODBYE!
LATER, SKATER!

Considerations (Python)

  • In your code you'll definitely need to use if and likely an elif and else.
  • Also remember that input() is the "inverse" method of print() -- while print() outputs information to the terminal, input('command Prompt') captures information from the user by presenting a command prompt and allowing them to type input.
  • If you have an infinite loop, how might you break out of it?

Considerations (Javascript)

  • In your code you'll definitely need to use if and likely an else if and else.
  • This will be hard to do in the terminal with Node.js, because Node.js doesn't have a great built-in prompt.
  • This is relatively easy to do in the browser with window.prompt, but you'll need to use an HTML file to run your javascript file.

Challenge Yourself

For a little extra fun, try refactoring your code to use regular expressions.

deafgrandma's People

Contributors

dennis0451 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.