├── Project Python Development (phase-1) - Random Password.txt ├── Project Python Development (phase-1)- Calculator.txt ├── Project Python Development (phase-2)- Audio_Recording.txt ├── Project Python Development (phase-2)- typing_Speed_testing.txt └── README.md /Project Python Development (phase-1) - Random Password.txt: -------------------------------------------------------------------------------- 1 | import random 2 | import string 3 | 4 | def generate_random_password(length=12): 5 | allowed_characters = string.ascii_letters + string.digits + string.punctuation 6 | password = ''.join(random.choice(allowed_characters) for _ in range(length)) 7 | return password 8 | 9 | def main(): 10 | try: 11 | desired_length = int(input("Enter the desired password length: ")) 12 | if desired_length <= 0: 13 | print("Password length must be a positive number.") 14 | else: 15 | generated_password = generate_random_password(desired_length) 16 | print("Generated Password:", generated_password) 17 | except ValueError: 18 | print("Invalid input. Please enter a valid number for password length.") 19 | 20 | if __name__ == "__main__": 21 | main() 22 | -------------------------------------------------------------------------------- /Project Python Development (phase-1)- Calculator.txt: -------------------------------------------------------------------------------- 1 | def Addition(x, y): 2 | return x + y 3 | 4 | def Subtract(x, y): 5 | return x - y 6 | 7 | def Multiply(x, y): 8 | return x * y 9 | 10 | def Divide(x, y): 11 | if y != 0: 12 | return x / y 13 | else: 14 | return "Cannot divide by zero" 15 | 16 | def inches_to_CM(inches): 17 | return inches * 2.54 18 | 19 | def CM_to_inches(cm): 20 | return cm / 2.54 21 | 22 | def Calculate_BMI(weight_kg, height_cm): 23 | height_m = height_cm / 100 24 | bmi = weight_kg / (height_m ** 2) 25 | return bmi 26 | 27 | while True: 28 | print("Calculator Menu:") 29 | print("1. Addition") 30 | print("2. Subtract") 31 | print("3. Multiply") 32 | print("4. Divide") 33 | print("5. Inches to Centimeters") 34 | print("6. Centimeters to Inches") 35 | print("7. Calculate BMI") 36 | print("8. Exit") 37 | 38 | choice = input("Enter your choice: ") 39 | 40 | if choice == '8': 41 | print("Exiting the calculator.") 42 | break 43 | 44 | if choice in ['1', '2', '3', '4']: 45 | num1 = float(input("Enter first number: ")) 46 | num2 = float(input("Enter second number: ")) 47 | 48 | if choice == '1': 49 | print("Result:", Addition(num1, num2)) 50 | elif choice == '2': 51 | print("Result:", Subtract(num1, num2)) 52 | elif choice == '3': 53 | print("Result:", Multiply(num1, num2)) 54 | elif choice == '4': 55 | print("Result:", Divide(num1, num2)) 56 | elif choice == '5': 57 | inches = float(input("Enter inches: ")) 58 | print("Centimeters:", inches_to_CM(inches)) 59 | elif choice == '6': 60 | cm = float(input("Enter centimeters: ")) 61 | print("Inches:", CM_to_inches(cm)) 62 | elif choice == '7': 63 | weight = float(input("Enter weight in kg: ")) 64 | height = float(input("Enter height in cm: ")) 65 | print("BMI:", calculate_BMI(weight, height)) 66 | else: 67 | print("Invalid choice. Please select a valid option.") 68 | -------------------------------------------------------------------------------- /Project Python Development (phase-2)- Audio_Recording.txt: -------------------------------------------------------------------------------- 1 | import pyaudio 2 | import wave 3 | 4 | def record_audio(output_file, duration=5, sample_rate=44100, channels=2, chunk=1024): 5 | audio = pyaudio.PyAudio() 6 | 7 | stream = audio.open( 8 | format=pyaudio.paInt16, 9 | channels=channels, 10 | rate=sample_rate, 11 | input=True, 12 | frames_per_buffer=chunk 13 | ) 14 | 15 | print("Recording...") 16 | 17 | frames = [] 18 | 19 | for _ in range(0, int(sample_rate / chunk * duration)): 20 | data = stream.read(chunk) 21 | frames.append(data) 22 | 23 | print("Finished recording.") 24 | 25 | stream.stop_stream() 26 | stream.close() 27 | audio.terminate() 28 | 29 | with wave.open(output_file, 'wb') as wf: 30 | wf.setnchannels(channels) 31 | wf.setsampwidth(audio.get_sample_size(pyaudio.paInt16)) 32 | wf.setframerate(sample_rate) 33 | wf.writeframes(b''.join(frames)) 34 | 35 | if __name__ == "__main__": 36 | output_file = "recorded_audio.wav" 37 | duration = 5 # Set the duration of the recording (in seconds) 38 | record_audio(output_file, duration) 39 | print(f"Audio recorded and saved to {output_file}") 40 | -------------------------------------------------------------------------------- /Project Python Development (phase-2)- typing_Speed_testing.txt: -------------------------------------------------------------------------------- 1 | import random 2 | import time 3 | 4 | def generate_random_sentence(): 5 | sentences = [ 6 | "The quick brown fox jumps over the lazy dog.", 7 | "Programming is fun and rewarding.", 8 | "Python is a versatile programming language.", 9 | "Practice makes perfect.", 10 | "Coding is an essential skill for developers.", 11 | ] 12 | return random.choice(sentences) 13 | 14 | def typing_speed_test(): 15 | sentence = generate_random_sentence() 16 | print("Type the following sentence as quickly as possible:") 17 | print("\n" + sentence + "\n") 18 | 19 | input("Press Enter to start...") 20 | 21 | start_time = time.time() 22 | 23 | user_input = input("Type the sentence here: ") 24 | 25 | end_time = time.time() 26 | 27 | elapsed_time = end_time - start_time 28 | 29 | words = sentence.split() 30 | word_count = len(words) 31 | 32 | correct_words = 0 33 | 34 | for i in range(min(len(words), len(user_input.split()))): 35 | if words[i] == user_input.split()[i]: 36 | correct_words += 1 37 | 38 | wpm = (correct_words / elapsed_time) * 60 39 | 40 | print("\nYou typed at {:.2f} words per minute.".format(wpm)) 41 | print("You got {} out of {} words correct.".format(correct_words, word_count)) 42 | 43 | if __name__ == "__main__": 44 | typing_speed_test() 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CVIP-Python-Development 2 | Python Development 3 | --------------------------------------------------------------------------------