Python Programming

June 16, 2023

Cool Mad Libs Simple Casino Python Game!

print(“Welcome to the Mad Libs Casino! Please pay a coin to play.”) # welcoming user ask = input(“Do you want to play: Reply with yes, or no.”) if ask == “no”: print(“Then why did you run this program in the first place? You’re still\n going to play.”) if ask == “yes”: name = “” # last few lines will be filled later adjective = “” favouriteSnack = “” number = “” activity = “” creature = “” verb = “” adjective2 = “” Name = input(“Give a name: “) #user input Adj = input(“Give an adjective: “) FavSnack = input(“Give...

Read More
February 8, 2023

Python Index

Indexes are perfect to use in Python when you have to locate a certain part in a string. For example: In the code above, abc is put into index of abc. The quotations say b, so where is b? Start from the start, and count. a is 1, space is 2, b is 3. So b is located in 3. Here is another example: Now we find “u” in queue. q is 1. u is 2. So print 2. We don’t print 4 because that u is after.

Read More
February 6, 2023

Python Lists

Python lists can be extremely useful. What is a list? A list holds elements together. Example: The element “hi” is element 0. “hello” is number 1. So the first element we see is actually the 0th element in Python. What you can do to a list: (result is below) Also:

Read More
February 4, 2023

Python Order of Operations

In math, we use order of operations. Multiplication and division goes first, unless brackets, then addition and subtraction. Python also has them, just with more rules. The order of operations goes from highest to lowest rank, in order: parentheses ( 1+1 ) * 2 exponents 1 ** 2 unary plus and minus +a, -a multiplication, division, remainders ( 1 * 2 / 1 ) % 3 addition and subtraction 1 + 1 – 2 comparing operators 1 < 2, 2 > 1, 3 == 3, 1 != 2, 1 <= 2 , 2 >= 1 boolean NOT (not) x =...

Read More
October 4, 2022

‘Python Lottery’ Explanation

Key: italic is for python functions and bold is for variables. First: The # signs represent a comment. Comments can help someone understand the code. It’s like a silvery ghost. import random indicates that random will be used in this code to help choose random numbers for the lottery. When you don’t use this, import random is gray. Alright, MyChoice is a set of numbers I randomly picked. It doesn’t have to be exactly that set of numbers, but I chose that set. You’ll see why soon… Balance tells the money I have. Right now I pretend I have $1000....

Read More
October 2, 2022

Why The Lottery Tricks You

You might have thought that the lottery is pretty cool, right? You only spend a speck of your money and can get more! And you have a big chance of winning the money because you get to choose more than 1 number, right? Well, that might be what most people think, but the lottery has a very special way of earning money. True, a very, very lucky person might win that pile of cash, but by that time, the lottery has got more than millions of dollars from people who don’t recognize what the lottery wants to do and what...

Read More
June 28, 2022

DMOJ-Special Day 3p

Question: February 18 is a special date for the CCC this year. Write a program that asks the user for a numerical month and numerical day of the month and then determines whether that date occurs before, after, or on February 18. If the date occurs before February 18, output the word Before. If the date occurs after February 18, output the word After. If the date is February 18, output the word Special. Input Specification The input consists of two integers each on a separate line. These integers represent a date in 2015. The first line will contain the month, which will be...

Read More
June 25, 2022

More Python (If You’re Interested)

OK, since you’ve learned some Python from my previous blog, let’s see if you’ve sucked up all of my information. Sorry, no hints! This is a test (Maybe not, but I’m just expressing myself.) . I’ll present you a DMOJ question and if you like, as a “test”, you can install a Python 3 file and find the answer yourself. Or if your Python skills aren’t that strong yet, review my solution to see if you understand why this answer makes sense. Start! Problem of the Day Let’s start with the DMOJ problem: In the story Goldilocks and the Three...

Read More
June 25, 2022

Diving Deep in Python

Well, today I dove deeper into Python 3 and tried some new functions. It’s pretty hard, so if you are not that experienced, you may want to learn the basics of this language. You could read one of my past blogs about the very first Python basics. Let’s get started now. DMOJ Problem In DMOJ, there was quite a question. So there someone who has an amount of sugar. Let’s call the amount a. You need b amount of sugar. You have c amount of toothpaste but need d amount of it. Determine is you need to go to the...

Read More