Skip to main content

Posts

Showing posts from August, 2020

How to use loops in Python

In this post, you will learn how to use loops in Python . Loops are a commonly used structure in programming that allows you to repeat a block of code a set number of times, or until you meet a particular condition. This is useful for many reasons. For example, if you are building a game, then you might want the bulk of your code to continuously “loop” while you update the position of enemies and check for player inputs. If you build a game in Pygame, then “game loop” will be one of the most important aspects of that code. Also read: How to make a game in Python: An introduction to Pygame More often, programmers need to learn how to use loops in Python so that they can perform iterative tasks. For instance, they might want to individually check all the files in a list, or they might want to look for something in a database. Now you know what a loop is, the next question is how to use loops in Python! How to use “for” loops in Python There are two main types of loop across pro

How to print an array in Java

An array is a type of variable that can store multiple values with an index. This allows developers to modify, arrange, and organize large data sets. Something that developers need to do often, is print an array in Java. In this post, we’ll explore how to do that. See also: How to use arrays in Python How to print an array in Java – the easy way There are a few different types of array in Java and a few ways to print each of them. The main Java Array looks like this: String vegetables[] = {"broccoli", "cauliflower", "potato", "carrot", "spinach", "beans"}; This is an array that contains the names of different vegetables. I can print any element from that list like so: System.out.println(vegetables[3]); In order to print an array in its entirety, I would simply need to create a little loop. int i = 0; while (i < vegetables.length) { System.out.println(vegetables[i]); i++; } That, very simply, is how to pr

How to install Java, and everything else you need to know

Whether you want to begin coding in Java or just wish to run Java apps, you first need to learn how to install Java. In this post, we’ll see how to do that. Why do you need to install Java? Programmers would describe Java as both being “compiled” and “interpreted.” This means that Java code can’t be understood natively by the computer but must first be “compiled” to a Java Bytecode. This Bytecode can then be run by any device that has the “Java Virtual Machine” installed. Alternatively, the code can be translated by software installed onto your machine. Suffice to say, that until you install Java, you won’t be able to run programs that are written in it. Seeing as a lot of apps we use every day are written in Java, that’s an issue! It also means that you need a slightly different installation, depending on whether you want to run Java apps or build them. To develop or run Java applications, you first need to install Java to act as an interpreter. For this, you’ll need the Java De

Java beginner course – A free and comprehensive guide to the basics of Java

Java is one of the most highly sought after programming languages, not to mention one of the two official languages for Android development. In this Java beginner course, we’ll go over the basics to provide you with a solid foundation and understanding of how the language works and what you can do with it. Prerequisites This Java beginner course assumes that you have no prior background in programming. In order to follow along however, you will need to use an online compiler. This will provide a terminal where you can enter Java code and then test your projects. A good example can be found here: Repl.it . Otherwise, you can also find a number of Java compilers in the Google Play Store and Apple App Store. Chosen your editor? Great, let’s get started! Java beginner course part 1: Hello world! Traditionally, when learning any new programming language, the first thing a tutorial should demonstrate, is how to print “Hello World!” to the screen. Depending on your chosen programming

How to call a method in Java

In this post, we will learn how to call a method in Java. This is a useful “chunk” of code that you can call from anywhere else in your program, thus preventing you from needing to write out the same lines of code over and over. By designing code this way, developers can create far more modular and portable programs and save significant time typing out code. How to call a method in Java – the basics To call a method in Java, you type the method’s name, followed by brackets. For example, the following will call a method called “helloMethod()”: helloMethod(); In order for this to work though, we first need to create our helloMethod() method. We can see what helloMethod might look like, here: public static void helloMethod() { System.out.println("Hello world!"); } This code simply prints “Hello world!” to the screen. Therefore, any time we write helloMethod(); in our code, it will show that message to the screen. If you ever want to change the message being dis

How to use classes in Python

