Quiz
Python Basics Quiz
…sets Loops with range() , break and continue Functions: default values, keyword arguments, returning several values and variable scope How it works 20 questions: 15 with one correct answer, 5 where…
Showing 11–20 of 71
Quiz
…sets Loops with range() , break and continue Functions: default values, keyword arguments, returning several values and variable scope How it works 20 questions: 15 with one correct answer, 5 where…
Challenge
…stay exactly the same: [T+00:12:05] INFO Engines nominal Define the function at the top: def format_log(t, level, msg): , with return f"..." inside, using its own parameter names. Then…
Article Mini projects
…let's break down our solution step by step: Step 1: Define Constants and Data First, let's specify what we know: import numpy as np # Gravitational constant - always the same in the universe G =…
Article Mini projects
…that class: import sqlite3 class CosmicHealthTracker: def __init__(self): #let's create database first self.create_database() def create_database(self): conn = sqlite3.connect('space_station.db')…
Article Mini projects
…read in reverse order, give you the base-6 number. def decimal_to_base6(decimal_number): if decimal_number == 0: return "0" digits = [] # We'll collect remainders here number = decimal_number while…
Quiz
Free beginner quiz on Python variables: 15 questions on naming, assignment, data types, type conversion and scope, with instant answers.
Article Mini projects
…handle them. Functions for converting temperatures Let's define 2 functions necessary for our calculations. These will be the celsius_to_kelvin and fahrenheit_to_kelvin functions: def…
Challenge
Load the downlink module's JSON settings over a copy of the defaults, check each value's type and range and report every problem in one go, then wrap it all in a load_config() that never crashes, even…
Article Mini projects
…planets and another to calculate their orbital paths: def create_planet(color, size): planet = turtle.Turtle() planet.shape("circle") planet.color(color) planet.shapesize(size) planet.penup() return…
Article Mini projects
…write a function that randomly selects our destination: def select_random_destination(): # Choose a random planet destination = random.choice(list(planets.keys())) # Get planet details planet_info =…