Codementor Events

Python Project(Descriptions and Code)

Published Nov 08, 2019Last updated Dec 17, 2019
Python Project(Descriptions and Code)

So this is where I will put the code and descriptions of the project experiences that I did. I'm gonna updated this post usually to post the project that I made and updated some features and code to make the projectmthat I made better.
Basically, this is just the place where all of the informations and details of the project that I did. The project that I didn't mention in project experiences will be here. But it will has less descriptions or maybe just a sentense than the project that there are in the project experiences of mine.
Let's get started, sorry for my bad english.
Rock Paper Scissor Game
For me this project is kinda like not really basic and simple. This project is for Intermediate people. This rock paper scissor game is using random choice because the game is let you fight the computer such as the machines. But there is a patter of the answer, so you could win all the time and won't lose. If you lose you can try again and again you can play agin if you win.
The code:

import random
print("Rock Paper Scissor Game")
name = str(input("Enter your name: "))

repeat = "yes"
while repeat.lower() == "yes":  
    print("Enter your choice \n 1. Rock \n 2. paper \n 3. scissor \n")
    choice = int(input("Enter your choice: "))
    
    if choice == 1:
        choice_name = 'rock'
    elif choice == 2:
        choice_name = 'paper'   
    elif choice == 3:
        choice_name = 'scissor'    
    else:
        print('''
Please, choose the options above.
Choose 1 or 2 or 3
        ''')

    print(f"{name}'s choice is: " + choice_name)
    comp_choice = random.randint(1, 3)

    if comp_choice == 1:
        comp_choice_name = 'rock'    
    elif comp_choice == 2:
        comp_choice_name = 'paper'    
    else:
        comp_choice_name = 'scissor'

    print("Computer choice is: " + comp_choice_name)    
    print(choice_name + " VS " + comp_choice_name)

    if choice == 1 and comp_choice == 2:
        print("Computer Wins, computer picked paper.")     
    elif choice == 2 and comp_choice == 1:
        print(f"{name} Wins, {name} picked paper.")
    elif choice == 2 and comp_choice == 3:
        print("Computer Wins, computer picked scissor.")     
    elif choice == 3 and comp_choice == 2:
        print(f"{name} Wins, {name} picked scissor.")
    elif choice == 1 and comp_choice == 3:
        print(f"{name} Wins, {name} picked scissor.")
    elif choice == 3 and comp_choice == 1:
        print(f"Computer Wins, Computer picked scissor.")    
    elif choice == 3 and comp_choice == 3:
        print(f"It's a tie")
    elif choice == 1 and comp_choice == 1:
        print(f"It's a tie")
    elif choice == 2 and comp_choice == 2:
        print(f"It's a tie")
    else:
        print("Please choose option 1/2/3")

    repeat = str(input("Do you wish to play again?"))
    if repeat == "no":
        break

print("Thanks for playing")

HangMan Game
Basic and simple hangman game. Actually my code won't give a picture where there is actually a hangman. But there will be points, that will decrease if you guess the secret word wrong.
Features:

  1. Hint
  2. Points
  3. etc
    In this game if you answer it wrong, decrase 1 point. If you use hint, decrease 3 points. If you don't have any points you died. That's like the
    rules of the HangMan game. The right words can be mixable
    Client: Thank to Ilyaas Lunat, I could make this project. Because his post remind me about it. You guys should check his profile also.
secret ="you can change the secret word"
guess =""
hint = 'you can change the hint or you can delete it and delete it in the elif statement'
point = 10

print('''HangMan game
You can change the introduction and the instructions''')

while guess != secret:
    guess = str(input("Enter the secret word:"))
    if guess == secret:
        print("You got it right")
        break
    elif guess == "hint":
        print(hint)
        point = point - 2
        print(f"you have {point} point left")
    elif guess in secret:
        print('You got it almost correct')
    else:
        print("Try Again. Type hint, if you need help")
        point = point - 1
        print(f"you have {point} point left")
        if point <= 0:
            print("You Died")
            breakou have {point} point left")
        if point <= 0:
            print("You Died")
            break

Quadratics Equations Calculator
This is a calculator for finding the answer for quadratics equations calculator. But the different thing with this calculator is this will give you yes and no options if you want to know the minimum point of the quadratics equations.
Summary of features:

  1. Solve quadratics equations questions
  2. It can be used for 2 and 3 variables(a and b or a and b and c)
