Archive

Archive for September, 2021

Python: Coffee Consumption P9

September 30, 2021 1 comment

Learning : Python, SQlite3, Dataset, Pandas,
Subject: Create Coffee Consumption Application.

[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.]

[ IF THE IS FIRST TIME DOWNLOADING THE CODE FILE, SELECT OPTION 7 FROM MAIN-MENU TO CREATE THE DATABASE]


In this part (Part-9) of Coffee Consumption App, we will write a Function to Edit a Record in the Main Table of the Coffee Consumption System. Because we are using Lookup tables for some of the data [Coffee Name, Type and Size] editing code may be longer that we will use the SQL Select commands several time to retrieve the data from those Tables. So first we will look to the steps we need to do (will do) in the Function:

1. Calling the show_records(inside = ‘yes’) function to display all the records on the screen.

2. In while True loop we will ask the user to Select the Record ID that want to Edit. We will do a Validation if the user select a valid ID using check_availabilty(‘coffee_con’,’c_id’, int(edit_rec_id)) != None)

3. Using SQL Command, We will Select the main record for Coffee_con Table, then again we will use the SQL to do the following:
— > SQL Command to get the Coffee Name for coffee_name Table using foreign key in coffee name cell.
— > SQL Command to get the Coffee Type for coffee_type Table using foreign key coffee type cell.
— > SQL Command to get the Coffee Size for coffee_size Table using foreign key coffee size cell.
Then we will display the Record and ask the use to confirm that this is the record to be edit.
4. After the user confirmation of Editing the Record, we will run three blocks of while True loop code for Coffee Name, Coffee Type and Coffee Size in each one we will display the data in the lookup Table, ask the user to Select ID from the List, if the user press on enter without writing any number then we will keep the current data, also we will do a validation on user input. Also will ask the user for Gender and Rank.
5. Now we have all the New Edited Date, we will display it on the screen asking the user [again] to confirm the “Saving The Changed” by Pressing the [S] (any thing else will be as “NO Don’t Save”).

Coding Now let’s see some parts of the code we use, the Source File of extention .py is available in the Download Page.


Here the user Selecting the ID of the Record to be Edit.

python project code coffee consumption ali radwani



The while True loop to edit the coffee Type.

python project code coffee consumption ali radwani



Last code part is to display the new edited record on the screen and the SQL command to UPDATE the DataBase.

python project code coffee consumption ali radwani



What’s Coming: In Part-10 we will write the Function to backup the data as Excel file.


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


Part 1 Part 2 Part 3 Part 4 Part 5
Part 6 Part 7 Part 8 Part 9 Part –


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



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

By: Ali Radwani

Nikon S9900 Shot # 15

September 28, 2021 Leave a comment


Subject: A Photo from Souq-Waqif with Nikon S9900

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: I was walking in Souq-Waqif one the most famous ‘Bazaar’ in Qatar
I fond this beautifull side wall of a restaurant, and I take the shot using my Nikon S9900, camera In-Hand almost at ground level.

…Click Image to Enlarge…
Doha Qata photo photography Nikon s9900 ali radwani ahradwani.com
Camera in Hand, F:4 , ISO:125 , Shutter:1/640s
Focal-Point:6mm



::.. 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


::.. Other Photos From Qatar Click-Here



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

By: Ali Radwani

Python: Coffee Consumption P8

September 26, 2021 2 comments

Learning : Python, SQlite3, Dataset, Pandas,
Subject: Create Coffee Consumption Application.

[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.]

[ IF THE IS FIRST TIME DOWNLOADING THE CODE FILE, SELECT OPTION 7 FROM MAIN-MENU TO CREATE THE DATABASE]


In this part (Part-8) of Coffee Consumption App, we will write a Function to Delete a Record from the Main Table of the Coffee Consumption System.

Deleting a record is an easy SQL command having the Table Name and the Record ID that we want to Delete. In our Function First we wil display all the Records on the screen and asking the user to Select the ID of the Record, then we will display that record (again) on the screen and ask to Confirm the action by Entering [Y].
If the user Enter [Y] the Record will be Deleted, any thing else it wil be as No and the user will returned to the Main-Menu.

Coding: We will start the Function by displaying the header, then we will call the Function that will display all the Records in the data-base.. Here is the code..
show_records(inside = ‘yes’)
and asking the user to Select the ID.
NEXT: We will check the Availability of the ID, so if the user Enter an ID that not in the Data-Base or Empty space or just press Enter we will ask to re-enter the ID again. … Here is the code ..
while True:

del_rec_id = input (‘\n\n Select the Record ID to be Deleted > ‘)

if del_rec_id in [‘e’,’E’]:

input(‘ You Select [E to Exit].. Press any Key. > ‘)

