Posts

10.Secret Encoding & Decoding.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 =...

9. Astrologer's Star.py

# Pattern Printing # input = Integer n # Boolean = True or False # True n=4 # * # ** # *** # **** # n = no.of rows # False n = 4 # **** # *** # ** # * # print the stars according to the date of birth of the client Raahu = input ( "Enter 'YES' if Raahu present else enter 'NO': " ).lower() # str(Raahu) # Raahu = False if Raahu == "yes" : # Take date input from the user date_of_birth = input ( "Enter the Date Of Birth (DD-MM-YYYY): " ) # Extracting the date from the DOB dob = date_of_birth.split( '-' ) # Custom exception class for invalid date format class InvalidDateFormatError( Exception ): def __init__ ( self , message= "Invalid date format. Please use DD-MM-YYYY." ): self .message = message super (). __init__ ( self .message) # Raise an error if date is not in 3 part format i.e DD-MM-YYYY # if len(dob) != 3: # print("Enter a valid (DD-MM-YYYY) ...

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!" )