Posts

Showing posts from February, 2024

This is KBC game.

                                       Welcome to KBC Game This is MCQ type game and only use python, so let's start the KBC ( Kaun Banega Crorepati) . price1= "1000 (1 Thousand)." price2= "10000 (10 thousand)." price3= "100000 (1 Lakh)." price4= "1000000 (10 lakh)." price5= '10000000 (1 Crore).' print ( "Hii, \n Welcome to KBC. \n " ) print ( "Let start KBC. \n " ) print ( "Now, This is your 1 Question?" ) print ( "What is the capital of India?" ) print ( '''(a). Delhi (b). Goa (c). Mumbai (d). Bangalore''' ) answer1= str ( input ( "Enter the option: " )) if answer1.lower() == 'a' : print ( " 🤑🤑🤑 Ok, Your answer is right and you won" ,price1) print ( " \n\n Who was the first Prime Minister of India?" ) print ( '''(a). Narendra Modi (b). Nehru (c). Dr. Manmohan Singh (d). Dr. APJ Abdul Kalam'...

This is removing a Folder.

                           This Code Removing a 10 Folder.                     This Code removing a 10 folder. Those folders create a back code. # Remove the 10 folders on the desktop import os import shutil # Specify the path to your desktop desktop_path = r'C:\Users\hp\OneDrive\Desktop' # you can change your path for i in range ( 1 , 10 ): folder_name = f"Folder_ { i } " folder_path = os.path.join(desktop_path, folder_name) shutil.rmtree(folder_path)

This is creating a Folder.

                                  This Code Creating a 10 Folder.      This Code creating a 10 folder. You can change the folder path or creating folders. # This is create a folder import os # Specify the path to your desktop desktop_path = r'C:\Users\hp\OneDrive\Desktop' # Create 10 folders on the desktop for i in range ( 1 , 10 ): folder_name = f"Folder_ { i } " folder_path = os.path.join(desktop_path, folder_name) os.makedirs(folder_path)

Binary to Words convertor.

                     Welcome Binary to Words convertor                                      This is Binary to Words convertor. print ( "Welcome to the Binary Convert to words! \n " ) while True : print ( "1. If you are intrested" ) print ( "2. Exit" ) choice = input ( "Enter your choice (1/2): " ) if choice == '1' : # Convert binary to words binary_value = str ( input ( " \n Enter your binary number: " )) byte_value = int (binary_value, 2 ).to_bytes(( len (binary_value) + 7 ) // 8 , byteorder = 'big' ) words = byte_value.decode( "utf-8" ) print ( " \n 😇 Your Words are = " , words, " \n " ) print ( "You are again try this." ) elif choice == '2' : print ( "Koi Baat Nahi 😞 " ) break else : print ( "Invalid choice! Please enter 1, 2 ."...

Words to Binary convertor.

                         Welcome Words to Binary convertor                                            This is all words convert to Binary. while True : print ( "Welcome to the Binary Converter!" ) print ( "1. If you are intrested" ) print ( "2. Exit" ) choice = input ( "Enter your choice (1/2): " ) if choice == '1' : # Convert a paragraph to binary print ( "Enter your words:" ) paragraph = "" while True : line = input () if line: paragraph += line + " \n " else : break byte_value = paragraph.encode( "utf-8" ) binary_value = bin ( int .from_bytes(byte_value, byteorder = "big" ))[ 2 :] print ( " 😇 Your Binary value is = " , binary_value, " \n " ) elif choice == '2...

Binary to Number converter.

# Prompt the user to enter a binary number print ( "You start a binary convert-to-number. \n " ) while True : print ( " \n\n 1. If you are interested then type '1'" ) print ( "2. If you are not interested then type '2'" ) choice = input ( "Enter choice (1/2): " ) if choice == '2' : print ( " \n Koi Baat Nahi 😞 " ) break if choice == "1" : print ( " \n ok you are come in binary convertor" ) binary_number = input ( " \n Enter a binary number: " ) # Convert the binary number to an integer using the int() function number = int (binary_number, 2 ) # Print the decimal number print ( "1 Your number is = " , number) print ( " \n\n 😇😇😇 Your task complete" )

Number to Binary converter.

                             Welcome number to binary convert.     But condition is if you type any number space  and decimal   does not include. def convert_to_binary (num): """Converts a only int number to its binary equivalent. Returns: The binary representation of the number as a string. """ binary = "" while num > 0 : remainder = num % 2 binary = str (remainder) + binary num //= 2 return binary # Convert any number to binary i= int ( input ( "Enter the value = " )) #It change in decimail so change the 'int' to 'float' binary_value = convert_to_binary(i) print ( i, f"in binary: { binary_value } " )

Calculator Code

                                This is calculator code by using python.                       Your choice while loop use or not.   while True : print ( " \n Calculator Menu:" ) print ( "1. Addition" ) print ( "2. Subtraction" ) print ( "3. Multiplication" ) print ( "4. Division" ) print ( "5. Exit" ) choice = input ( "Enter choice (1/2/3/4/5): " ) if choice not in [ '1' , '2' , '3' , '4' , '5' ]: print ( "Invalid choice! Exiting the calculator. Goodbye!" ) break if choice == '5' : print ( "Exiting the calculator. Goodbye!" ) break num1 = float ( input ( "Enter first number: " )) num2 = float ( input ( "Enter second number: " )) if choice == '1' : print ( "Result:" , num1 + num2) elif choice == '2' : print ...