A ten-minute Python crash course covering variables, data types, math, logic, loops, functions and exceptions.
Decide on a name, such as item, and then assign it a value. The value shown is a string, which is just any form of text for the program to read. The naming convention is an underscore every time you have more than one word, as in item name, assigned orange.
Four. The integer, which is just any number and is written in blue; strings, any text inside quotation marks; booleans, a simple true or false; and lists, a pair of brackets with the values you insert, which can mix numbers and booleans. Printing them gives 2021, text, false and the list.
Convert them into the correct types first. Print name plus the string value of the integer, which converts the integer to a string so the two texts combine; using the integer alone raises an exception. The other way, put parentheses and int ahead of the string number to add 10 to it.
Addition is a plus symbol, the difference a minus symbol, multiplication an asterisk, division a slash, and the exponential power two asterisks. With one variable at 10 and one at 5, printing all of them gives a very quick calculator: 10 plus 5 is 15, a minus b is 5.
With age set to 28, if the age is more than 21 it prints you are old; elif the age is equal to 18 it says you are getting old; if neither, you are still young. Because is happy is false it prints you are not happy; set it to true and it prints you are happy.
Because in programming the index always starts at zero, so for i in range of three prints hello zero, hello one, hello two. To start at one you manually add one to i. Printing range of three shows a range object with values from zero to three, and loops also run over lists.
With break. Inside while true the program takes a user input that says enter something; if the user input is equal to the string of zero it prints we are done here and breaks, which cancels the loop. Type 10 or 2 and it keeps going; type 0 and the program finishes.
Use the def keyword and name the function however you like, with the underscore convention. The example prints hey there plus the name. Functions are used to reuse your code as much as possible: call it with Mario and again with Luigi and it says hey there Mario, hey there Luigi.
It says there is nothing in here, the program accepts that, and it still runs regardless of the function having no content. Empty functions such as get internet and run game give an error, but with pass there are no errors. It is good for creating blueprints before you know how to write them.
Use try and accept. After an input that says please provide a number, the try block prints the value plus the integer of that number; if an exception occurs it goes to the accept block and prints that is not a valid number. Writing 10 adds it, writing Mario cannot convert.
“What is up guys, in this video I'm going to be showing you how you can get started with Python in less than 10 minutes.”
“They are free and open source, so definitely do check those out.”
“Then we have booleans, which is just a simple true or false.”
“and the if else statement is going to probably be your most used logic”
“you want to maximize how often you can reuse the same line of code without having to rewrite it.”
“that is called pass, which essentially just says, there's nothing in here, we accept that,”
“Learn Python in Less than 10 Minutes for Beginners (Fast & Easy).” https://www.youtube.com/watch?v=fWjsdhR3z3c. Transcript summary by WhipScribe, https://whipscribe.com/transcript-pages/learn-python-in-less-than-10-minutes-for-beginners-fast-easy.html.