Skip to main content

A Program To Guessing A Number.

n=18
number_of_guesses=1
print("Number of guesses is limited to only 9 times: ")
while (number_of_guesses<=9):
    guess_number = int(input("Guess the number :\n"))
    if guess_number<18:
        print("you enter less number please input greater number.\n")
    elif guess_number>18:
        print("you enter greater number please input smaller number.\n ")
    else:
        print("you won\n")
        print(number_of_guesses,"no.of guesses he took to finish.")
        break
    print(9-number_of_guesses,"no. of guesses left")
    number_of_guesses = number_of_guesses + 1
if(number_of_guesses>9):
    print("Game Over")


Comments

Post a Comment

Popular posts from this blog

Write a C Program to Demonstrate the Working of Keyword long.

 #include<stdio.h> //24. Write a C Program to Demonstrate the Working of Keyword long. void main() {     int a;     long b;     long long c;     double e;     long double f;     printf(" The size of int = %ld bytes \n", sizeof(a));     printf(" The size of long = %ld bytes\n", sizeof(b));     printf(" The size of long long = %ld bytes\n", sizeof(c));     printf(" The size of double = %ld bytes\n", sizeof(e));     printf(" The size of long double = %ld bytes\n\n", sizeof(f)); }

Health Management System

# Health Management System print ( "This is a Health Management System" ) def getdate():     import datetime     return datetime.datetime.now() def take(k):     if k == 1:         c = int ( input ( "Type 1 for Food /n Type 2 for Exercise /n" ))         if c == 1:             d = int ( input ( "Enter 1 for Divyansh /n Enter 2 for Rohit /n Enter 3 for Sohan" ))             if d == 1:                 value = input ( "Type here /n" )                 with open ( "Dpsc-food.txt" ) as op:                     op.write( str ([ str (getdate())]) + ":" + value + "/n" )                 print ( "Sucessfully Written" )             if d == 2:                 value = input ( "Type here /n" )                 with open ( "Rohit-food.txt" ) as op:                     op.write( str ([ str (getdate())]) + ":" + value + "/n" )                 print (