return

elif (del_rec_id ==” “) or (del_rec_id ==””) or (check_availabilty(‘coffee_con’,’c_id’, int(del_rec_id)) != None):

break

If the ID is available, then we will display the Record and will ask the user to Confirm the Delete Command. This is the code for all the Delete Function ..


What’s Coming: In Part-9 we will Writing the Function to Edit a Coffee Record.


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


Part 1 Part 2 Part 3 Part 4 Part 5
Part 6 Part 7 Part 8 Part – Part –


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



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

By: Ali Radwani

Drafting New System

September 22, 2021 Leave a comment

Start to write down some notes and ideas for a new system/application using a self-brainstorming session.

I am always using the MindJet Maps app to draw the basic outlines of the application I want to work on.

Here is the first Draft of a Payroll System that I want to do in coming weeks. Not sure if I will use Python or MS-Excel to do this project.

Old Drawer: Nikon S9900 # 11

September 21, 2021 Leave a comment

Title: Nikon S9900 # 11

Subject: Drawer Side with Nikon S9900

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: In one of my indoor photo-session i take this shot of an old drawer in my living room, using Black and White option, lights coming from the window & Camera in hand

…Click Image to Enlarge…
Nikon s9900 coolpix camera Ali radwani ahradwani.com photo Photography
Camera in Hand, F:4 , ISO:400 , Shutter:1/10s
Focal-Point:6mm



::.. 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

Python: Tower of Hanoi

September 15, 2021 Leave a comment

Learning : Python
Subject: Write a Function to Solve Tower of Hanoi Problem

Intoduction: Tower Of Hanoi is Puzzle Game that has three Vertical Sticks/Pegs Named A, B, C (3 Towers) and we have n number of disks different in diameter soted on top of each other (Large to Small) in Tower A. The Gall is to move all the disks from (A) to (C).

 # Tower of Hanoi Puzzel

"""
    Project Name: Tower of Hanoi
    
    By: Ali Radwani
    Date: 13.6.2021
    
     d  : Number of Desk
     fs : From Stick
     ts : To Stick
     bs : Buffer Stick
"""


import os

def hanoi_t(d, fs, bs, ts): 
    if d ==1 : 
        print("\n   Move Desk 1 From {} To {}".format(fs,ts)) 
        return

    else: 
        hanoi_t(d-1,fs,ts,bs) 
        print("   Move Desk {} From {} To {}".format(d,fs,ts)) 
        
        hanoi_t(d-1,bs,fs,ts) 
        print("   Move Desk {} From {} To {}".format(d,fs,ts))
        
os.system('clear')        
print('\n\n   This is Tower Of Hanoi Project')
print('   We are Solving a Three Desk Tower Named 1, 2 and 3, with Three Sticks Named A, B and C ')
print('\n   Start Solving ...')
hanoi_t(3,'A','B','C')

python project code Tower of Hanoi ali radwani



..:: 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

Stairs: Nikon S9900 # 12

September 12, 2021 2 comments


Subject: In Parking Ramp with Nikon S9900

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:I take this shot while I was Driving my car through parking ramp, camera in hand and window down. Black & White.

…Click Image to Enlarge…
photo photography ali radwani nikon nikkor S9900
Camera in Hand, F:4 , ISO:125 , Shutter:1/640s
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

Python: Coffee Consumption – P7

September 8, 2021 3 comments

Learning : Python, SQlite3, Dataset, Pandas,
Subject: Create Coffee Consumption Application.

[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.]

[ IF THE IS FIRST TIME DOWNLOADING THE CODE FILE, SELECT OPTION 7 FROM MAIN-MENU TO CREATE THE DATABASE]


In this part (Part-7) of Coffee Consumption App, we will write a Function to display all Records in the data-base in a table on the screen.

Beginning with formating the table header, we will have the following columns: record Id, Date_time, Coffee_name, Coffee_type, coffee_size, customer_Gender and Rank. Here is the code..

print(‘ ‘*6,’ID’,’ ‘*5,’ Date & Time’,’ ‘*3,’ Coffee Name’,’ ‘*4,’Type’,’ ‘*9,’Size’,’ ‘*4,’ Gender’,’ ‘*4,’ Rank’)
print(‘ ‘*4,’-‘*90)

Next we will execute an SQLITE command to fetch all the records. Here is the commands..
c.execute (f”select * from coffee_con where c_id > 1 “)
dataset = c.fetchall()

Also we will using the lookup tables to get the names using the id keys in the coffee_name, coffee_type, coffee_size columns.

Now, Using the for loop to access all the records and print them on the screen. Here is apart of the code ..


