Skip to content

Instantly share code, notes, and snippets.

View HandsonMatheus's full-sized avatar
💭
tchururu

Handson Matheus HandsonMatheus

💭
tchururu
View GitHub Profile
# THIRD EXERCISE ON PRACTICEPYTHON.ORG
# Creating the list
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
# Checking if the number is less then 5
def print_less_than_5(list):
for number in list:
if number < 5:
print(number)
# SECOND EXERCISE ON PRACTICEPYTHON.ORG
def even_or_odd(number):
if number % 2:
return "Even"
else:
return "Odd"
print(even_or_odd(4))
import random
def play_guessing_game():
# GENERATE A RANDOM NUMBER BETWEEN 1 AND 100
secret_number = random.randint(a=1, b=100)
attempts = 0
guessed = False
print("\nwelcome to the Handson's Number Guessing Game")
print("I am thinking of a number between 1 and 100.")
"""
Create a program that asks the user for a number and then prints out a list of all
the divisors of that number. (If you don’t know what a divisor is, it is a number
that divides evenly into another number.
For example, 13 is a divisor of 26 because 26 / 13 has no remainder.
"""
def divisor(n):
for i in range(1, n+1):
def palindrome(word):
return word == word[::-1]
input_word = input("Enter a word: ")
if palindrome(input_word):
print("The word is a palindrome")
else:
print("The word is not a palindrome")
import random
import time
rock = 1
paper = 2
scissor = 3
def cpu_intelligence():
cpu = random.randint(1, 3)
if cpu == 1:
import random
secret_number = random.randint(1, 9)
print("You have 5 tries to guess the secret number (1-9)")
while True:
try:
player_guess = int(input("Type your guess >>> "))
if player_guess == secret_number:
import random
secret_number = random.randint(1, 9)
print("You have 5 tries to guess the secret number (1-9)")
while True:
try:
player_guess = int(input("Type your guess >>> "))
if player_guess == secret_number:
import random, time
BAR = chr(9608) # Character 9608 is "█"
def main():
# simulate a download
print("Progress bar simulation")
bytes_downloaded = 0
download_size = 2048
while bytes_downloaded < download_size: