Blog Posts tagged with 'python'

ASP.NET Core Web API on macOS Using Visual Studio Code

In this article I create an ASP.NET Core Web API Application and Python web client on macOS that allows me to list, add, and remove daily reminders. I also show how to register services with the ASP.NET Core Dependency Injection Framework. I use Visual Studio Code to build the Web API Application and PyCharm to build the Python web client.

Read More

Merge Sort in Python Using Pythonista 3 on iPad Pro

I am learning divide and conquer algorithms and wrote Merge Sort in Python using Pythonista 3 on my iPad Pro. I included Doctests this time and plan to do so in the future. The Doctests provided a sanity check when I changed my algorithm based on an optimization I found elsewhere.

Read More

Python Web Client Retrieving Factorial Calculations from ASP.NET Core Website

As promised, I wrote a Python client using the Requests http library to use the factorial service I built with ASP.NET Core Routing, RouteBuilder.MapGet, and a custom RequestDelegate. I just made a small tweak to the RequestDelegate to support a custom http header for returning just the factorial instead of a formatted string.

Read More

Binary Search Example in Python

Binary search is a very efficient algorithm for finding an item in a sorted list. I wrote a Python program that uses binary search to find random numbers in a list of 10,000 and 100,000 items. Using asymptotic notation, binary search is O(log n), which means it has a really slow rate of growth as the number of items to search grows large.

Read More

Fibonacci Numbers - Tale of Two Algorithms using Python

A mind blowing experiment looking at two different algorithms in Python for calculating Fibonacci numbers. One is the well-known recursive function, and the other is an alternative algorithm using a list. I profiled these functions in Pycharm, and am amazed at the results!

Read More

Python Algorithms - Revisiting Recursive Functions and Palindromes

My algorithms course has me re-thinking that recursive function used to detect palindromes. Although the assignment required writing a recursive function, is a recursive function really the best algorithm? Possibly, but there is at least one other good solution.

Read More

Python Sets and the Hangman Game

I built another helper function for the Hangman Game. This function also leverages the set data structure in Python. I really love the use of sets in this instance as well as the instance before. Python sets bring out the essence of the function's purpose and promotes declarative programming.

Read More

Python Recursive Function to Detect Palindromes

I wrote a recursive function in Python to determine if a string was a palindrome. While doing so I also wrote one of my first Python List Comprehensions to strip non-alphanumeric characters from the string before testing to see if it was a palindrome.

Read More

Programming the Hangman Game in Python

I am creating a helper function in Python for the game Hangman. I need to determine if the secret word has been guessed from a list of guesses. I mention imperative vs. declarative programming, recursion, and sets and subsets in Python.

Read More

Find Two Largest Integers in List Using Python

The second problem of my introductory computer science class on Coursera asks me to find the two largest integers in a list. Although the class uses C, I am currently learning Python and chose to solve this problem using the Python programming language. I show a few solutions using the max function, sorting, set, and heapq in Python.

Read More

Python Program to Calculate Square Roots using Babylonian Method

A guess and check Python program that calculates the square root of a number using the Babylonian Method.

Read More