import math

print("Quadratics Equation Calculator")
repeat = "yes"
while repeat.lower() == "yes":

    V = float(input("Enter how many Variables do you have in the question: "))
    print(V)
This code works for 3 variables in 1 equation/question.
This code can work to find the minimum point of the equations of the question
    if V == 3:
        a = float(input("Enter the first variable: "))
        print(a)
        b = float(input("Enter the second variable: "))
        print(b)
        c = float(input("Enter the third variable: "))
        print(c)
        root_1 = ((-1 * b) + math.sqrt((b ** 2) - (4 * a * c))) / (2 * a)
        root_2 = ((-1 * b) - math.sqrt((b ** 2) - (4 * a * c))) / (2 * a)
        print(f"The first result is {root_1} to {round(root_1)}")
        print(f"The second result is {root_2} to {round(root_2)}")
        graph = str(input("Want minimum point: "))
        if graph == "yes":
            x = ((b / 2) * -1)
            y = c - b ** 2/4*a
            print(f"The minimum point is ({x}, {y})")
This code works for finding the answer for only 2 variables in a equations/questions
But it doesn't find the minimum point of it.
    elif V == 2:
        a = float(input("Enter the first variable: "))
        print(a)
        b = float(input("Enter the second variable: "))
        print(b)
        root_1 = ((-1 * b) + math.sqrt((b ** 2) - (4 * a * 0))) / (2 * a)
        root_2 = ((-1 * b) - math.sqrt((b ** 2) - (4 * a * 0))) / (2 * a)
        print(f"The first result is {root_1} to {round(root_1)}")
        print(f"The second result is {root_2} to {round(root_2)}")
        graph = str(input("Want minimum point: "))
        if graph == "yes":
            x = ((b / (2*a)) * -1)
            y = 0 - b ** 2/4*a
            print(f"The minimum point is ({x}, {y})")
        elif graph == "no":
            repeat = str(input("Do you wish to continue?: "))
            if repeat == "no":
                break

    else: 
        print("INVALID ERRORS, CHECK AGAIN YOUR VARIABLES")
        print("Type yes or no.")

    repeat = str(input("Do you wish to continue?: "))
    if repeat == "no":
        break

Dice Roller
This will roll a dice and it can be used multiple times. This is the second game that I made with python. It's super basic and simple to make. In the game there are 2 options, 1 is about play where you duel with somebody else(It's not online) and see who is the winner and the new update is you can play with computer. 2 is about go, where you just let the machine roll the dice for you randomly. You can choose how many dice do you want to use. After that it will tell you what is the minimim value of the dice and the maximum value of the dice.
The code:

from random import randint
import math

repeat = "yes"
while repeat.lower() == "yes":
    print("Dice Automatics roller and games")
    print("Play = type \"play\" \nRandom Roller = type \"tool\"")
    choose = str(input("Enter: "))
    dice = int(input("How many dice do you want to use: "))
    if choose == "play":
        again = str(input("Computer fight or duel fight, Enter: "))
        repeat = "yes"
        while repeat.lower() == "yes":
            if again == "duel":
                player1 = str(input("Enter name: "))
                player2 = str(input("Enter name: "))
                print("Initializing....\nRolling....")
                roll1 = (randint(dice*1, dice*6))
                roll2 = (randint(dice*1, dice*6))
                print(f"Info:\nMinimum = {dice*1}\nMaximum = {dice*6}")
                if roll1 > roll2:
                    print(f"{player1} won")
                    print(f"{player1} point: {roll1}")
                    print(f"{player2} point: {roll2}")
                elif roll2 > roll1:
                    print(f"{player2} won")
                    print(f"{player2} point: {roll2}")
                    print(f"{player1} point: {roll1}")
                else:
                    print("It's a tie")
            elif again == "computer":
                player = str(input("Enter your name: "))
                roll = (randint(dice*1, dice*6))
                comp_roll = (randint(dice*1, dice*6))
                print(f"Info:\nMinimum = {dice*1}\nMaximum = {dice*6}")
                if roll > comp_roll:
                    print(f"{player} won")
                    print(f"{player} point: {roll}")
                    print(f"computer point: {comp_roll}")
                elif comp_roll > roll:
                    print(f"computer won")
                    print(f"computer point: {comp_roll}")
                    print(f"{player} point: {roll}")
                else:
                    print("It's a tie")
            else:
                print("Please choose duel fight or computer fight")
            repeat = str(input("Wanna play again?: "))
            if repeat == "no":
                break
    elif choose == "tool":
        repeat = "yes"
        while repeat.lower() == "yes":
            print("Initializing.....")
            total = (randint(dice*1, dice*6))
            print(f"Info:\nMinimum = {dice*1}\nMaximum = {dice*6}")
            print(f"The total: {total}")
            repeat = str(input("Wanna play again?: "))
            if repeat == "no":
                break
    else:
        print("Please choose: \nPlay = type \"play\" \nRandom Roller = type \"tool\"")
    repeat = str(input("Wanna play again?: "))
    if repeat == "no":
        break

