Archive

Posts Tagged ‘ahradwani’

Nikon S9900 Shot 13

October 13, 2021 Leave a comment


Subject: Nikon S9900 in Souq-Waqif Journey

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 most beautifully ‘Old Bazaar’ in Qatar called “Souq-Waqif” you may find lot’s of Vestibules, here is one that will take you to a Mosque, I take the shot using Nikon S9900.

…Click Image to Enlarge…
photo photography ali radwani doha qatar Souq-Waqif old bazaar Nikon Coolpix S9900
Camera in Hand, F:3.7, ISO:125, Shutter:1/400s, 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: Generate your Data-Set

August 8, 2021 1 comment

Learning : Python, pandas, function
Subject: Generate your CSV dataset using python

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

The Story:
last week i was reading about Data Cleaning, Deep Learning and Machine Learning, and for all we need some data to play with and testing our code. There are several sites providing a free (to certain limits) Data-set. But while i was working, it just come to my mind Why not to write a code to generate some Fake data-set.

Before I start:
The main question was “What is the subject of the data” or Data about What? This is the main question that will guide us to write our code, and tha answer was very..very fast 🙂 .. at that moment I was holding my Coffee Mug, and just jump to my mind, Data about Coffee … Coffee Consumption. So we are taking the data of Coffee Consumption from a Coffee-Shop, the coffee-shop is collecting the following data: Date-Time (of the order), Coffee-Name, Coffee-Type, Coffee-size, Sex, Rank. Here is in more details..

Dat-Time: Date and Time of Order, Date format: dd-mm-yyyy, the Time format: hh:mm (24h)

Coffee-Name: Such as: [black, latte, espresso, americano, cappuccino, mocha, lungo, flat white, irish, macchiato,ristretto, iced coffee]

Coffee-Type: 3n1 , pods, grounded

Coffee Size: samll, medium, large, venti  

Sex: The person how order it male, female 

Rank: if the customer drink the coffee in the shop, will ask for a ranks (1,10) 1:bad, 10:Grate

Scope of Work: We will write several functions to generate random data for each attribute we have, saving the data into a list, then combining all the lists in a pandas dataframe df and save the data_set df to a csv file. Later on we can re-call the file using pandas command df.read_csv(file_name) and manipulate the data.

.::.. Coding ..::.
Let’s start with Date-Time Function: def fake_date_time(from_y,to_y): In this function we will use a random.randint() to generate numbers for day’s, months and years, also for hours and minites. The function will take two arguments from_y, to_y and will return a string like this: dd-mm-yyyy hh:mm … here is the code ..

ali radwani python code project


Now,Coffee Name: def fake_coffee_name() : for Coffee Name I create a list of Coffee Names (from the net) and use random.choice(coffee_name_list) to select one from the list. this function is a one-line code .. here it is ..

 # fake_coffee_name() function

def fake_coffee_name() : 
    """
        Function to randomly select one from the list. 
        
        Return coffee_name 
        
     """ 
    
    coffee_name_list = ['black', 'latte', 'espresso', 'americano', 'cappuccino', 
                         'mocha', 'lungo', 'flat white', 'irish', 'macchiato', 'ristretto', 
                         'iced coffee'
                         ] 
    return random.choice(coffee_name_list) 



Here are another two Functions def fake_coffee_type(): and def fake_coffee_size(): Both are using the random.choice to select from a list.. here is the code ..

]ali radwani python code project



More over, in out dataset we need another two variables sex and rank, both are simple and we don’t need to put them in separate function, we will call the random.choice(‘f’,’m’) to select between Male and Female, and random.randint (1,11) to select a Rank between (1 and 10). Here is the main part of the application, we will use a for loop and append all the returns from the function’s in a list (a list for each attribute) after that we will combine all the list in a dataset using pandas command. Here is the code..

 # Main body of the application

# empty lists of the columns
d_d =[] 
cn_d =[] 
ct_d =[] 
cs_d =[] 
s_d =[] 
r_d = [] 

number_of_rows = 1000 