print(‘ ‘*6,'{}’.format(data_id),end=””)
print(‘ ‘*(10 – 5),'{}’.format(data_date),end=””)
print(‘ ‘*(21 – 16),'{}’.format(data_name[0]),end=””)
print(‘ ‘*(14 – len(data_name[0])),'{}’.format(data_type[0]),end=””)
print(‘ ‘*(13 – len(data_type[0])),'{}’.format(data_size[0]),end=””)
print(‘ ‘*(13 – len(data_size[0])),'{}’.format(data_sex),end=””)
print(‘ ‘*(12 – 1),'{}’.format(data_rank))

Here is a screen shot of the code..

python project code coffee consumption ali radwani
OutPut Screen
python project code coffee consumption ali radwani



What’s Coming: In Part-8 we will write the Function to Edit the records on the Main Data-Base.


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


Part 1 Part 2 Part 3 Part 4 Part 5
Part 6 Part 7 Part – Part – Part –


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



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

By: Ali Radwani

Python: Coffee Consumption – P6

September 5, 2021 4 comments

Learning : Python, SQlite3, Dataset, Pandas,
Subject: Create Coffee Consumption Application.

[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.]

[ IF THE IS FIRST TIME DOWNLOADING THE CODE FILE, SELECT OPTION 7 FROM MAIN-MENU TO CREATE THE DATABASE]


In this part (Part-6) of Coffee Consumption App, we will write First Function of the Main Application to ADD New Record. In this Function we will do the following:

  • Get the Current Date and Time.
  • The user will Select the Coffee Name, Type and Size from the list in lookup tables.
  • Selecting the Gender of the user.
  • Entring the Rank for the order [If the customer rank it].

Beginning with adding New Record in the Coffee Consumption System. We will use the datatime.now() function get the current data and time here is the code..

now = datetime.now()
date_t = now.strftime(“%d/%m/%Y %H:%M”)
Then we will show each of the lookup table we have and the user will select the ID of the Coffee Name,Type and Size, the, we will use a simple Validation process to control the user inut. Here is the code for Entering the Coffee Name


   # Select a Coffee Name 
    print('\n     List of Coffee Names:\n')
    show_list('coffee_name','cn_id')
     # check the availability of the input 
    while True:
        cn_id = input('\n     Enter the ID of a Coffee Name. [E to Exit]. > ')
        if cn_id in ['e','E']:
            input('     You Select [E to Exit].. Press any Key. > ')    
            return
            
        elif (cn_id ==" ") or (cn_id =="") or (check_availabilty('coffee_name','cn_id', int(cn_id)) != None):
            break

The same code will be apply for the Coffee Type and Coffee Size.
[NOTE] All the codes will be in the file to be Download.

Next part of the code will be to select the customer Gender [M,F] here also we will use a simple Validation that will accept M or F Not anything else. Here is the code..


# Select Customer Gender [Only M,F]
    while True:
        sex = input('\n     Enter the Gender of the customer. [M / F] [E to Exit]. > ')
        
        if sex in ['e','E']:
            input('     You Select [E to Exit].. Press any Key. > ')    
            return
        elif sex in ['m','M','f','F']:
            break
        else: 
            print('     You Must input [M,F]')

Last variable we will collect will be the Rank, the Customer will ask the user to Rank this Order, the range will be from 1 to 10, 0 will be for Not Available.. Here is the code…


# Enter the user Rank
    print('     If the User can Rank the Coffee.. 1 to 10 [1 is Bad, 10 is Great]')
    while True :
        rank = input('\n     Enter User Rank.[1 is Bad, 10 is Great] [0 is NOT Available] [E to Exit]. > ')
        if int(rank) in range (0,11):
            break
        else:
            print('\n     Rank Should be in Range of 0-10.'

After that we will display all the Entries on the screen and ask the customer to press [S] to save the Record, and then we will use IINSERT SQL command to Insert the record. Here is the code for all the function….



What’s Coming: In Part-7 we will do the Follwing:

Writing three Function to Show / Display the Records in the main Table of the Coffee Consumption Application.


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


Part 1 Part 2 Part 3 Part 4 Part 5
Part 6 Part – Part – Part – Part –


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



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

By: Ali Radwani

Blue Light: Nikon S9900 shot – 9

September 2, 2021 1 comment


Subject: Milk Mug with Nikon S9900

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: In a one of photo sessions i take several photos of a Milk Mug, I place the Mug on the ground and let the sun light come through a window in the room, I set up the camera to take a Black & White [Read this Post], the Nikon S9900 provide controlling over the colors [color filttering]; so here is another shot allowing to the Blue color only to reflect from the object.

…Click Image to Enlarge…
Nikon s9900 coolpix camera Ali radwani ahradwani.com photo Photography
Camera in Hand, F:4 , ISO:140 , Shutter:1/30s
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