Skip to content

Houses examples and an exercise for as many programming languages as i can learn

Notifications You must be signed in to change notification settings

syreal17/Language-Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

How to learn any programming language (or start with it)

Many people asked me: how do i learn a programming language? My answer usually is: start by reading documentation and trying to figure things out.

That approach is not always the best, so i made a small exercise that can teach the basics of pretty much every language.

The Exercise

Make a small calculator app that can handle basic functions like addition, subtraction, multiplication, division and exponentiation and has a CLI interface like this:

{Language} CLI calc V1.0
choose a function
1 - Add        3 - Multiply   5 - Exponentiation
2 - Subtract   4 - Divide
>>> 5

{function} - Please choose two numbers a and b to calculate {expression}
a: {num_a}
b: {num_b}
result: {result}
Press enter to restart...

Requirements

  • It must have the above interface
  • it must use functions/methods
  • builtins are not allowed unless it is to interact with the terminal
  • it must have a loop that waits for enter to restart
  • it must handle keyboard interrupts without error
  • it must not error out
  • it must have comments

Optional

  • use as few if-statements as possible
  • make it efficient (space, time, length)
  • make it fancy (color, slight UI change, whatever)
  • add docstrings
  • do it in as few formatted lines as possible

About

Houses examples and an exercise for as many programming languages as i can learn

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published