Category: Tips

Parsing data with strtok in C
Post

Parsing data with strtok in C

Originally posted on opensource. The strtok function is a handy way to read and interpret data from strings. Use it in your next project to simplify how you read data into your program. Some programs can just process an entire file at once, and other programs need to examine the file line-by-line. In the latter...

How to Use Python to Reverse a String
Post

How to Use Python to Reverse a String

Originally posted on makeuseof. Either one of these approaches works, so find out which is most suitable for you. Python has many useful string functions, like casefold() which converts a string to lower case. There is no string-reversing function built into the language. However, there are two simple approaches you can use to reverse a...

How to Execute SQL Queries in Python and R Tutorial
Post

How to Execute SQL Queries in Python and R Tutorial

Originally posted on datacamp. Learn easy and effective ways to run SQL queries in Python and R for data analysis and database management. What is SQL Structured Query Language (SQL) is the most common language used for running various data analysis tasks. It is also used for maintaining a relational database, for example: adding tables,...

Logging in Python
Post

Logging in Python

Originally posted on machinelearningmastery. Logging is a way to store information about your script and track events that occur. When writing any complex script in Python, logging is essential for debugging software as you develop it. Without logging, finding the source of a problem in your code may be extremely time consuming. After completing this...

11 Bite-Sized Python Recipes You Must Know
Post

11 Bite-Sized Python Recipes You Must Know

Originally posted on makeuseof. These code samples will help you learn about Python basics and solve common everyday challenges. Many programmers like Python for its simple and concise syntax. These Python recipes are small sample programs that you can use to solve common daily problems. Use these easy-to-digest Python recipes and take your coding efficiency...

What are go workspaces and how do I use them?
Post

What are go workspaces and how do I use them?

Originally posted on dev. I previously blogged about generics being added as part of the Go 1.18 release. There was another quality of life improvement that was added with this release called “Go workspaces”. This is what the release notes said about workspaces: In this blog post, we are going to explore what Go workspaces are and...

Data Visualization in Python with matplotlib, Seaborn and Bokeh
Post

Data Visualization in Python with matplotlib, Seaborn and Bokeh

Originally posted on machinelearningmastery. Data visualization is an important aspect of all AI and machine learning applications. You can gain key insights of your data through different graphical representations. In this tutorial, we’ll talk about a few options for data visualization in Python. We’ll use the MNIST dataset and the Tensorflow library for number crunching...

How to Create a Monte Carlo Simulation using Python
Post

How to Create a Monte Carlo Simulation using Python

Originally posted on towardsdatascience. Walkthrough an example to learn what a Monte Carlo simulation is and how it can be used to predict probabilities What is a Monte Carlo Simulation? A Monte Carlo simulation is a type of computational algorithm that estimates the probability of occurrence of an undeterminable event due to the involvement of...

5 Advanced Tips on Python Objects
Post

5 Advanced Tips on Python Objects

Originally posted on towardsdatascience Python is an object oriented programming language but can behave strangely. If you come from other OOP languages, this post may benefit you In chapter 8 of Fluent Python, Luciano Ramalho discusses how python objects under the hood. Here will define the fundamental concept behind variable storage in python and explore some...

How to Write SQL in Native Python
Post

How to Write SQL in Native Python

Originally posted on kdnuggets. If the idea of being able to link with SQL databases and define, manipulate, and query using Python sounds appealing, check out the SQLModel library. Do you write a lot of SQL? Do you end up calling a lot of this SQL from within Python? Does the idea of being able...

Switch statements in javascript – How to refactor?
Post

Switch statements in javascript – How to refactor?

Originally posted on dev. The Switch statements are perfectly nice and majorly used in the other traditional language like C, C++, and Java. Why Switch statement? The switch statement executes different actions based on the different conditions. Of course, we can solve the above with an if-else ladder but that will make the program too much clumsy. Also,...

JavaScript Hoisting
Post

JavaScript Hoisting

Originally posted on dev. In this article, we are going to discuss about hoisting in JavaScript. Hoisting, is a process that happens during the creation of execution context, which will move the declarations of variables and functions up to the top of the context. Let’s start with an example: hello(); function hello(){ return "Hello World";...

How to write performant React code: rules, patterns, do’s and don’ts
Post

How to write performant React code: rules, patterns, do’s and don’ts

Performance and React! Such a fun topic with so many controversial opinions and so many best practices flipping to be the opposite in just 6 months. Is it even possible to say anything definitive here or to make any generalized recommendations? Usually, performance experts are the proponents of “premature optimisation is the root of all...

Understanding Traceback in Python
Post

Understanding Traceback in Python

Originally posted on machinelearningmastery. When an exception occurs in a Python program, often a traceback will be printed. Knowing how to read the traceback can help you easily identify the error and make a fix. In this tutorial we are going see what the traceback can tell you. After completing this tutorial, you will know:...

Python Switches to Match-Case
Post

Python Switches to Match-Case

Originally posted on dev. If reading about code with foo, bar, and math examples is the bane of your existence, keep reading. Expect examples with sweaters and dogs. Jump to: Past Present Benefits Example 1 Example 2 Future Past Once upon a time, in 2006, a Python Enhancement Proposal(PEP) was introduced. PEP 3103 detailed many different ways a switch...