Skip to main content

Posts

Showing posts from December, 2017

5 Ways to Reverse String in Python

Hello everyone, in this tutorial we’ll see different ways to reverse string in Python. As we know, we can reverse a list using reverse() method but Python doesn’t have the reverse() method for string. Here are some alternate and easy ways to reverse a string. Ways to Reverse String in Python 1. Using Loop string1 = "the crazy programmer" string2 = "" i = len(string1)-1 while(i>=0): string2 = string2 + string1[i] i = i-1 print "original = " + string1 print "reverse = " + string2 Output: original = the crazy programmer reverse = remmargorp yzarc eht In above program, we’ve started a loop from the last index (length-1) to first index (0) of string1. In each step of loop, it will pick the character from right-side in string1 and concatenate with string2. 2. Using Recursion def reverse_it(string): if len(string)==0: return string else: return reverse_it(string[1:]) + string[0] print "added " + stri...

Python Merge Sort

Here you will learn about python merge sort algorithm. Merge sort is based on divide and conquer technique. All we have to do is divide our array into 2 parts or sub-arrays and those sub-arrays will be divided into other two equal parts. We will divide the array in this manner until we get single element in each part because single element is already sorted. After dividing the array into various sub-arrays having single element, now it is the time to conquer or merge them together but in sorted manner. Python Merge Sort Example Let’s see an example: We have an array  [ 99, 21, 19, 22, 28, 11, 14, 18 ]. There are 8 elements in the array. Break it into two equal parts. And repeat breaking until we get single element in each part or sub-array. We have single element in each sub-array. Now we have to merge them in the same way as had divided it, but in sorted manner. Compare 99 with 21, 19 with 22, 28 with 11, 14 with 18 and place the smaller number first (for ascending ...

How to set up a 10" Touchscreen LCD for Raspberry Pi

I'm a big fan of the SunFounder tech kits ( https://www.sunfounder.com ), and my kids and I have built several Raspberry Pi projects with their module/sensor kits . This holiday vacation we have two project we're doing, that coincidentally use SunFounder parts. The first is the Model Car Kit that uses a Raspberry Pi to control DC motors AND (love this part) a USB camera. So it's not just a "drive the car around" project, it also can include computer vision. My son wants to teach it to search the house for LEGO bricks and alert an adult so they'll not step on it. We were thinking to have the car call out to Azure Cognitive Services , as their free tier has more than enough power for what we need. For this afternoon, we are taking a 10.1" Touchscreen display and adding it to a Raspberry Pi. I like this screen because it works on pretty much anything that has HDMI, but it's got mounting holes on the back for any Raspberry Pi or a LattePanda or Bea...

How to Convert String to int in C and C++

There are different ways to convert string to int in C and C++. Like using inbuilt function or writing custom code. Lets take a look on each of them one by one. The programs below are written in C but the same concept will work for C++. Ways to Convert String to int in C and C++ Using sscanf() This function reads input directly from string. Take below example. #include <stdio.h> int main() { char str[] = "12345"; int x; sscanf(str, "%d", &x); printf("%d", x); return 0; } Output 12345 Using atoi() It is another inbuilt function that can directly convert string to integer. #include <stdio.h> #include <stdlib.h> int main() { char str[] = "12345"; int x; x = atoi(str); printf("%d", x); return 0; } Using Manual Method Here we will use our own custom logic for conversion. #include <stdio.h> int mai...

Introduction to TensorFlow

Here you will get TensorFlow introduction. TensorFlow is a framework which is used for machine learning and deep learning applications like neural network. It is used for data flow programming as an open source software library over various range of tasks. It is symbolic  math library used in research and production both. Tensorflow is used for general purpose computing on graphics processing units that are able to run on multiple CPUs and GPUs unlike the reference implementation that runs on single devices. It is available on Linux, macOS, windows with 64-bit configuration and also on mobile computing platforms like Android and IOS. As the neural network performs operations on multidimensional data arrays that derives from tensorflow and these arrays are called tensors. Image Source Also Read:  Introduction to Deep Learning Also Read:  Introduction to Neural Networks Tensorflow has multiple application programmable interfaces. The lowest level application program...

C++ STL Algorithm Library

In this article you will learn about stl algorithm   library in c++. Are you a competitive programmer or very passionate programmer then you must know about STL algorithm library. It contains very rich set of algorithms. If you practice this well you can nail any programming interview. All inbuilt algorithms implemented in this library were implemented in the best complexity way. So using those is better than writing own code. It also saves time and code readability. C++ STL Algorithm Library There are many of those algorithms. We will see some of them which mostly used. To work with these we first need to include algorithm library. That is #include<algorithm> In all previous articles we learned about containers, now we can apply these algorithms on those containers. Since main intention of algorithm is to retrieve information or to know some of properties, these will not do any modifications on container sizes or container storage. They just use iterators to apply on ...

Python Quick Sort

Here you get python quick sort program and algorithm. Quick sort is based on divide and Conquer technique. We divide our array into sub-arrays and that sub-arrays divided into another sub-arrays and so on, until we get smaller arrays. Because it is easy to solve small arrays in compare to a large array. Sorting smaller arrays will sort the entire array. Python Quick Sort To understand Quick Sort let’s  take an example:- Example We have an array [48,44,19,59,72,80,42,65,82,8,95,68] First of all we take first element and place it at its proper place. We call this element Pivot element. Note:  We can take any element as Pivot element but for convenience the first element is taken as Pivot. There are two condition to place Pivot at its proper place. All the elements to the left of Pivot element should be smaller than All the elements to the right of Pivot element should be greater than In given array, we’ll take first element as Pivot element which is 48. Now p...

Visualizing your real-time blood sugar values AND a Git Prompt on Windows PowerShell and Linux Bash

My buddy Nate become a Type 1 Diabetic a few weeks back. It sucks...I've been one for 25 years. Nate is like me - an engineer - and the one constant with all engineers that become diabetic, we try to engineer our ways out of it. ;) I use an open source artificial pancreas system with an insulin pump and continuous glucose system . At the heart of that system is some server-side software called Nightscout that has APIs for managing my current and historical blood sugar. It's updated every 5 minutes, 24 hours a day . I told Nate to get NightScout set up ASAP and start playing with the API. Yesterday he added his blood sugar to his terminal prompt! Love this. He uses Linux, but I use Linux (Ubuntu) on Windows 10, so I wanted to see if I could run his little node up from Windows (I'll make it a Windows service). Yes, you can run cron jobs under Windows 10's Ubuntu, but only when there is an instance of bash running (the Linux subsystem shuts down when it's not used...

Introduction to Neural Networks

Here you will get an introduction to neural networks in the field of data science. Neural networks are similar to biological neural network. Biological neural network is collection of biological neurons in human brain similarly Neural network is collection of nodes called Artificial neurons. Neural networks are based on non-task specific programming concepts like in image recognition they learn to resemble images by analyzing sample images labeled with name as “car” or “no car” and by using such sample example they identify car in other images. They need not to acquire any knowledge regarding car like it has engine, four wheels, shape and so on. They generate their own relevant characteristics from the process of their learning material. Neural Network is a feature of artificial intelligence that efforts to copy the way human brain works. Neural network perform its operation by connecting the processing elements rather than doing all computations that manipulate zeros and ones in di...

Introduction to Deep Learning

Here you will get an introduction to deep learning. Deep learning is also known as hierarchical learning. It is used for interpretation of information processing and communication patterns in biological neural system. It also defines relation between different stimuli and associated neural responses in brain. It is a part of machine learning methods with non-task specific algorithms based on learning data representation. Deep learning can be applied in many fields such as computer vision, speech recognition, image processing, bioinformatics, social network filtering and drug design with  the help of its architectures such as deep neural networks and recurrent neural network. It generates result comparable or in some cases superior to human experts. It uses outpouring of multiple layers of nonlinear processing units  for transformation and feature extraction. In this, each successive layer takes output from previous layer as input. Deep learning levels form hierarchy of c...

Setting up a managed container cluster with AKS and Kubernetes in the Azure Cloud running .NET Core in minutes

After building a Raspberry Pi Kubernetes Cluster , I wanted to see how quickly I could get up to speed on Kubernetes in Azure. I installed the Azure CLI (Command Line Interface) in a few minutes - works on Windows, Mac or Linux. I also remembered that I don't really need to install anything locally. I could just use the Azure Cloud Shell directly from within VS Code. I'd get a bash shell, Azure CLI, and automatically logged in without doing anything manual. Anyway, while needlessly installing the Azure CLI locally, I read up on the Azure Container Service (AKS) here . There's walkthrough for creating an AKS Cluster here . You can actually run through the whole tutorial in the browser with an in-browser shell. After logging in with " az login " I made a new resource group to hold everything with " az group create -l centralus -n aks-hanselman ." It's in the centralus and it's named aks-hanselman. Then I created a managed container serv...

C++ STL Unordered Multiset – std::unordered_multiset

In this tutorial you will learn about STL Unordered Multiset container in c++ and all functions applicable on it. As name says that, this is an unordered container. Set, unordered_set, multiset has some restrictions to store the elements. But here in unordered_multiset, the features are: 1) Elements need not follow specific order. They follow any order to store. 2) We know that unordered containers uses hash table for fast access. This also uses hash table to store elements. 3) Facility that both value and key same. 4) This dynamically handles the storage needs (i.e. on fly). 5) Unlike unordered sets, here duplicate values are allowed. It just counts how many such elements are there. By creating extra space. 6) Using iterator positions only we can delete elements. C++ STL Unordered Multiset – std::unordered_multiset Iterators work on unordered multiset: begin(): returns iterator to the beginning end(): returns iterator to the end of the list cbegin(): Returns constant it...

iMyFone D-Back iPhone Data Recovery

Our mobile phone is one of the most important device, it has almost all of our crucial data stored in it. Losing the data can be really dreadful. Have you lost your Iphone data due to any accident or something like system crash, forgotten password or stolen or lost data? Well if you have then let me tell you that IMyFone D-back ensures you to get it back. Many a time’s users encounter virus attacks on their phones which makes them lose all their data. Earlier to get that data back was tough but not anymore with the IMyFone D-back. IMyFone D-Back offers four modes of recovery to gain your lost data.  Following are the Features It offers smart iphone data recovery to the users, and this is the best choice for the users who know even little about technology. It also assures the users to recover the data without any hassle or data theft from all the Iphone, ipad and iPod devices. Recovering back from the iTunes might seem impossible but not anymore, with iMyFone D-back one can re...