Archive

Posts Tagged ‘radwani’

Python: Grade_2 Math Questions V1

October 31, 2022 Leave a comment

Learning : Python, Math
Subject: Math Questions for Grade-2 V.1

[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]

In the process of studing with/for my kids [specialy Math] i always need to give them some Questions in [+ -], I need to write the Questions on a paper then they solve it and i check the answers. So I thought if I create an app to solve this Problem.
Application to Do What?

  • Select Two random numbers from a given range.
  • Select a Math operator [+ -].
  • Writing the Question on the Screen.
  • Comparing the user input with the real answer.
  • Writing a message on the screen acoording to the user answers.


Application Menu

  • Start Play the Game. [All Math Lessons]
  • Re-set the Numbers Range.
  • Register New Kid to Play.
  • Questions Like: x (+ -) y = ??
  • Questions Like: x (+ -) ?? = y
  • Questions Like:
    x
    y (+ -)
    _______________
    ??

  • Exit.
  • In this Version (V.1) of the application, there will be some limitations on the Questions Difficulties, Number ranges and type of Questions.


    Start Coding
    The Menu
    As we can see above, we will have 7 keys for the Menu, Menu 9 is for Exit. Menu 3 will ask the user to Enter the Kid Name. Menu 2 will ask for the Number Ranges (From/To as 0 to 9 so all the questions will be in this rage). Menu 4, 5 and 6 each will be for type of questions. Menu 1 will ask the user about All the questions type. In all menus 1,4,5 and 6 if the user did’t enter a Name or a number ranges, the application will as for it before srating.
    Here is the code for the Main Menu.

     # Code for Main Menu
    
     # ---------------- Main Menu -------------------------
    def menu () :
        os.system('clear')
        print('\n\n\t This is a Math Revision Game.',version)
        print('\t --------------------------------------------')
        print(' '*34,'By:[AHRADWANI.COM]')
    
        print('\n\n\t')
        print('\t 1. Start Play the Game. [All Math Lessons]')
        print('\t 2. Re-set the Numbers Range.')
        print('\t 3. Register New Kid to Play.')
        print('\t \n ')
        print('\t 5. Questions Like:   x (+ -) y = ?? \n')
        print('\t 6. Questions Like:   x (+ -) ?? = y \n')
        print('\t 7. Questions Like:      x','\n\t\t\t\t y   (+ -)','\n\t\t\t     ___________')
        
        print('\t ')
        print('\t 9. Exit.')
        
        user_select = input ('\n\n\t Select from the Menu. > ') 
        
        return user_select
    
    


    Get the Numbers Range
    In this Function the user will be asked to Enter the Number range as from and to, we will check if the user Enter a valid input, No space, No Alphabetics.

     #  Get the Numbers Range
    
     def get_numbers_range () :
        
         """
            Function to get the Number range from the user, we will check if the user Enter
            a valid input, No space, No Alphabetics.
            
            return:
                nfrom: is the lower number range.
                nto  : is the upper number range.    
        """
        
        
        nfrom = check_user_input("\t Enter the Lower Range Number > ","\t ... You Need to Enter a Lower Range Number.") #(input('\n\t Enter the Lower Range > '))
        nto = check_user_input("\t Enter the Upper Range Number > ","\t ... You Need to Enter an Upper Range Number.")
            
        if (int(nfrom)) > (int(nto)) :
            nfrom, nto =  nto, nfrom     
        
        return int(nfrom), int(nto)
           
    


    Check user input
    With each user input we will call this Function with two messages, statement message will be the one to gaid the user to What is need to Enter, error message will be display if the user input something wrong or not expected. Then the Function will return back the user input.

     # check_user_input
    
    def check_user_input(statment_m,error_m):
         """
        Function to check on the user input if it is a valid or not.
        
        Arguments:
            statmen_m: will be the one to gaid the user to What is need to Enter
            error_m: will be display if the user input something wrong or not expected. 
        
        Return:
            uinput
        
        """    
        while True :        
            print(statment_m,end="")
            uinput = input()
            if ((uinput) in [" ",""] or (not uinput.isnumeric()) or ((uinput) in schar) or ((str(uinput).isalpha()))):
                print(error_m)  
            else:
                break        
        return uinput
    
    
    


    Get the Kid Name
    A small and short Function to return the user/Kid Name.

     # Get the Kid Name
    
     def get_kid_name () :
    
        return input('\n\t Enter Your Name > ')
    
    


    Setting and Variabls
    This is the first upper part of the application, we just import the random and os also we set some variables.

     # Variables
    
     
    import random, os, operator 
    
    score1 = 0
    good = ['Correct','You are Right', 'Well Done..','Nice..','Excellent..','Amazing..','Good job',' YES .. Keep it up .. ','So Proud of You','Yes .. Another Point for You',]
    bad = ['Wrong ..','Sorry .. No!','Try Your Best','No!','No..Think Harder','ooops .. No','Not this Time']
    oper_dict = { '+': operator.add, '-': operator.sub,} # '*': operator.mul, }
    schar = "@_!#$%^&*()?/\|}{~,.:'"
    
    nfrom = 0
    nto = 0
    name = 0
    version = 'V.10.2022.R1'
    


    Math Question Type-1
    This Function will ask the user 10 Questions of Math according to the Numbers Range were the question will looks like: X [+ -] Y = ??, then if the answer is right good message will display on the screen.

     #  Math Question Type-1 (X [+ -] Y = ??)
    
     def Math_G2_type_1():
       os.system('clear')
       score =0
       for q in range(0,10):
          n1 = random.randint(nfrom,nto)
          n2 = random.randint(nfrom,nto) 
          op = random.choice(list(oper_dict.keys()))
          
          if op == '-' :
              if n1 ')
          print('   ', n1, op ,n2,end='')
          
          ans = check_user_input(" = ","  You Need to Enter an Answer .. ")
          
          if  int(ans) == oper_dict[op](n1,n2):  
              print('   ',random.choice(good),'   .. ')
              score = score +1
          else:
              print('   ',random.choice(bad),'   .. ')
            
       return score 
     
    



    Math Question Type-2
    This Function will ask the user 10 Questions of Math according to the Numbers Range were the question will looks like: X [+ -] ?? = Y, then if the answer is right good message will display on the screen.

     # Math Question Type-1 (X [+ -] ?? = Y)
    
     
    def Math_G2_type_2():
        os.system('clear')
        print('\n\n\t ', name ,' Now try to solve these once\n ')
        score =0
        for q in range(0,10):
            n1 = random.randint(nfrom,nto)
            n2 = random.randint(nfrom,nto) 
            op = random.choice(list(oper_dict.keys()))
            if op == '-' :
              if n1 < n2 :
                  n1,n2 = n2,n1
         
            print('\t\t   ',n1)
            print('\t\t   ',n2,' ',op)
            print('\t\t __________') 
            ans = int(input('\t\t    '))
            
            if ans in [" ",""]:
              print('   ',random.choice(bad),'  You Need to Enter an Answer .. ')          
            else:      
                if ans == oper_dict[op](n1,n2): 
                    print('   ',random.choice(good),'   .. \n\n')
                    score = score +1
                else:
                    print('   ',random.choice(bad),'   .. \n\n')
    
        return score
    
    


    Math Question Type-3
    This Function will ask the user 10 Questions of Math according to the Numbers Range were the question will looks like:

    X
    Y [+ -]
    __________
    ???
    then if the answer is right good message will display on the screen.

     # 
    
     def Math_G2_type_3 ():
        os.system('clear')
        print('\n\n\t ', name ," let's try this.")
        print('\t Complete with correct number.\n')
        score = 0
        for q in range(0,10):
            n1 = random.randint(nfrom,nto)
            n2 = random.randint(nfrom,nto)
            op = random.choice(list(oper_dict.keys()))
            if op == '-' :
                if n1  n2 :
                    n1,n2 = n2, n1
        
            print('\t ',n1,op, ' ______ = ', n2)
            ans = int(input('  Your Answer > ') )
            
            if ans in [" ",""]:
              print('   ',random.choice(bad),'  You Need to Enter an Answer .. ')
            else:
                if n2 == oper_dict[op](ans,n1): 
                    print('   ',random.choice(good),'   .. \n\n')
                    score = score +1
                else:
                    print('   ',random.choice(bad),'   .. \n\n')
        return score
    
    


    Application Body
    In the Application Body itself I use a while loop to call and detect the User input from the menu and using that input to call the corresponding Function. All the codes and functions also the application Body code is on the Source file and can be Downloaded.

    I test the code and RUN the app several times, but errors can be found, so next version of this Application will solve any errors also will add more Math Questions Type.

    ..:: Have Fun with Coding ::.. 🙂

    To Download my Python code (.py) files Click-Here



    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani

    Daily Sketch: Colored Seal

    October 27, 2022 Leave a comment

    I Just finish this Water-color Sketch of a Seal, I almost have 20 water_colored sketches on a 4x3in cards since I start this session [Drawing on a 4×3 Card] on September 2022, the sketch it self is about 3x2in. Here I am posting todays Seal sketch.

    ali radwani art draw paint sketches watercolor seal


    More of my Other Sketches Here..




    ..:: Have Fun with Sketching ::.. 🙂


    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani

    Fujifilm X-T30ii Post # 24

    September 18, 2022 Leave a comment


    Subject:FIFA WORLD CUP 2022 IN QATAR
    using Fujifilm X-T30ii.

    In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. Away from Nikon, I got my first FujiFilm X-T30ii camera.
    [:. Read more about my cameras and lenses Here .:]

    This Shot: This is a shot of Qatar West-Bay towers that has a FIFA WORLD CUP 2022 advertising campaign, I take the shoot using FujiFilm X-T30ii with ACROS film simulation.

    …Click Image to Enlarge…
    ali radwani ahradwani.com photo photography Fujifilm X-T30ii camera,
    Camera in Hand, F: 4, ISO: 400, Shutter:1/500s, Focal-Point:51mm
    Lens: XF 18-55mm F2.8-4.0 OIS lens.
    Film Simulation: ACROS



    ::.. To see all my FujiFilm X-T30ii Photos Click-Here
    ::.. To see all my Nikon S9900 Photos Click-Here
    ::.. To see all my Nikon D7100 Photos Click-Here
    ::.. To see all my Nikon D90 Photos Click-Here


    [ For Fujifilm Simulation Recipes Click Here ]



    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani

    Fujifilm X-T30ii Post # 21

    September 14, 2022 Leave a comment


    Subject: Classic Green Simulation in Fujifilm X-T30ii.

    In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. Away from Nikon, I got my first FujiFilm X-T30ii camera.
    [:. Read more about my cameras and lenses Here .:]

    This Shot: This is a shoot of a Mosque near my kids school, i take to shoot while waiting for them to finish. Also this is a test for my New ClassicGreen film recipe I create for indoor shooting it look great for outdoor also. I am
    using FujiFilm X-T30ii and XF 18-55mm F2.8-4.0 OIS lens.

    …Click Image to Enlarge…
    Fujifilm Camera X-T30ii Film Simulation Qatar Ali Radwani Photography
    Camera in Hand, F:9, ISO:200, Shutter:1/250s, Focal-Point:33mm
    Lens: XF 18-55mm F2.8-4.0 OIS lens.
    Film Simulation: ClassicGreen



    ::.. To see all my FujiFilm X-T30ii Photos Click-Here
    ::.. To see all my Nikon S9900 Photos Click-Here
    ::.. To see all my Nikon D7100 Photos Click-Here
    ::.. To see all my Nikon D90 Photos Click-Here


    [ For Fujifilm Simulation Recipes Click Here ]



    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani

    Fujifilm X-T30ii Post # 23

    September 11, 2022 Leave a comment


    Subject: FIFA WORLD CUP 2022 IN QATAR
    using Fujifilm X-T30ii.

    In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. Away from Nikon, I got my first FujiFilm X-T30ii camera.
    [:. Read more about my cameras and lenses Here .:]

    This Shot: This is a shot of Qatar West-Bay towers that has a FIFA WORLD CUP 2022 advertising campaign, I take the shoot using FujiFilm X-T30ii with ACROS film simulation..

    …Click Image to Enlarge…
    ali radwani ahradwani.com photo photography Fujifilm X-T30ii 
 camera
    Camera in Hand, F:4, ISO:400, Shutter:1/500s, Focal-Point:36mm
    Lens: XF 18-55mm F2.8-4.0 OIS lens.
    Film Simulation: Defult ACROS



    ::.. To see all my FujiFilm X-T30ii Photos Click-Here
    ::.. To see all my Nikon S9900 Photos Click-Here
    ::.. To see all my Nikon D7100 Photos Click-Here
    ::.. To see all my Nikon D90 Photos Click-Here


    [ For Fujifilm Simulation Recipes Click Here ]



    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani

    Fujifilm X-T30ii Post # 19

    September 7, 2022 Leave a comment


    Subject: Orry the Oryx with Fujifilm X-T30ii

    In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. Away from Nikon, I got my first FujiFilm X-T30ii camera.
    [:. Read more about my cameras and lenses Here .:]

    This Shot: Orry the Oryx is a 30 FEET TALL antelope-like animal statue holding a torch stand in the center of Doha, it was spread widely as advertisement for the Asian Games 2006 in QATAR. I use FujiFilm X-T30i with XF 18-55mm F2.8 lens and Kodak Portra 800 to take this shoot.

    …Click Image to Enlarge…
    Fujifilm Camera X-T30ii Film Simulation Qatar Ali Radwani Photography
    Camera in Hand, F:5, ISO:400, Shutter:1/4000s, Focal-Point:55mm
    Lens: XF 18-55mm F2.8-4.0 OIS lens.
    Film Simulation: Kodak Portra 800



    ::.. To see all my FujiFilm X-T30ii Photos Click-Here
    ::.. To see all my Nikon S9900 Photos Click-Here
    ::.. To see all my Nikon D7100 Photos Click-Here
    ::.. To see all my Nikon D90 Photos Click-Here


    [ For Fujifilm Simulation Recipes Click Here ]


    ——————————–

    ——————————-



    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani

    Fujifilm X-T30ii Post # 18

    August 31, 2022 Leave a comment


    Subject: Office Wall Decoration Fujifilm X-T30ii.

    In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. Away from Nikon, I got my first FujiFilm X-T30ii camera.
    [:. Read more about my cameras and lenses Here .:]

    This Shot: A shoot of a wall in my Home Office i am using FujiFilm X-T30ii with XF 18-55mm F2.8-4.0 OIS lens..

    …Click Image to Enlarge…
    Fujifilm Camera X-T30ii Film Simulation Qatar Ali Radwani Photography
    …Click Image to Enlarge…
    Fujifilm Camera X-T30ii Film Simulation Qatar Ali Radwani Photography
    Camera in Hand, F:6.4, ISO:4000, Shutter:1/100s, Focal-Point:28.
    Lens: XF 18-55mm F2.8-4.0 OIS lens.
    Film Simulation: BW_Street



    ::.. To see all my FujiFilm X-T30ii Photos Click-Here
    ::.. To see all my Nikon S9900 Photos Click-Here
    ::.. To see all my Nikon D7100 Photos Click-Here
    ::.. To see all my Nikon D90 Photos Click-Here


    [ For Fujifilm Simulation Recipes Click Here ]



    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani

    Fujifilm X-T30ii Post # 20

    August 28, 2022 Leave a comment


    Subject: KidZania Doha with Fujifilm X-T30ii.

    In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. Away from Nikon, I got my first FujiFilm X-T30ii camera.
    [:. Read more about my cameras and lenses Here .:]

    This Shot: Before Summer School Vacation we start searching for somewhere that fills the Kids time and to be as Fun and Intertanment also learning Hub in a 60-Days Vacation. I fond an account in Instagram for a Summer Camp called KidZania, they define them self as: An interactive city made for children 1-14Y that combines inspiration, fun and learning through realistic role-play. I contact also visit them, the place was amazing .. I register my girls there from 7:30AM to 2:00PM, after 2PM my girls stay there and don’t want to go back home.. we stay until 5:00PM (every day).

    I use FujiFilm X-T30ii to take this shoot.

    …Click Image to Enlarge…
    Fujifilm Camera X-T30ii Film Simulation Qatar Ali Radwani Photography
    Camera in Hand, F:5.6, ISO: 80, Shutter: 1/40s, Focal-Point: 18mm
    Lens: XF 18-55mm F2.8-4.0 OIS lens.
    Film Simulation: Out-Side 1



    ::.. To see all my FujiFilm X-T30ii Photos Click-Here
    ::.. To see all my Nikon S9900 Photos Click-Here
    ::.. To see all my Nikon D7100 Photos Click-Here
    ::.. To see all my Nikon D90 Photos Click-Here


    [ For Fujifilm Simulation Recipes Click Here ]



    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani

    Fujifilm X-T30ii Post # 15

    August 24, 2022 Leave a comment


    Subject: Aspire Tower with Fujifilm X-T30ii.

    In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. Away from Nikon, I got my first FujiFilm X-T30ii camera. [:. Read more about my cameras and lenses Here .:]

    This Shot: Aspire Tower, also known as The Torch Doha, located in the Aspire Zone complex in Doha, Qatar. Photo taken by FujiFilm X-T30ii.

    …Click Image to Enlarge…
    ali radwani ahradwani.com photo photography Fujifilm X-T30ii camera
    Camera in Hand, F:13, ISO:125, Shutter:1/180s, Focal-Point:55mm
    Lens: XF 18-55mm F2.8-4.0 OIS lens.
    Film Simulation: Classic_G



    ::.. To see all my FujiFilm X-T30ii Photos Click-Here
    ::.. To see all my Nikon S9900 Photos Click-Here
    ::.. To see all my Nikon D7100 Photos Click-Here
    ::.. To see all my Nikon D90 Photos Click-Here


    [ For Fujifilm Simulation Recipes Click Here ]



    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani

    Nikon S9900 – Shot 21

    August 17, 2022 Leave a comment


    Subject: Mosques in Qatar using Nikon S9900 lens

    In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. [:. Read more about my cameras and lenses Here .:]

    This Shot: Mosques in Qatar using Nikon. using Nikon S9900.

    …Click Image to Enlarge…
    photo nikon camera S9900 ali radwani qatar mosques
    Camera in Hand, F:4.5, ISO:125, Shutter: 1/2000s, Focal-Point:5mm



    ::.. To see all my Nikon S9900 Photos Click-Here
    ::.. To see all my Nikon D7100 Photos Click-Here
    ::.. To see all my Nikon D90 Photos Click-Here




    ali radwani ahradwani.com python projects codeFollow me on Twitter..

    By: Ali Radwani