String Data Type in Python Part 3: String Methods in Python 1 of 3
Data Science Unlimited
by grobler.inus
4y ago
Introduction There are a total of 44 string methods in total built-in the string library of Python.  This tutorial is the first of 3 parts which contain a detailed overview of most of the methods in the string library. For each method in the string library there will be a brief description of the method, details of the input parameters if applicable, the syntax of the method and then followed by an example or two of applying the method.  The data type of the input parameter will be specified in brackets next to the name of the input parameter. It will also be specified if the input p ..read more
Visit website
String Data Type in Python Part 2: Loops and Conditional Expressions
Data Science Unlimited
by grobler.inus
4y ago
Introduction In Python, it is possible to construct a loop that can look at each character of a string individually. We will look at the different ways of looping over the characters of a string. First by using a while loop and then by using a for loop. We also will look at using conditional expressions with if statements to compare strings to each other.  Loop Through the String with While Loop in Python If we use a while loop with an iteration variable and use the len function to get the total amount of characters in the string we can look at each individual character in the s ..read more
Visit website
String Data Type in Python Part 1: Working with Strings
Data Science Unlimited
by grobler.inus
4y ago
Basics of string data type in Python The variable type string is a sequence of characters. The characters can be letters, symbols or numbers. Strings are immutable sequences and thus they don’t change.  A string is an extremely useful and common data type in programming. In Python, there is much we can do with strings. This tutorial will go over the essential part of working with strings in Python.  A string of words or characters in between quotes is referred to as string literals, such as, ‘Hello World’ or “Hello World”. We can use single or double quotes in Python to create a stri ..read more
Visit website
How to Use the For Loop in Python
Data Science Unlimited
by grobler.inus
4y ago
Introduction In the previous tutorial, we explained how loops work and went into detail with explaining the workings of the while loop in Python. This tutorial will go into detail with the for loop. To recap, loops allow a computer to do tasks repetitively. This allows us to do powerful tasks with computers that would not be possible otherwise.  For loop in Python Another type of loop in Python is the for loop. A for loop also referred to as a definite loop have an exact amount of iterations it goes through. The for loop has iteration variables that change every time the loop is ..read more
Visit website
How to Use the While Loop in Python
Data Science Unlimited
by grobler.inus
4y ago
Introduction to loops Loops is where a computer does repetitive tasks. This is where computers become very useful and powerful.  Loops have iteration variables that change each time the loop goes through an iteration. Often loops go through a range of numbers. In Python you have the ability to iterate over a list of variables which can be useful in certain operations.  In Python, you get two types of loops namely a while loop and a for a loop. Most prefer to use a for loop when possible as it can be more efficient than the while loop. The while loop has its use cases.  In this tut ..read more
Visit website
How to Define and Use Functions in Python
Data Science Unlimited
by grobler.inus
4y ago
What is a function in Python A function is a set of code that is assigned to a function that can be executed when calling the function. This allows us to make our code more readable and save time by being able to call the same code multiple times. The function can have parameters which are variables passed to the function. The function has a unique name and has the same naming restrictions as variables in Python. Recap of the restrictions: The function’s name is not allowed to start with a number. The first character must either be a letter or an underscore character.  No non-alp ..read more
Visit website
If Statement in Python Tutorial
Data Science Unlimited
by grobler.inus
4y ago
Conditional statements A conditional statement refer to a statement that is only executed if a condition holds true. If the statement is false another statement is executed. This is the basic logic of an if statement.  The following chart is an example of the logic followed by an if statement whereby if the value of x is less than 5 ‘smaller’ is printed to the screen. If the value of x is more than 10 then ‘larger’ is printed to the screen. If x is neither less than 5 nor greater than 10 then ‘neither’ is printed to the screen. In this case, x = 8 and is neither less than 5 or greater t ..read more
Visit website
Variable types in Python
Data Science Unlimited
by grobler.inus
4y ago
In Python variables, literals and constants have a type. Python knows the difference between an integer number and a string of text. Once a variable is declared and a value assigned to it the variable has a type. The most basic types are a string, an integer, a boolean and a float.  This tutorial builds on the previous tutorial about variables and expressions. String type A string is a variable type for text or a “string” of text. To initiate an empty string variable in Python you use the chosen variable name and set it equal to an empty string using single or double quotes: empt ..read more
Visit website
Variables and Expressions in Python
Data Science Unlimited
by grobler.inus
4y ago
Constants A constant is a fixed value such as a number, letter or string of text that does not change their value. Variables A variable is used to store data values. A variable is a place in the memory where a programmer can store data and then later retrieve this data using the variable’s name that was assigned to it.  A variable is created as soon as a value is assigned to it. In other programming languages, there is a command to declare a variable and specify the type of the variable but in the Python programming language, there is no command for declaring a variable. The ..read more
Visit website
Python Basics and Print Function
Data Science Unlimited
by grobler.inus
4y ago
Basics of programming: We use a programming language to describe what we want the computer to do. Programming languages such as Python follow grammar called syntax.  The syntax of the Python programming language is the set of rules which defines how a Python program will be written. If the syntax has a mistake the program will stop and raise an error. Syntax errors are usually easy to spot and can easily be fixed.  Sequential execution is when the computer performs the statements one after another in the order they are encountered in the script. In Python the code is executed l ..read more
Visit website

Follow Data Science Unlimited on FeedSpot

Continue with Google
Continue with Apple
OR