Posts

Showing posts from February, 2024

Card Game In Python

 import random dict = {'A':4,'KING':4,'QUEEN':4, 'J':4} ROWS = 3 COLS = 3 def sequence_game(alhp,rows,cols):     all_cards = []     for i, dict in alhp.items():         for _ in range(dict):             all_cards.append(i)     user_input = input("do you want to play ? ")     if user_input == 'y':         print(f"all_cards : {all_cards}")     random_choice = []          for col in range(cols):      value = random.choice(all_cards)      all_cards.remove(value)      random_choice.append(value)                        lets_distribute_all_cards = input(" ready to distribute ? ")     if lets_distribute_all_cards == 'y':                           print(random_c...

quiz program

  python_questions_answers = {     "What is the full form of API?" : "Application Programming Interface" ,     "When was Python created?" : "1989" ,     "Who is the creator of Python?" : "Guido van Rossum" ,     "What is the syntax used to create functions in Python?" : "def function_name():" ,     "What is the latest stable version of Python?" : "Python 3.10" ,     "What are the two main loop constructs in Python?" : "for loop and while loop" ,     "What is the purpose of the 'pass' statement in Python?" : "It is a null operation and does nothing. It is used as a placeholder." ,     "What is the difference between '==' and 'is' in Python?" : "'==' compares the values of two objects, while 'is' compares their identities (memory addresses)." ,     "What is a module in Python?" :...

calculator program

  A = int () B = int () def x ( a , b ):         while True :       a = 0       a =+ 1       for n in range ( a ):       a = int ( input ( "enter a number " ))       b = int ( input ( "enter 2nd number " ))       i = input ( f "what should you want to do (addition,substraction,division,parcent,multiplication )" )       c = int ( a + b )       if i == 'addition' :         print ( a + b )       if i == 'substraction' :         print ( a - b )       if i == 'division' :         print ( a / b )       if i == 'multiplication' :         print ( a * b )       if i == 'parcent' :         print ( a % b )   ( x ( A , B ))

ludo_guess_number program

  import random choices = [ 1 , 2 , 3 , 4 , 5 , 6 ] MAX_INPUT = 5 def ludo_container ( i , max_input ):   scores = []           for _ in range (max_input):      guess_number = int ( input ( "input your guess number " ))       if guess_number < 1 or guess_number > 6 :         print ( "guess_number is not valid" )         print ( "guess a number between 1-6" )              choice = random.choice(i)       if guess_number == choice:       scores.append(choice)       else :       print ( "you have no matching value, your score is equal to 0" )       print (scores)   total_score = sum (scores)   print ( f "your total score is { total_score } " )       (ludo_container(choices,MAX_INPUT))              ...