Earlier when discussing strings we introduced the concept of a sequence in Python. Lists can be thought of the most general version of a sequence in Python. Unlike strings, they are mutable, meaning the elements inside a list can be changed! In this section we will learn about: 1.) Creating lists 2.) Indexing and Slicing … Continue reading Lists in Python
Category: Python Tutorial
String Formatting
String formatting lets you inject items into a string rather than trying to chain items together using commas or string concatenation. As a quick comparison, consider: player = 'Thomas' points = 33 'Last night, '+player+' scored '+str(points)+' points.' # concatenation f'Last night, {player} scored {points} points.' # string formatting There are three ways to perform … Continue reading String Formatting
Strings
Strings are used in Python to record text information, such as names. Strings in Python are actually a sequence, which basically means Python keeps track of every element in the string as a sequence. For example, Python understands the string "hello' to be a sequence of letters in a specific order. This means we will … Continue reading Strings
Variable Assignment
Rules for variable names names can not start with a number names can not contain spaces, use _ intead names can not contain any of these symbols: :'",<>/?|\!@#%^&*~-+ it's considered best practice (PEP8) that names are lowercase with underscores avoid using Python built-in keywords like list and str avoid using the single characters l (lowercase … Continue reading Variable Assignment
Numbers and more in Python
In this tutorial, we will learn about numbers in Python and how to use them. We'll learn about the following topics: 1.) Types of Numbers in Python 2.) Basic Arithmetic 3.) Differences between classic division and floor division 4.) Object Assignment in Python Types of numbers Python has various "types" of numbers (numeric literals). We'll … Continue reading Numbers and more in Python
