├── README.md ├── Fibonacci Generator.py ├── random password generator.py ├── rock-paper-scissor.py └── basic calculator.py /README.md: -------------------------------------------------------------------------------- 1 | # python-projects 2 | -------------------------------------------------------------------------------- /Fibonacci Generator.py: -------------------------------------------------------------------------------- 1 | #fibonacci denerator 2 | 3 | def fibonacci(n): 4 | if n == 1 or n == 0: 5 | 6 | return n; 7 | 8 | else: 9 | 10 | return fibonacci(n-2) + fibonacci(n - 1) 11 | 12 | 13 | numero = int(input("ingrese un numero entero positivo: ")) 14 | 15 | if numero < 0: 16 | print("Numero no valido") 17 | 18 | i = 0 19 | 20 | print("Secesion de fibonacci: ") 21 | 22 | for i in range(0, numero): 23 | print(fibonacci(i)) 24 | -------------------------------------------------------------------------------- /random password generator.py: -------------------------------------------------------------------------------- 1 | import string 2 | import random 3 | 4 | characters = list(string.ascii_letters + string.digits + " !@#$%^&*()") 5 | 6 | def generate_password(): 7 | password_length = int(input("How long would you like your password to be? ")) 8 | 9 | random.shuffle(characters) 10 | 11 | password = [] 12 | 13 | for x in range(password_length): 14 | password.append(random.choice(characters)) 15 | 16 | random.shuffle(password) 17 | 18 | password = "" .join(password) 19 | print(password) 20 | 21 | option = input("Do you want to generate a password? (Yes/No): ") 22 | 23 | if option == "Yes": 24 | generate_password() 25 | elif option == "No": 26 | print("Program ended") 27 | quit() 28 | else: 29 | print("Invalid input, please input Yes or No") 30 | quit() 31 | -------------------------------------------------------------------------------- /rock-paper-scissor.py: -------------------------------------------------------------------------------- 1 | from random import randint 2 | moves=["rock","paper","scissors"] 3 | while True: 4 | computer=moves[randint(0,2)] 5 | player=input("rock, paper or scissors? (or end the game)").lower() 6 | if player=="end the game": 7 | print("The game is ended") 8 | break 9 | elif player==computer: 10 | print("Tie!!") 11 | elif player=="rock": 12 | if computer=="paper": 13 | print("You Lose!!",computer,"beats",player) 14 | else: 15 | print("you Win",player,"beats",computer) 16 | elif player=="paper": 17 | if computer=="scissors": 18 | print("You Lose!!",computer,"beats",player) 19 | else: 20 | print("You Win!!",player,"beasts",computer) 21 | elif player=="scissors": 22 | if computer=="rock": 23 | print("You lose",computer,"beasts",player) 24 | else: 25 | print("You Win!",player,"beast",computer) 26 | else: 27 | print("Check your spelling") 28 | 29 | -------------------------------------------------------------------------------- /basic calculator.py: -------------------------------------------------------------------------------- 1 | def add(a, b): 2 | answer = a + b 3 | print(str(a) + " + " + str( b) + " = " + str(answer) + "\n") 4 | def sub(a, b): 5 | answer = a - b 6 | print(str(a) + " - " + str(b ) + " = " + str(answer) + "\n") 7 | def mul(a, b): 8 | answer = a*b 9 | print(str(a) + " * " + str(b) + " = " + str(answer) + "\n") 10 | def div(a, b): 11 | answer = a / b 12 | print(str(a) + " / " + str(b) + " = " + str(answer) + "\n") 13 | 14 | while True: 15 | print("A. Addition") 16 | print("B. Subtraction") 17 | print("C. Multiplication") 18 | print("D. Division") 19 | print("E. Exit") 20 | choice = input("input your choice: ") 21 | 22 | if choice == "a" or choice == "A": 23 | print("Addition") 24 | a = int(input("input first number: ")) 25 | b = int(input("input second number: ")) 26 | add(a, b) 27 | elif choice == "b" or choice == "B": 28 | print("Subtraction") 29 | a = int(input("input first number:")) 30 | b = int(input("input second number: ")) 31 | sub(a, b) 32 | elif choice == "c" or choice == "C": 33 | print("Multiplication") 34 | a = int(input("input first number:")) 35 | b = int(input("input second number: ")) 36 | mul(a, b) 37 | elif choice == "d" or choice == "D": 38 | print("Division" ) 39 | a = int(input("input first number:")) 40 | b = int(input("input second number: ")) 41 | div(a, b) 42 | elif choice == "e" or choice == "E": 43 | print("program ended") 44 | quit() 45 | --------------------------------------------------------------------------------