Random List Picker
The random list picker will be used such as randomly picked something from the list in the code. So you need to write the data in the list on the code, not in the output. If the list is some words/letters/alphabets you need to write quotations mark before and after the words. But you don't need to write quotations marks if the list is numbers.
See the examples in my code:
The code:

import random

list = ["Examples:", "Hello World", 2, 3, 4, 5]

print("Random picker")
cont = "yes"
while cont.lower() == "yes":
    print("Initializing...")
    print (random.choice(list))

    cont = str(input("Do you want to continue: "))
    if cont == "no":
        break

Temperature Converter
Temperature Converter, the will convert celsius, fahreinheit and kelvin. It will tell the user if they use the same type of temperature. You can see the instructioins, because I made the converter like this. Degree Celsius, you write it "C". Fahreinheit, you write it "F". Kelvin, you write it "K". All of them are on the instructions of my code.

import math

Instructions = "Celsius = C", "Fahreinheit = F", "Kelvin = K"

print("Temperature Converter")
print(Instructions)
repeat = "yes"
while repeat.lower() == "yes":
    A = str(input("Enter your temperature: "))
    B = str(input("Enter type of temperature that you want: "))
    if A == "C":
        if B == "F":
            V = float(input("Enter your variable: "))
            answer = (V * 9/5) + 32
            print(answer)
        elif B == "K":
            V = float(input("Enter your variable: "))
            answer = V + 273.15
            print(answer)
        elif B == "C":
            print("It's the same type of temperature")
        else:
            print("ERROR")
    elif A == "F":
        if B == "F":
            print("It's the same type of temperature")
        elif B == "K":
            V = float(input("Enter your variable: "))
            answer = (V - 32) * 5/9 + 273.15
            print(answer)
        elif B == "C":
            V = float(input("Enter your variable: "))
            answer = (V - 32) * 5/9
            print(answer)
        else:
            print("ERROR")
    elif A == "K":
        if B == "F":
            V = float(input("Enter your variable: "))
            answer = (V - 273.15) * 9/5 + 32
            print(answer)
        elif B == "K":
            print("It's the same type of temperature")
        elif B == "C":
            V = float(input("Enter your variable: "))
            answer = V - 273.15
            print(answer)
        else:
            print("ERROR")
    else:
        print('''Degree Celsius=C
Fahreinheit=F
Kelvin=K)
''')
    repeat = str(input("Do you wish to continue?: "))
    if repeat == "no":
        break

Length Converter
This is not a calculator, but it's technically like a calculator to convert length that you have and what you want. This converter is used to convert length from km to mm, because those are the most common things to do I think. But still this is not perfect I will update it later and maybe next time I will add things that are longer than km and shorter than mm. when you write the type of the length please write it in no capital letter and whrite it the logo or the abbreviation on it.
The code:

import math

