So… One really cool thing about Python is that it’s a really straight forward language. You can see many examples of this, like printing something, making a conditional, and other stuff. One does not need to go through too much trouble to wrap ones head around understanding how Python works. Another example is the topic […]
Here’s the code for quiz 8: https://github.com/Dragv/quiz08 It took me a while to try to make as compact as possible since my first solution took a about double the length of the final code.
So… Here’s my code for the quiz. It was quite interesting quiz to make. It wasn’t that the task was hard but at least for the second one I had to think on it a tad bit more. https://github.com/Dragv/quiz7/tree/master
Here’s the Github URL that contains both files of Quiz 6 https://github.com/Dragv/Quiz6/tree/master
A while is a loop that as the condition that it is in is met, it will keep performing and action: Here’s an example of that: As long as the user doesn’t input the right number, the program will keep asking him to try again.
“If” is really simple. You write a parameter with variables such that if thats true, the program does something. The “else” makes it so that of the parameters of the conditional aren’t met, the program does something else. And an “elif” is like an “else” but with a conditional. Here’s an example.
To print something in python you just write print and what ever you want the terminal to print in parenthesis.
Like this:
Making a Python file is pretty easy. Open a new Atom sheet and save it as a .py file.
All right, now write your code.
now run it with the command line.
Easy as pie.
This one took me a bit to get it. I didn’t quite get the whole for thing and range the first time, but after playing with it a little I got the hang of it pretty quickly. Anyways, here’s the code:
So this one is a little bit more simple than the last one. The program chooses a number randomly and asks the user to guess the number. When the user finally gets it, it tells him or her how many tries did it take. Simple, right? Well not going t lie, I did have my […]