📜  如何在python代码示例中制作操作系统

📅  最后修改于: 2022-03-11 14:45:37.198000             🧑  作者: Mango

代码示例1
import time
import images
import random
import datetime
from datetime import date
# ! i = 1 doesn't work for some reason!
i = 1
# * This is an operating system with a few apps!
# TODO Make more apps
today = date.today()

print("\n")
day = today.strftime("%B %d, %Y")
print("d2 =", day)
print(images.password)
password = input()


# ! Wrong password
if password != "3219":
    print(images.wrongpassword)
    ta = input()


    if ta == 'yes':
        second = input("enter your password ")
        if second != '3219':
            print("You locked the phone wait 20 seconds")
            while i <= 20:
                time.sleep(1)
                print(i)
                i = i + 1
            trird = input("Type your password ")
            if trird != "3219":
                print("Your phone is locked you dont have an other try!")
            else:
                print("Ok plese enter it the first time!")
        else:
                print("Right password plese enter it at the start")


#?Password right
if password == '3219':
    print(images.home)
    main = input()


    # * The proggram app
    if main == 'program':
        print(images.proggram)
        print('type here')
        print('type here')
        print('type here')

    
    # * The calculator app
    if main == 'calculator':
        print(images.calculator)
        num = input("Your number ")
        num2 = input("Your second number ")
        num3 = input("Your third number ")
        num4 = input('do you want "+ - * multiply or / for devide" ')
        if num4 == '+':
            print('the result of', num, '+', num2, '+', num3, 'is', int(num) + int(num2) + int(num3))
        if num4 == '-':
            print('The result is', int(num) - int(num2) - int(num3))
        if num4 == '*':
            print("the result is", int(num) * int(num2) * int(num3))
        if num4 == '/':
            print('the result is', int(num) / int(num2) / int(num3))
        else:
            print('Invalaid input')
    if main == 'games':
    #*The games folder!
        time.sleep(1)
        print('do you want to play (rock, paper scissors/maths/fast typing)')
        game = input()
  
        if game == 'rock, paper, scissors':
            while True:
# ! noise
                print('what do you want rock, paper or scissors\nif you want to leave press o')
                rps = input()
                ROPESC = ['rock', 'paper', 'scissors']
                RPS = random.choice(ROPESC)
                print('the bot chose', RPS)
                if rps == 'o': 
                    break
                    print('You left')
            

        if game == 'maths':
            Maths2 = ['45', '+3', '76', '8.09', '53', '21']
            Maths = ['4', '79', '89', '57', '8', '7.8', '-2', '69']
            Symbols = ['+', '-', '*', '/']

            symbols = random.choice(Symbols)
            maths = random.choice(Maths)
            print('Starting in ')
            time.sleep(1)
            print(3)
            time.sleep(1)
            print(2)
            time.sleep(1)
            print(1)
            time.sleep(1)
            print('GO!')
            maths2 = random.choice(Maths2)
            start_time = time.time()
            print('Your porblem is', maths, symbols, maths2, '=')
            maths = input()
            fin_time = time.time() - start_time
            print('It took you', fin_time, 'to figure it out')
        if game == 'fast typing':
            fastyping = ['cat', 'man', 'woman', 'python', 'VScode', 'easy', 'last']
            time.sleep(1)
            print(3)
            time.sleep(1)
            print(2)
            time.sleep(1)
            print(1)
            time.sleep(1)
            print("GO!")
            fast = random.choice(fastyping)
            ft = random.choice(fastyping)
            fasttyping = random.choice(fastyping)
            start_time = time.time()
            
            time.sleep(3)
            ft = input(fasttyping)
            time.sleep(1)
            ft2 = input(fast)
            time.sleep(0.4)
            ft3 = input(ft)
            if ft != fasttyping or ft2 != fast or ft3 != ft:
                print("You're wrong!")
            else:
                fin_time = time.time() - start_time
                print("You're right! It took you", fin_time, "to reach")