for x in range(1,number_of_rows): 
    d_d.append(fake_date_time(2000,2022)) 
    cn_d.append(fake_coffee_name()) 
    ct_d.append(fake_coffee_type()) 
    cs_d.append(fake_coffee_size()) 
    s_d.append(random.choice(['f','m'])) 
    r_d.append(random.randint (1,11)) 
    

the_data ={'date_time':d_d, 'c_name':cn_d, 'c_type':ct_d, 'c_size':cs_d, 'sex':s_d, 'rank':r_d } 

df = pd.DataFrame (the_data) 

# to create a CSV file and save the data in it. 
file_name = 'coffee_consumption_v1.csv'
df.to_csv(file_name, index=False)

print(f'\n\n    The data been generated, a file named: {file_name} saved')



Now we have a file called: coffee_consumption_v1.csv saved in the same directory of the .py code file. Here is a sample of the data.

ali radwani python code dataset



We will stop here, and we will do another post to apply pandas commands over the dataset.

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


To Download my Python code (.py) files Click-Here
Also the Date-Set coffee_consumption_v1 file (.csv) files is available in the same page.



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

By: Ali Radwani

Nikon S9900 shots – 5

July 25, 2021 1 comment


Subject: Nikon S9900 Milk and Coffee

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 place my Milk Mug in the sun-light coming from a window, the camera on graound level and i took the shot using BW-color from the camera.

…Click Image to Enlarge…
Nikon s9900 coolpix camera Ali radwani ahradwani.com photo Photography

Camera in Hand, F:4 , ISO:160 , Shutter: 1/30s



::.. 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 Sorting Algorithm – Heap Sorting -P5


Learning : Python, Math, Algorithm
Subject: Sorting Algorithm, Heap Sort P5

