import randomcomp_number = random.randint(1,10)guess = Falsecount = 0while guess == False: guess_number = int(input('What is your guess:')) if guess_number > comp_number: print('Too high') count += 1 elif guess_number < comp_number: print('Too low') count += 1 else: print(f'You are right',f'\nYou got it in {count} tries!') guess == True break function = input() print(eval(function))import randomuser = input('rock,paper,scissor:')choices = ['rock','paper','scissor']number = random.randint(0,2)computer = choices[number]if computer == 'rock' and user == 'paper': print('You win!, computer chose',computer) elif computer == 'paper' and user == 'scissor': print('You win!, computer chose',computer) elif computer == 'scissor' and user == 'rock': print('You win!, computer chose',computer) elif user == 'rock' and computer == 'paper': print('computer wins!, computer chose',computer) elif user == 'paper' and computer == 'scissor': print('computer wins!, computer chose',computer) elif user == 'scissor' and computer == 'rock': print('computer wins!, computer chose',computer) import randomcharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890{[(~`!@#$%^&*()_-+=|\:;)]}'length = int(input('Enter the length of your password:'))print('Your password would be:',''.join(random.sample(characters,length)))word = input('Enter your word:')if word.lower() == word.lower()[::-1]: print(f'{word}is a palindrome!')else: print(f'{word} is not a palindrome')n = int(input('Enter the length of the series:'))fib = [0,1]while len(fib) != n: fib.append(fib[-1]+fib[-2])print(fib[-1])Use pip install SpeechRecognition before running this code
import reimport speech_recognition as srimport webbrowserwhile True: r = sr.Recognizer() with sr.Microphone() as source: r.adjust_for_ambient_noise(source, duration=1) audio = r.listen(source) try: command = r.recognize_google(audio).lower() print('You said: ' + command + '\n') except sr.UnknownValueError: print('Your last command couldn\'t be heard') if command.startswith('open'): if 'google' in command: webbrowser.open('https://www.google.com') elif 'discord' in command: webbrowser.open('https://discord.com') elif 'youtube' in command: webbrowser.open('https://www.youtube.com') elif 'red it' in command: webbrowser.open('https://www.reddit.com') elif command.startswith('play'): command = command.split('play') webbrowser.open('https://www.youtube.com/results?search_query='+command[1]) elif command == 'quit': breakdef code(): s = input('Format: (hh:mm:ssAM/PM)') if s[-2:] == "AM" and s[:2] == "12": print ("00" + s[2:-2]) elif s[-2:] == "AM": print( s[:-2]) elif s[-2:] == "PM" and s[:2] == "12": print( s[:-2]) else: print( str(int(s[:2]) + 12) + s[2:8]) code()code()Use pip install pyttsx3 before using the code
import pyttsx3 speak = pyttsx3.init() speak.say('pyttsx3 speaks this')speak.runAndWait()number = int(input('Enter the number:'))number = list(str(number))cubes = [int(x) for x in number]cubes = [x**3 for x in cubes]if sum(cubes) == str(number): print('Your number is an armstrong number')else: print('Your number is not an armstrong number')sequence = input('Input sequences separated by commas:').split(',')sequence = [float(x) for x in sequence]if sequence[1] - sequence[0] == sequence[2]-sequence[1]: print('Sequence Type: Arithmetic') diff = sequence[1]-sequence[0] print(f'Common difference:{sequence[1]-sequence[0]}') print('Find the nth term') n = int(input("Input the value of 'n:'")) print(f'The nth term is {sequence[0]+(diff*(n-1))}')elif sequence[1]/sequence[0] == sequence[2]/sequence[1]: print('Sequence Type: Geometric') r = sequence[1]/sequence[0] print(f'Common ratio: {r}') print('Find the nth term') n = int(input("Input the value of 'n:'")) print(f'The nth term is {sequence[0]*(r**(n-1))}') else: print('Not a pattern')year = int(input('Enter the year:'))if (( year%400 == 0)or (( year%4 == 0 ) and ( year%100 != 0))): print('Your year is a leap year')else: print('Your year is not a leap year')text = []for _ in range(int(input('Enter number of emails'))): text.append(input())text = sorted(text, key=lambda x:x.split('@')[0])for mail in text: print(mail)