cont = 'yes'
while cont.lower == 'yes':
  print("Calculator to convert any type of length")

  length1 = str(input("Enter the unit that you have: "))
  print(length1)
  length2 = str(input("Enter the unit that you want to be convert: "))
  print(length2)
  Variable = float(input("Enter the variable that you have: "))
  print(Variable)

  if length1 == "km":
      if length2 == "hm":
          answer = Variable * 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dam":
          answer = Variable * 100
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "m":
          answer = Variable * 1000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dm":
          answer = Variable * 10000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "cm":
          answer = Variable * 100000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "mm":
          answer = Variable * 1000000
          print(Variable ,length1, "is", answer, length2)
      else:
          print("Invalid error units and variables")

  elif length1 == "hm":
      if length2 == "km":
          answer = Variable / 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dam":
          answer = Variable * 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "m":
          answer = Variable * 100
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dm":
          answer = Variable * 1000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "cm":
          answer = Variable * 10000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "mm":
          answer = Variable * 100000
          print(Variable ,length1, "is", answer, length2)
      else:
          print("Invalid error units and variables")

  elif length1 == "dam":
      if length2 == "km":
          answer = Variable / 100
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "hm":
          answer = Variable / 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "m":
          answer = Variable * 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dm":
          answer = Variable * 100
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "cm":
          answer = Variable * 1000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "mm":
          answer = Variable * 10000
          print(Variable ,length1, "is", answer, length2)
      else:
          print("Invalid error units and variables")

  elif length1 == "m":
      if length2 == "km":
          answer = Variable / 1000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "hm":
          answer = Variable / 100
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dam":
          answer = Variable * 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dm":
          answer = Variable * 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "cm":
          answer = Variable * 100
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "mm":
          answer = Variable * 1000
          print(Variable ,length1, "is", answer, length2)
      else:
          print("Invalid error units and variables")

  elif length1 == "dm":
      if length2 == "km":
          answer = Variable / 10000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "hm":
          answer = Variable / 1000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dam":
          answer = Variable / 100
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "m":
          answer = Variable / 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "cm":
          answer = Variable * 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "mm":
          answer = Variable * 100
          print(Variable ,length1, "is", answer, length2)
      else:
          print("Invalid error units and variables")

  elif length1 == "cm":
      if length2 == "km":
          answer = Variable / 100000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "hm":
          answer = Variable / 10000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dam":
          answer = Variable / 1000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "m":
          answer = Variable / 100
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dm":
          answer = Variable / 10
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "mm":
          answer = Variable * 10
          print(Variable ,length1, "is", answer, length2)
      else:
          print("Invalid error units and variables")

  elif length1 == "mm":
      if length2 == "km":
          answer = Variable / 1000000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "hm":
          answer = Variable / 100000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dam":
          answer = Variable / 10000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "m":
          answer = Variable / 1000
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "dm":
          answer = Variable / 100
          print(Variable ,length1, "is", answer, length2)
      elif length2 == "cm":
          answer = Variable / 10
          print(Variable ,length1, "is", answer, length2)
      else:
          print("Invalid error units and variables")

      print("Invalid errors input units and variables")

  cont = str(input('Continue: '))
  if cont == 'no':
    break

Calculator For Quadratics Sequences
Caclculator for solving quadratics sequences, I used the shortcut way for this because if I use the range pattern thingy way it will take a lot time to write. The formula for this is 3a + b way, you guys can search it in internet. You can find the minimum point of the quadratics equations sequences too.
Quick info about abs:
abs is used for return absolute value of a number. But I make my own definition si kinda useful to make negative numbers to positive numbers and if we want to make from positive numbers to negative numbers you can use negative abs(-abs).

print('Calculator Quadratics Sequences')
cont = 'yes'
while cont.lower() == 'yes':

    d1 = int(input('The 1st differences of the first and second terms: '))
    d2 = int(input('The 2nd differences: '))
    n = int(input('The 1st number in 1st terms: '))

    a = d2 / 2
    print(f'The a variable is {a}')
    b = d1 + -abs(3*a)
    print(f'The b variable is {b}')
    result = (a + b)
    if result < 0:
        c = n + abs(a + b)
        print(f'The c variable is {c}')
    elif result > 0:
        c = n + -abs(a + b)
        print(f'The c variable is {c}')

    graph = str(input("Want minimum point: "))
    if graph == "yes":
        x = ((b / 2) * -1)
        y = c - b ** 2 / 4 * a
        print(f"The minimum point is ({x}, {y})")
    elif graph == "no":

        cont = str(input('Again: '))
        if cont == 'no':
            break

Like if you guys think these are a helpful projects, comment if you guys nk there is something that you guys want to tell me about this post.
Thank you.

Discover and read more posts from MS-092
get started
post comments2Replies
Zerq'sProgramz
5 years ago

👍

MS-092
5 years ago

All of those code above are not perfect yet. I will update it later.