Skip to main content

Posts

10 Programs using numbers for Python beginners

Numbers are at the core of learning any programming language. From basic arithmetic operations to complex computations, numbers are everywhere in programming. Having a strong foundation on numbers and arithmetic would come a long way in mastering any programming language. In this article, ten basic Python programs that involve numbers and arithmetic are explored.

Simple arithmetic expression evaluator in Python

Taking user input for two variables, an arithmetic operator and computing the results is very basic. This article projects a fresh look at extending the simple calculator by evaluating complex arithmetic expressions input by the user while also providing a mechanism to include the last computed value in a follow-up expression. All of these in only a few lines of code, by exploiting the Python's eval function.

Implementing Monotonic Stack in Python

A monotonic stack is an extension of the Stack data structure in which the elements of the stack are in either increasing or decreasing order. The stack in which the items are in increasing order is called the monotonically increasing stack, the top element of such a stack will be the largest of all the elements below. On the other hand, if the items are arranged in a decreasing order then the stack is called a monotonically decreasing stack, on which the top element will be the smallest of all the elements below. Monotonic stacks are very popular in competitive programming.

Tic-tac-toe game using Python and tkinter

Tic-tac-toe is a popular two player game where each player tries to occupy an empty slot in a 3x3 board until one of them wins or the entire board is filled without any winner. The winner has to occupy three continuous cells in any direction, including the two diagonals. In this article, a version of the tic-tac-toe game is coded using Python and tkinter library.

Double ended queue (deque) in C

A double-ended queue, pronounced deque in short is a LIFO queue where entries can be pushed and popped at both the ends of the queue, apart from push and pop an additional peek method is also discussed which fetches the value at either ends without removing it. In this article, one such queue is implemented using the C language.

Using hilite.me API in Python

hilite.me is a light weight website made by Alexander Kojevnikov , used to format source code from various programming languages into formatted HTML snippets which can be added to blogs, articles, and other web pages as needed. I personally use the API to format the source code snippets in this blog, and it has greatly reduced the time taken to complete an article, much thanks to the creator. In this article, an automated way of using the hilite.me API through Python and a simple HTML document is created with formatted code snippets.

BMI Calculator using Python and Tkinter

Body Mass Index can be calculated using a simple formula kg/m 2 , where the weight is represented in kilograms (kg) and the height is represented in metres (m). The article presents code to create a simple GUI to calculate BMI based on user input values. The GUI is implemented using tkinter and tkinter.ttk libraries in Python language.

Stack using linked list in C

 A stack data structure is used on cases where the last-in-first-out (LIFO) is needed. For example, Undo is implemented using stack, ie., the most recently made change is undone first. The article explains a sample implementation of the stack using linked list in C.

BMI calculator in Python

Body Mass Index can be calculated using a simple formula kg/m2, where the weight is represented in kilograms (kg) and the height is represented in metres (m). The article discusses the various ways to calculate BMI using python programming language.