Challenge
Round or cut?
int() cuts the decimals off, round() rounds, and round(2.5) gives 2. Predict the difference, investigate Python's rounding rule, then round a fuel reading two ways.
Showing 11–17 of 17
Challenge
int() cuts the decimals off, round() rounds, and round(2.5) gives 2. Predict the difference, investigate Python's rounding rule, then round a fuel reading two ways.
Article Mini projects
…In this article, we'll show you how to make such conversions easily using Python. To perform the conversion, we need to know the formulas for converting degrees Celsius to Kelvin and degrees…
Challenge
…the function gives back, fix it with return, then write a conversion function that returns.
Challenge
The burn length is typed in by hand, and a typo stops the program with a ValueError. Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative…
Article Python Fundamentals
…through space exploration examples. Learn about number types, operators, and practical applications that will help you start your programming journey in an engaging way.
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 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…