Challenge
Flag from config text
…give and store the answers, True or False , in the two variables. Run them to check, and remove any lines you added before you check. Modify. Work dry_run out by comparing the text with "True" , so it…
Showing 41–50 of 53
Challenge
…give and store the answers, True or False , in the two variables. Run them to check, and remove any lines you added before you check. Modify. Work dry_run out by comparing the text with "True" , so it…
Quiz
…, dictionaries and sets . After this one, try the Python Variables Quiz or the Python Basics Quiz . Which of these values is an int ? What does this code print? Which of these expressions give a float…
Article Python Fundamentals
…Overly complex conditions: Break them into named boolean variables for clarity. safe_fuel = fuel >= 60 good_weather = wind_speed < 20 if safe_fuel and good_weather: launch = True Relying on…
Article Python Fundamentals
…book's structure: first half covers Python fundamentals (variables, lists, dictionaries, functions, classes), while the second half walks you through three complete projects - a Space Invaders-style…
Example
Return statement returns a value from function. Function can perform calculations and give result.
Quiz
…quiz covers Comments, print() with sep and end , f-strings Variable names, data types and type conversion Arithmetic: // , % , ** and operator precedence Strings: indexing, slicing and string methods…
Article Python Fundamentals
…temperature:", telescope_temp, "Kelvin") The variable telescope_temp is set by us, but it could actually be set by the temperature monitoring system, and with print, you can display it on the screen…
Article Mini projects
…enter: ")) We assign the choice entered by the user to the variable choice as a numerical value int. Performing calculations Having saved the choice in the choice variable, we can call the appropriate…
Challenge
…fuel_needed(-5) raises ValueError : call it in try , set a variable to True in except ValueError: , and assert it after. Then print: All checks passed Leave the function as it is. The hidden tests…
Challenge
…once and then pasted for the next two waypoints, with the variable names changed by hand. One wrong name in one copy and the display would lie about one waypoint only. Give the formula a name, call it…