├── Audio_recording.py ├── Project Python Development (phase-1) - Calculator.txt ├── Project Python Development (phase-1) - Random Password.txt └── Typing.py /Audio_recording.py: -------------------------------------------------------------------------------- 1 | import pyaudio 2 | import wave 3 | def record_audio(filename, duration=5, sample_rate=44100, channels=1, chunk_size=1024): 4 | audio = pyaudio.PyAudio() 5 | # Configure the audio stream 6 | stream = audio.open(format=pyaudio.paInt16, 7 | channels=channels, 8 | rate=sample_rate, 9 | input=True, 10 | frames_per_buffer=chunk_size) 11 | print("Recording...") 12 | frames = [] 13 | for _ in range(0, int(sample_rate / chunk_size * duration)): 14 | data = stream.read(chunk_size) 15 | frames.append(data) 16 | print("Finished recording.") 17 | # Stop and close the audio stream 18 | stream.stop_stream() 19 | stream.close() 20 | audio.terminate() 21 | # Save the recorded audio to a WAV file 22 | with wave.open(filename, 'wb') as wf: 23 | wf.setnchannels(channels) 24 | wf.setsampwidth(audio.get_sample_size(pyaudio.paInt16)) 25 | wf.setframerate(sample_rate) 26 | wf.writeframes(b''.join(frames)) 27 | if __name__ == "__main__": 28 | output_filename = "recorded_audio.wav" 29 | record_duration = 10 # You can change this to the desired recording duration in seconds 30 | record_audio(output_filename, duration=record_duration) -------------------------------------------------------------------------------- /Project Python Development (phase-1) - Calculator.txt: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def add(x, y): 4 | return x + y 5 | 6 | def subtract(x, y): 7 | return x - y 8 | 9 | def multiply(x, y): 10 | return x * y 11 | 12 | def divide(x, y): 13 | if y != 0: 14 | return x / y 15 | else: 16 | return "Cannot divide by zero" 17 | 18 | def exponentiate(x, y): 19 | return x ** y 20 | 21 | def square_root(x): 22 | return math.sqrt(x) 23 | 24 | def modulo(x, y): 25 | if y != 0: 26 | return x % y 27 | else: 28 | return "Cannot perform modulo with zero" 29 | 30 | while True: 31 | print("Select operation:") 32 | print("1. Add") 33 | print("2. Subtract") 34 | print("3. Multiply") 35 | print("4. Divide") 36 | print("5. Exponentiate") 37 | print("6. Square Root") 38 | print("7. Modulo") 39 | print("8. Exit") 40 | 41 | choice = input("Enter choice (1/2/3/4/5/6/7/8): ") 42 | 43 | if choice == '8': 44 | print("Calculator exiting...") 45 | break 46 | 47 | if choice in ('1', '2', '3', '4', '5', '7'): 48 | num1 = float(input("Enter first number: ")) 49 | num2 = float(input("Enter second number: ")) 50 | elif choice == '6': 51 | num1 = float(input("Enter a number: ")) 52 | 53 | if choice == '1': 54 | print("Result:", add(num1, num2)) 55 | elif choice == '2': 56 | print("Result:", subtract(num1, num2)) 57 | elif choice == '3': 58 | print("Result:", multiply(num1, num2)) 59 | elif choice == '4': 60 | print("Result:", divide(num1, num2)) 61 | elif choice == '5': 62 | print("Result:", exponentiate(num1, num2)) 63 | elif choice == '6': 64 | print("Result:", square_root(num1)) 65 | elif choice == '7': 66 | print("Result:", modulo(num1, num2)) 67 | else: 68 | print("Invalid input") -------------------------------------------------------------------------------- /Project Python Development (phase-1) - Random Password.txt: -------------------------------------------------------------------------------- 1 | import random 2 | import string 3 | 4 | def generate_random_password(length=12): 5 | characters = string.ascii_letters + string.digits + string.punctuation 6 | password = ''.join(random.choice(characters) for _ in range(length)) 7 | return password 8 | 9 | random_password = generate_random_password() 10 | print("Random Password:", random_password) -------------------------------------------------------------------------------- /Typing.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | def typing_speed_test(text): 4 | print("Type the following text:") 5 | print(text) 6 | input("Press Enter when you're ready to start...") 7 | 8 | start_time = time.time() 9 | user_input = input("Start typing: ") 10 | end_time = time.time() 11 | 12 | elapsed_time = end_time - start_time 13 | words_per_minute = len(user_input.split()) / (elapsed_time / 60) 14 | 15 | print("\nYou typed at a speed of {:.2f} words per minute.".format(words_per_minute)) 16 | 17 | if __name__ == "__main__": 18 | sample_text = "This is a sample text for typing speed test. Try to type it as quickly and accurately as possible." 19 | typing_speed_test(sample_text) 20 | 21 | --------------------------------------------------------------------------------