Challenge
Catch what you expect
…Change except: to except Exception as error: and print type(error).__name__ in it, to see what is really being caught. Store its name in hidden_error , and the number of readings that are really bad…
Showing 41–50 of 73
Challenge
…Change except: to except Exception as error: and print type(error).__name__ in it, to see what is really being caught. Store its name in hidden_error , and the number of readings that are really bad…
Example
Functions can return complex data structures like dictionaries or lists.
Example
Sets store only unique elements without a specific order.
Quiz
…print() with sep and end , f-strings Variable names, data types and type conversion Arithmetic: // , % , ** and operator precedence Strings: indexing, slicing and string methods Conditions: if , elif…
Article Mini projects
…{details['distance']} million km") print(f"Surface type: {details['surface']}") print(f"Number of moons to explore: {details['moons']}") print(f"Mission duration: {mission_duration} days")…
Article Mini projects
…menu using the print() function: print("Choose the type of conversion:") print("1. Temperature in degrees Celsius to temperature in degrees Kelvin.") print("2. Temperature in degrees Fahrenheit to…
Example
Tuples are immutable lists. Once created, they cannot be modified.
Article Python Fundamentals
…code editor you have Create a new file called first.py Type this code and save your file: # This is your first program moon_distance = 384400 mars_distance = 225000000 print(f"The moon is…
Challenge
Clean the crew sign-ups for the analogue mission: trim and capitalise names, lower-case emails, then reject sign-ups with no name or a broken email and drop duplicates by email, saying why for each…
Article Python Fundamentals
…Every example below runs as it is. Open the editor and type along rather than just reading. Typing the code yourself sticks far better, and you'll make a few typos that teach you more than the article…