One of the more complicated concepts to get your head around as a new programmer is classes and objects. Once you know how to use classes in Python though, you will be ready to build significantly more powerful and complex code. Also read:  What is object oriented programming? Read on to learn how to use classes in Python, and when you should! Introducing classes in Python For those that are unfamiliar with the concept of classes and who want to learn more about how they work, keep reading. If you just want the syntax for classes in Python, you can skip to the next section! So, what is a class? A class is a piece of code that describes a “data object.” This is an object just like you find in the real world, except that it has no tangible presence: it only exists in concept! Like real objects though, data objects can have properties (size, weight, height, number of lives, speed), and they can have functions (move forward, jump, turn up the heat, delete). In a computer game, for

How to install Android on PC: These are your best options

Android is the most popular mobile operating system in the world, but just because it’s meant for mobile doesn’t mean it can’t be installed on the desktop. There are many ways to get Android running on a PC, including virtual device emulators, bootable USB versions, and even full standalone applications like BlueStacks . Each has its advantages and disadvantages depending on your needs. Here is the full breakdown of each. If you’re looking to install Android on PC, we have your back! Using Android Studio and the virtual device For the most part, Android development requires a tool called Android Studio. This is the software developers use to enter their code, test their apps, and manage their projects. It also happens to include a powerful “Android virtual device manager” (AVD Manager) for setting up and installing emulators that can run full-fat Android extremely well. Using this Android virtual device has many advantages. If you select x86_64 as the architecture, there is th

How to use arrays in Python

Arrays in Python give you a huge amount of flexibility for storing, organizing, and accessing data. This is crucial, not least because of Python’s popularity for use in data science. But what precisely is an array? And how do you use arrays in Python? Also read: How to use dictionaries in Python Read on, and we’ll shed some light on the matter. What is an array? An array is a way to store multiple values in a single variable. That means that you can use a single “reference” in order to access your data. A list is also an example of a variable that stores multiple values, but has some slight differences. When using lists in Python, you store a series of values each with a numbered index. For example, this is how you would create a list of fruits in Python: fruits = [“apple”, “orange”, “pear”, “nectarine”] If we then say: print(fruits[3]) We will see “nectarine” appear on the screen (the first entry is stored as “0”). Also read: How to use lists in Python This is not an

How to use Python modules

Once you know how to add and use a Python module, you will greatly extend the capabilities of the language. A Python module is an external class or set of functions that exist outside the main file of your program. This can be something that you built yourself, or it can be provided by the community. Either way, the modular nature of Python means these elements can be used to seamlessly extend the capabilities of an application, or to share utilities you’ve built across multiple projects. In this post, we’ll explore how to add and use a Python module. How to use built-in modules Your basic Python installation comes with a host of Python modules that are ready to use. These provide basic functionality that a large proportion of programmers will rely on. Also read: How to install Python and start coding on Windows, Mac, or Linux For example, if you want to generate a “pseudo random number” (“pseudo” because there is no such thing as a random number in programming), then you wil

Google Pixel 4a vs OnePlus Nord, and more news from Gary Explains

Your bi-monthly dose of tech industry and developer news, brought to you by the Gary Explains Newsletter Windows on Arm only needs one thing to become great: Linux, macOS, and Windows all run on Arm-based processors. However, Windows on Arm is currently the weakest solution of the three. There is one thing that could make Windows on Arm great. ( YouTube ) Deal: Pay as little as $1 and learn cloud computing with AWS The Basics: What is the Cloud? As part of my “The Basics” series, here is a look at the nebulous term called “the cloud.” What is it and how does it affect you? ( YouTube ) Does Microsoft have a compiler problem that makes Linux faster? While developing my new benchmark, Speed Test G PC, I noticed the results were much slower on Windows compared to Linux. Here’s why! ( YouTube ) Speed Test G battles Google Pixel 4a vs OnePlus Nord : Two of the most important mid-range phones of 2020 are the Pixel 4a and the OnePlus Nord. They both use Snapdragon 700-series pro