[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 Last Parts (2, 3 and 4) we wort the Following Functions:

  • Sections Header.
  • Main Menu Function.
  • Entering/Creating the Array.
  • Print-Out or to Display the Array.
  • Check If Array in Max-Heap.
  • Convert Array to Max-Heap.
  • Add Node to Max-Heap.
  • Delete a Node from a Max-Heap.

In this last part-5 we will write the last main Function to aplay the Heap Sorting Algorithm.

Scope of Work: Deleting a Node from a Max-Heap Array is the main function in sorting an Array using Max-Heap Algorithm, the Deleting is always from the Root Node, So if we delete the most top Node [Root] (and store it in index[0] in a temp_array) then we move the Last Node to it’s position and by doing that we miss the Max-Heap state of the Array, so we convert the array to a Max-heap, then we Delete the Root again until we delete all the elements in the Array.. Here the Algorithm:

Assuming we have a Max-Heap Array:
1. Delete the Root Element, and Store it in index[0] in Temp_array.
2. Move the Last Element in the Array to index[0].
3. If the Array not in Max-Heap then Convert it to a Max-Heap.
4. Repeat Steps 1 to 3 Until length of Array is 0.

In our list of Functions up, we have the three Functions we Need to complete/apply a Max-Heap Sorting:
We Delete a Node using def delete_node(arr,inside):
then in a while loop we call both
def check_if_max_heap (arr,inside): and
def convert_to_max_heap (arr,inside): so let’s see the code..

ali radwani ahradwani.com python project code heap sorting algorithm


We finish Max-Heap Sorting Algorithm, ..

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

Python: Kadane’s Algorithm


Learning : Python, Algorithm, Math
Subject: Implement the Kadane’s Algorithm

Definition: Kadane’s Algorithm is to search in a one Dimensional Array [integer positive and negative numbers] for a we will largest Sum of contiguous subarray.

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

Algorithm To find the largest subset sum, we apply coming step:
We will use two variables:
current_max: to hold the max sum of thesub-set
start_again: will be as a flag to re-set the current_max

Algorithm:
1. Start from Element in the array index = 1, save it as start_again. Set Current_max to Array Element in index = 0.

2. Do sumation of start_again with the next element index + 1.

3. If current_max < start_again then re-set current_manx = start_again

4. If start_again < 0 then re-set start_again = 0

5. Repeat from 2 to 4 until the end of the array.

6. If we reach end of the Array, then return the current_max

More from Kadane’s Algorithm:
The aim of Kadane’s Algorithm is to return the Maximum sum of sub-set. But in our code here we will return the following:
1. Maximum sum of largest subset
2. The start Index and the End Index of the subset.
3. printing out the subset.

We will have three options in our application, as following:
1. Kadane’s Algorithm – Fast Run.
2. Kadane’s Algorithm – Step By Step.
9. Exit.

As we are doing in our Algorithms coding, we will use a Main-Menu, and a Function to help the user to enter the Array.

Coding
We will start with def create_array(): and will return the Array that the user will enter. here is the code..

Ali radwani python project code Kadane Algorithm



Now, here is the code for the Main-Menu and the Main application body. In Main application body code, we will use the while True : loop and calling the main_menu() function then with if statement we will check on the user_selection

The Main-Menu
Ali radwani python project code Kadane Algorithm
Here is the Main Application body code..

Ali radwani python project code Kadane Algorithm



Last, we will write the Function to get the Kadane’s Sum in a Fast-Run, the details one will be a copy with mode print-out statement to show the steps .. [All code is in Download Page.]
As we mentioned, Our Kadane’s function will return three things, the Grates Sum of a sub-set, and to position of that sub-set as start index and end index. Here is the code ..

Ali radwani python project code Kadane Algorithm
Here is a Run-Time screen ..

Ali radwani python project code Kadane Algorithm



We done with another Algorithm, looking forwards to solve new one in coming days.

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

Python Project: Disarium Numbers in Range


Learning : python code
Subject: Finding the Disarium number
in a range

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

Definition We call a Number as A Disarium Number if the Sum of it’s Ddigits Powered with their Respective Position is Equal to the Original Number.
So 89 is a Disarium Number, because 8^1 + 9^2 = 8 + 81 = (89 the original number)
and 135 is also a Disarium Number, because 1^1 = 1, 3^2 = 9, 5^3 = 125 and the Total is [1+3+125 = 135 the original number]
we have a previous post to check if a given number is a Disarium Number or not … Read The Post Here .. In this post we will write the Function to print-out all the Disarium Numbers in a given range.

So our application will ask the user to enter two Numbers as a range From and To, then the disarium_n_range(num1,num2) taking two argument will work through a For loop to check each number in the range and if it is a Disarium Number we will store it in a list (disarium_n =[]) .. Let’s start by the asking the user to Input the range numbers..

 # Code to collect the Numbers from the User

print('\n\n   This Project will Print-Out all the Disarium Numbers in a given range.')
num1 = input('\n   Enter the From Number. > ')
num2 = input('\n   Enter the To Number.   > ')




And now let’s see the main Function of the application ..

python project code doha qatar ali radwani


Run-Screen for the range From 10 To 99

python project code doha qatar ali radwani


Another Run for the Range From 100 To 999

python project code doha qatar ali radwani



End of the post ..

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



Follow me on Twitter..

By: Ali Radwani

Sketch of a Swan

April 25, 2021 2 comments

Using a pencil then black pen and a photo from the Net as a reference, here is a sketch of a Swan in a Lake.

Follow me on Twitter @h_ta3kees

ali radwani draw sketch pen pencil swan lake

Flowers in my lens… 9

April 22, 2021 Leave a comment

Some time the Fake is there as well as the real…. Here are some small FAKE pink flowers in a bouquet of flowers. I use a galaxy Note 9 phone to take this photo.

Click here and follow me on Twitter @h_ta3kees

ali radwani doha qatar pink flowers photo galaxy note9

Coffee and Boat

April 20, 2021 Leave a comment

Some time you need a coffee, and some time you need a strong one .. here is a small shot of Turkish Coffee in a small beautiful cup from Holland . Photo taken by galaxy Note 9 .

Click and follow me on Twitter @h_ta3kees

ali radwani Turkish coffee and boat camera galaxy note9

Another sketch challenge: Lion’s Face

April 11, 2021 Leave a comment

This week sketch challenge @1hour1sketch is to Draw a Lino Face, so here is my sketch using pencil, black Pen.

I tried to do my best to draw the hair/mane am sure I can’t do better than this, I need more practice in doing fur drawing.

More Sketches on my Sketch page ..

also follow me on Twitter @h_ta3kees

ali radwani sketchbook sketch lion face pencil black pen