Variables
Variables are an essential part of any programming language. A variable is a name that refers to a value stored in the computer's…
Explore the fundamentals of data types in programming in-depth in this lesson. Data types are essential elements in program creation, as they determine how information is stored and manipulated. Enhance your programming skills and understanding of data types through a series of practical exercises designed to reinforce your knowledge.
Variables are an essential part of any programming language. A variable is a name that refers to a value stored in the computer's…
A data type defines what kind of value something is and which operations can be done with it. Python is dynamically typed (the…
These are the basic types that represent simple values. Unlike other languages, in Python they are objects like any other, and…
Sometimes you need to turn a value of one type into another, for example to do arithmetic with a number that the user typed. This…
A string ( str ) is a sequence of characters. Almost everything a program shows is text, so it is worth mastering how to create…
Strings come with many built-in tools, called methods, to transform and examine them. You call them by writing a dot after the…
Showing a result is not only about being correct: how it looks matters too. Python offers formatted strings, or f-strings, to…
Comparing values is the basis for a program to make decisions. Every comparison results in a logical value ( bool ): True or…
Games, simulations and tests often need random values. Python provides them in the random module, which is part of the standard…
Everything in Python is an object , and a variable is just a name that points to an object. Understanding which objects can be…
Any object can be used as a condition. Python converts it with bool() : falsy values are None , False , zeros ( 0 , 0.0 ), empty…
Write a program to ask the user for three letters and display them in reverse order.
Write a Python program that requests the width (x) and height (y) of a rectangle and calculate the perimeter, area and diagonal.
Create a program Python to ask the user for a distance in meters and the time taken (hours, minutes, seconds).
Create a Python program that prompts the user for 2 integers and displays a random number on the screen between those values.
Create a Python program that reads two texts and swaps them using variables, without writing them directly in the output.
Create a Python program that reads a decimal number and shows it converted to other types.
Create a Python program that reads a first name and a surname and shows their initials in capital letters separated by dots.
Create a Python program that reads a sentence and shows four facts about it.
Create a Python program that turns a sentence into a hyphen-joined string and counts its words.
Create a Python program that reads a word of at least four letters and shows several pieces of it.
A palindrome is a word that reads the same forwards and backwards, like level . Create a Python program that checks it.
Create a Python program that compares two integers with all the comparison operators.
Create a Python program that calculates the total of a purchase and shows it formatted as money.
Create a Python program that separates the digits of a three-digit number using only arithmetic operations.
The is operator checks identity (is it the same object?) and == checks equality (do they have the same value?). A copy is equal…
With nested lists, a shallow copy shares the inner lists with the original; a deep copy duplicates them too.
In Python every value has a truth value : None , False , zero, empty strings and empty collections are falsy; everything else is…
int() raises ValueError if the text is not an integer. A function can catch that error and return None to signal that the…