Home » Programming

How to Get User Input in Python [With Examples]

Get User Input in Python

This article covers getting user input on the command line using Python 2 or 3 and includes some useful examples. Get User Input in Python 3 Python 3 uses the input() function to collect user input: myText = input(“Enter some text:”) print(“You entered the text: ” + myText) Get User Input in Python 2 If you’re still using Python 2, you will use the raw_input() function instead: myText = raw_input(“Enter some text:”) print “You entered the text: “, myText # Python 2 uses different syntax to print output Typing Input … Read more

Home » Programming

Assign Variables, Global Variables and Scopes in JavaScript (let, var, const)

JavaScript let var const

let, var, and const are all JavaScript statements that assign a value to a variable. Their behavior can differ depending on how and where they are used in your code – read on to find out the details. Scopes in JavaScript As you start to build more complex applications, you’ll start to see a lot of talk about scopes. A variable’s scope defines where it is available in your application. Global Scope (Global Variables) If a variable is in the global scope, it is available anywhere in your application. It can be called … Read more

Home » Programming

Creating Multiline Strings in JavaScript [With Examples]

Creating Multiline Strings in JavaScript

There are several ways to create text that spans multiple lines in JavaScript – so here they are! Method 1: Backticks This is the best method, so it goes first. It is only compatible with ECMAScript 6 and onwards, so it is only for use in modern browsers (really, if you’re using any browser that isn’t Internet Explorer, you should be fine, but you should always test your code on the browsers you want to target). var multiText = ` This is multiline text!`; console.log(multiText) // … Read more

Home » Programming

Python Scatter Plots with Matplotlib [Tutorial]

Python Scatter Plots

Graphs are awesome. If you disagree, you probably shouldn’t read on. The best (and easiest!) way to create graphs and scatter plots in Python is using the package Matplotlib. This tutorial explains exactly how to do so. https://pypi.org/project/matplotlib/ What is matplotlib? I’ll let them introduce themselves in their own words: Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. This article will give you a jump-start on using Matplotlib to create scatter plots. Install Python Dependencies First, you’ll need to install MatplotLib using … Read more

Home » Programming

PHP var_dump() Function [With Examples]

PHP var dump Function

The PHP programming language includes various built-in variable types and allows you to create your own complex object classes. Third-party packages also come with their own object classes. So it’s useful to find out what type of variable a variable is, its value, and the type/value of any properties or values the variable may contain. The PHP var_dump() function returns a given variable or value’s properties, including the value and type. It works through the variable’s properties or value recursively doing the same. Read on to learn … Read more

Categories PHP

Home » Programming

PHP strtotime() Function – Converting Text to Timestamp [With Examples]

PHP strtotime

The PHP strtotime() function takes a string containing text and converts it to a Unix Timestamp. Find out how to use this function in this guide. A Unix timestamp is a number representing the number of seconds since 00:00:00 UTC on 1 January 1970. From it, you can build more complex Date/Time objects which can readily provide Dates/Minutes/Hours/Seconds or other information about the supplied time. strtotime Syntax strtotime ($datetime , $baseTimestamp) Note that: $datetime is your supplied text string (possibly) containing a date strtotime() supports the English language only See … Read more

Categories PHP

Home » Programming

Concatenating (Joining) Strings in JavaScript [3 Methods]

javascript string concatenation

Being able to concatenate (join) two or more strings together is pretty useful – you may be combining user input for storage in a single database column or doing the reverse – combining data from multiple database columns into a single string for display or output. There are several ways to concatenate strings in Javascript, and we’ll cover these methods below, along with some useful examples. The string.concat() Method The string.concat() method will join any number of strings to a given initial string. Syntax string.concat(string1, string2, string3…) Note that: string is … Read more

Home » Programming

Javascript String includes() Method – Check if a String Contains Another String

Javascript String includes

Here’s a guide on checking whether a string contains another string in the JavaScript programming language using the includes() method. includes() Syntax string.includes(search, start) Note that: string should be a string value or variable search should be the string you are checking for start is the index (position) you want to start searching at. It’s optional Indexes start counting at 0 – The first character of the string is at index 0 returns bool Examples var string = “Linux all over the world”; var result = string.includes(“over”); // Will … Read more

Home » Programming

Python isinstance Function, With Example [Guide]

Python isinstance Function

The Python isinstance() function determines the type or class of a variable. Read on to find out exactly how isinstance works, with an example below. What are Types? The type of a variable determines what it can or can’t do. It determines what value the variable may take and what can be done with that value. isinstance Syntax isinstance(OBJECT, CLASS) Note that: OBJECT is the variable or value to check the type or class of CLASS is the type or class we want to see if the variable type matches The function returns a boolean value (True/False) Types in Python Generally, … Read more

Home » Programming

What is a Tuple in the Python Programming Language?

python tuple

A Tuple is a type of variable in Python – a data structure containing multiple parts. It’s a collection (or array) of data – but a specific kind of collection. It’s Ordered (Indexed) Elements in a tuple are stored in order – stored with an index or position – their position in the collection is fixed, and they can be found by their position. It’s Unchangeable (Or Immutable) Once a tuple is created, elements in it cannot be moved, removed, added, or altered. Duplicates are Allowed Duplicate values are allowed as tuples are indexed, so multiple elements with the same … Read more