Python-Cheat-Sheet
Python-Cheat-Sheet Variables We use variables to temporarily store data in the computer’s memory. price = 10 rating = 4.9 course_name = ‘Python for Beginners’ is_published = True In the above example, • price is an integer (a whole number without a decimal point) • rating is a float (a number with a decimal point) • course_name is a string (a sequence of characters) • i s_published is a boolean. Boolean values can be True or False. Comments We use comments to add notes to our code. Good comments explain the hows and whys, not what the code does. That should be reflected in the code itself. Use comments to add reminders to yourself or other developers, or also explain your assumptions and the reasons you’ve written code in a certain way. # This is a comment and it won’t get executed. # Our comments can be multiple lines. Receiving Input We can receive input from the user by calling the input() function. birth_year = i nt(input(‘Birth year: ‘)) The input() function always r...