Welcome to Aardvark, the language that has entranced programmers by its simplicity and amazingness for the last few days.
My goal is to by the end of this lesson have taught you the basics of the Aardvark language and get you on a course to become an amazing Aardvark developer.
In programming, you usually start with a Hello World program, but let's mix it up this time, lets start by learning how to write a program that takes the user's username as input and outputs a random welcome message. But first, we need to learn basic input and output.
This code will output
This is my Aardvark program!:
output("This is my Aardvark program!")
You see, not that hard, now don't forget the quotes, it won't work right without them. Let's look at what this code does,
output has parentheses, which means its a function, and then inside the quotes are the message that shows up on the screen. Hmm, I wonder if I can change what's in the quotes and it will change the message, lets try it:
output("This is a different message")
If you run that program you will see that it worked! Now let's learn how to take user input:
input("Enter your username: ")
If you run that code, you will see that it will give that message and then let you type in an answer. But how do we store that answer in our program? We use variables, variables store data for use later in the code. So if we add
a = to the beginning of that then it will store the input in the variable
a, lets try it:
a = input("Enter your username: ")
How do we know if it worked? Well, let's try to output the data inside
a. Try this code:
a = input("Enter your username: ") output(a)
When you output variables, you don't need those quotes. Let's run it. When we run it, it will ask for our username and then output what we typed in. We can already get their username, we still need the random welcome message, lets first start with just a welcome message. If we output "Welcome, " before we output what they typed in, it would say
Welcome, plus their username. Let's try it:
a = input("Enter your username: ") output("Welcome, ") output(a)
It worked! Let's simplify it, just do
"Welcome, " + a instead of doing it on separate lines. Try this:
a = input("Enter your username: ") output("Welcome, " + a)
It worked! We now have our username input and our welcome message, but what about the random. How can we make it do something random?
In Aardvark, the tools module has some functions to help us do random stuff. But how do we include a module? Try this code:
It makes all the functions in the tools module available in our program, lets add it to our code:
#include tools a = input("Enter your username: ") output("Welcome, " + a)
Now, what is the function to do random stuff? In Aardvark, you can use the
randomchoice function from the tools module to make random choices.
randomchoice takes a list of possible choices as its one argument. How do we make a list in Aardvark? Just put it in between
] and separate the items by commas. Let's try this code:
#include tools username = input("Enter your username: ") message = randomchoice("Welcome, ", "Hello, ", "Have a good day, ") output(message + username)
It worked! We have reached our goal!
If you would like to continue learning Aardvark, watch for future tutorials, or go to our website.
People here not knowing what Read the Docs and iframes are... :(
I'm not a Talk mod (just a fellow from the Discord) so I can't say for sure but I believe that hosting the docs there is fine, and it's very clear that you aren't making money off of it and I really don't get all the antagonizing.
So people don't get confused may I suggest instead of using an iframe, link to your Read the Docs site in a new tab? Of course, having the documentation on the repl.co site itself is fine too and means you wouldn't have to deal with ads. (That said, I have used RTD myself for my documentation in the past and it's very handy!)
You have a very fine project and I wish you best of luck in the competition.
No. It's beyond his abilities rn. After he hosts it on repl.it (and I mean with the majority of code, not with the iframe to readthedocs that he currently has), he'll be able to remove ads. He is not making a profit off of the advertisements, and moderators have deemed it appropriate. @HahaYes
pythonCode.replace('print', 'output').replace('import', '#include')
That's what I'm seeing