Posts

Number Guessing Game Using Python 3

Number Guessing Game Using Python 3: import random num_rounds = 5 max_guesses = 10 score = 0 print ( "Welcome to the Number Guessing Game!" ) print ( "You will play" , num_rounds, "rounds. Each round, you have to guess a number between 1 and 100." ) print ( "You will score points based on the number of attempts taken to guess the number." ) print ( "Let's get started! \n " ) for i in range (num_rounds):     secret_number = random.randint( 1 , 100 )     num_guesses = 0     print ( "Round" , i+ 1 , "starts now!" )     # print("Your Guessing Number is:",secret_number)     while num_guesses < max_guesses:         guess = int ( input ( "Guess a number between 1 and 100: " ))         num_guesses += 1         if guess == secret_number:             print ( "Congratulations! You guessed the secret number in" , num_guesses, "guesses!" )    ...

Write A Python Program To Find Max Between Three Numbers.

 Write A Python Program To Find Max Between Three Numbers Enter By The User. Code: num1 = int ( input ( "Enter The First Number:" )) num2 = int ( input ( "Enter The Second Number:" )) num3 = int ( input ( "Enter The Third Number:" )) if num1 > num2 and num1 > num3 :     print ( f " { num1 } is Greatest Number" ) elif num2 > num1 and num2 > num3 :     print ( f " { num2 } is Greatest Number" ) else :     print ( f " { num3 } is Greatest Number" ) Output: Enter The First Number:47 Enter The Second Number:50 Enter The Third Number:48 50 is Greatest Number Download Code

Make A Calculator Using If else Statement in Python

 Make A Calculator Using If else Statement in Python Code - num1 = int ( input ( "Enter The First Number: " )) operator = input ( "Choose Operater +,-,*,/,%:" ) num2 = int ( input ( "Enter The Second Number: " )) if operator == "+" :     print ( "Output = " ,num1 + num2) elif operator == "-" :     print ( "Output = " ,num1 - num2) elif operator == "*" :     print ( "Output = " ,num1 * num2) elif operator == "/" :     print ( "Output = " ,num1 / num2) elif operator == "%" :     print ( "Output = " ,num1 % num2) else :     print ( "Invalid Input!" ) Output -  Enter The First Number: 47 Choose Operater +,-,*,/,%:+ Enter The Second Number: 3 Output =  50 Download Code

Write Multiplication Table Using While Loop In Python

 Write Multiplication Table Using While Loop In Python Code: Num = int ( input ( "Enter The Number :" )) i = 0 while i < 10 :     i = i + 1     print ( f " { Num } X { i } = { Num * i } " )     # or     # print(Num,"X",i,"=",Num*i)     # or     # print(str(Num) + "X" + str(i) + "=" + str(Num*i)) Output: Enter The Number:8 8X1=8 8X2=16 8X3=24 8X4=32 8X5=40 8X6=48 8X7=56 8X8=64 8X9=72 8X10=80 Download Code

Write Multiplication Table Using For Loop In Python

Write  Multiplication Table Using For Loop In Python Code: Num = int ( input ( "Enter The Number :" )) for i in range ( 1 , 11 ) :     print ( f " { Num } X { i } = { Num * i } " )     # or     # print(Num,"X",i,"=",Num*i)     # or     # print(str(Num) + "X" + str(i) + "=" + str(Num*i)) Output: Enter The Number:4 4X1=4 4X2=8 4X3=12 4X4=16 4X5=20 4X6=24 4X7=28 4X8=32 4X9=36 4X10=40 Download Code

Write a program to find out whether a given post is talking about "harry" or not using Python?

write a program to find out whether a given post is talking about harry or not? Code: post = input ( "Enter a post: " ) if 'harry' in post . lower ():     print ( "Yes! the post contains the name Harry." ) else :     print ( "No! the post does not contain the name Harry" ) Output: Enter a post: harry Yes! the post contains the name Harry. Enter a post: HARRY Yes! the post contains the name Harry. Enter a post: Harry Yes! the post contains the name Harry. Download Code

Write a Python Program To Calculate The Grade Of A Student

 Write a Python Program To Calculate the Grade Of a Student From His marks From The Following Scheme: 90-100 →Ex 80-90 → A 70-80 → B 60-70 → C 50-60 →D    <50 →F Code : marks = int ( input ( "Enter Your Marks \n " )) if marks >= 90 :     grade = "Ex" elif marks >= 80 :     grade = "A" elif marks >= 70 :     grade = "B" elif marks >= 60 :     grade = "C" elif marks >= 50 :     grade = "D" else :     grade = "F" print ( "Your grade is " + grade ) Output : Enter Your Marks 99 Your grade is Ex Enter Your Marks 50 Your grade is D Enter Your Marks 40 Your grade is F Download Code