Posts

Showing posts from February, 2024

8.SecretEncodingandDecoding.py

  # Write a program to translate a message into secret code language. # Use the rules below to translate normal English into secret code language. # Coding: # if the word contains atleast 3 characters: # remove the first letter and append it at the end now append three random characters at the starting and the end # now append three random characters at the starting and the end # else: # simply reverse the string # Decoding: #if the word contains less than 3 characters: # reserve it #else: # remove 3 random characters from start and end. Now remove the last letter append it to the beginning import random # Function to generate a random prefix def generate_prefix (): prefixes = [ 'asd' , 'jhg' , 'iuy' , 'ert' , 'bnm' ] return random.choice(prefixes) def generate_postfix (): postfixes = [ 'asd' , 'jhg' , 'iuy' , 'ert' , 'bnm' ] return random.choice(postfixes) choice...

7.KBC Quiz Game

  questions=[ [ "1.The International Literacy Day is observed on:" , "A.Sep 8" , "B.Nov 28" , "C.May 2" , "D.Sep 22" , "A" ], [ "2.The language of Lakshadweep, a Union Territory of India, is:" , "A.Tamil" , "B.Hindi" , "C.Malayalam" , "D.Telugu" , "C" ], [ "3.In which group of places the Kumbha Mela is held every twelve years?" , "A.Ujjain. Purl; Prayag. Haridwa" , "B.Prayag. Haridwar, Ujjain,. Nasik" , "C.Rameshwaram. Purl, Badrinath. Dwarika" , "D.Chittakoot, Ujjain, Prayag,'Haridwar" , "B" ], [ "4.Bahubali festival is related to:" , "A.Islam" , "B.Hinduism" , "C.Buddhism" , "D.Jainism" , "D" ], [ "5.Which day is observed as the World Standards Day?" , "A....

6.NumberMatchingGame.py

  n1 = 21 max_chances = 9 for i in range ( 1 , max_chances+ 1 ): n2 = int ( input ( "Enter your number:" )) chances_left = max_chances - i if n2 == n1: print ( "Congratulations! You found it" ) print ( "No.of chance taken:" ,max_chances-chances_left) break else : if chances_left == 0 : print ( "Game Over!" ) else : print ( "No. of Chances left:" , chances_left) # Add additional logic here if you want to do something after the loop

5.MinuteToHourConvertor.py

  n_time = int ( input ( "Enter the time in Minutes" )) Hour = n_time// 60 Min = n_time% 60 Sec = n_time* 3600 # std_time = str(HourMin:Sec) print (Hour, ":" ,Min, ":" ,Sec)

4.GoodMorningSir.py

import time # t=time.strftime('%H:%M:%S') Hour= int (time.strftime( '%H' )) print (Hour) if (Hour> 0 and Hour< 12 ): print ( "Good Morning Sir!" ) elif (Hour> 12 and Hour< 17 ): print ( "Good Afternoon Sir!" ) elif (Hour> 17 and Hour< 21 ): print ( "Good Evening Sir!" ) else : print ( "Good Night Sir!" )

3.FaulyCalculator.py

  #Q. Create a Calculator that will return all the results correctly except the following ones: # a)45678*90 # b) 205000/56 # c) 3456709876+0987654566 num1 = float ( input ( "Enter your 1st Operand: " )) num2 = float ( input ( "Enter your 2nd Operand: " )) # num3 = float(input("Enter your 3rd Operand: ")) sign = int ( input ( "Enter your Operator's Choice from the following: 1 for Addition, 2 for Multiplication, 3 for Division " )) # Use the match statement with case instead of match alone match sign: case 1 : if num1 == 3456709876 and num2 == 987654566 : print ( "36666666666" ) else : print (num1 + num2 ) case 2 : if num1 == 45678.0 and num2 == 90 : print ( "36666" ) else : print (num1 * num2) case 3 : if num1 == 205000.0 and num2 == 56 : print ( "366" ) else : print (num1 / num2) ...

2.DrivingLisence.py

  age_list = [ 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 ] #print(age_list) for i in range ( 22 , 101 ): age_list.append(i) #print(age_list) candidate_age = int ( input ( "Enter your age here : " )) if candidate_age< 18 : print ( "Not Eligible for Driving License" ) elif candidate_age== 18 : print ( "Apply after Drive Test is over" ) elif candidate_age not in age_list: print ( "Invalid Age" ) else : print ( "Eligible for License" )

1.DictionarySearch.py

 All my Python Exercises available are here : 1.DictionarySearch oxdict = { "Belie" : "To give a false representation to, or misrepresent" , "Arrant" : "Complete and wholly" , "Untoward" : "Inconvenient" , "Byzantine" : "Complex and intricate" , "Conciliate" : "To make peace with" , "Equivocate" : "To speak vaguely, with the intention of misleading someone" , "Abnegation" : "Renouncing a belief or doctrine" , "Aggrandize" : "Aggrandize" , "Alacrity" : "Eagerness" , "Anachronistic" : "Misplaced chronologically" , "Archetypal" : "Quintessential of a certain kind" } word = str ( input ( "Ask meaning of any word form the top 10 difficult words list:" )) if...