Anna CS 123 - Python Tutorial
School name Anna University
Course Cs 123-
Pages 3

Unformatted text preview:

Python Tutorial Python Full Course for Beginners Programming with Mosh Mosh an experienced software engineer and instructor who has taught over 3 million people how to code has designed a Python course for anyone who wants to learn Python He will guide students in downloading and installing Python on their computers as well as using the language in machine learning and artificial intelligence Moreover all the materials in the course will apply to the latest version of Python which as of the time of recording was Python 3 7 2 but may have been updated since then Additionally Mac computers come with an outdated installation of Python Python 2 which is no longer maintained or supported Mosh recommends setting the base interpreter to Python 3 when creating a new project using Pycharm It s also worth noting that by convention all Python files should have the py extension In this Python tutorial we re gong to take this program to the next level and make it more interesting So I m going to show you how to draw a dog hair As part of this tutorial you will learn how Python code gets executed and you will also learn about a few programming terms In the future as you learn more Python you ll be able to build applications that have a graphical user interface With this piece of code we can draw 10 asterisks on the terminal Python interpreter tries to execute line 4 when it executes line 4 It will evaluate the code that we put in between parenthesis and before the parenthesis add a space once again add an asterisk space 10 So let s run this program one more time there you go Are you excited to learn Python and get started on this career path If you are I would encourage you to make a commitment and spend 2 hours every day practicing python Use the comment box below and let me know why you are learning Python what do you want to do with it What s your dream job I would love to hear your story Python interpreter executes our code line by line from the top On the second line we can update the value of this price variable so we can reset it to a new value like 20 On line 2 we can define another variable called rating and set it to number 4 9 Now note that Python is a case sensitive language Python is sensitive to lower case and upper case letters In this tutorial I m going to show you how to receive input from the user So we re going to write a small program that asks the user s name and then we ll print a greeting message customized for that user In Python we also have functions for common tasks such as printing messages receiving input and so on Mosh has created a cheat sheet with summary notes to review the materials in this course The link is below this video So I have done my best to create the best possible Python course on Youtube And I really appreciate it if you support my hard work by liking this video and sharing it with others We re going to write a program that will ask the year that we were born in and then it will calculate our age and print it on the terminal Python does n t know what to do with subtraction So whenever you see this message that means there is something wrong with your program Python does n t know how to interpret or how to evaluate this expression To fix this problem we need to convert this 1982 into an integer and then we ll be able to subtract it from 2019 and that is easy I want you to write a program ask the user their weight and then convert it to kilograms In this tutorial you re going to learn more about Python strings So I ve defined this course variable and set it to Python for beginners defined another variable weight kg we set this to weight lbs times 0 45 And finally let s print weight underline kg Let s run this Python program and see what happens We use square brackets to get a character and a given index in this string The index of the first character in the string is 0 We can also use a negative index here This is one of the features that we do n t have in other programming languages as far as I know The square bracket syntax is pretty important if you re preparing for online python tests or college exams So with this syntax you can basically copy or clone a string So once again the square bracket brackets syntax works we can also use a similar syntax to extract a few characters instead of 1 character In this tutorial we re going to look at formatted strings in Python programming language Formatted strings are particularly useful in situations where you dynamically generate some text with your variables Let s say we want to print this on the terminal So I m going to run this program there you go This is what we get Jon Smith is a coder So to define formatted strings prefix your strings with an F and then use curly braces to dynamically insert values into your strings This is particularly useful when you receive input from the user Using this len function we can enforce a limit on the number of characters in an input field In this Python tutorial we will show you some really cool things you can do with Python strings When a function belongs to something else or is specific to some kind of object we refer to that function as a method In contrast len and print are general purpose functions they do n t belong to strings or numbers or other kinds of objects To access these functions we use the dot operator There are times that you want to check the existence of a character or sequence of characters in your string In those situations you use the in operator to check if this string contains the word python The in operator produces a boolean value and I get true or false The replace method is case sensitive so if you pass beginners all in lowercase this method is not going to find this exact word in our string We can use the len function to count the number of characters in a string this is the general purpose function built into python We also have specific functions for strings which we refer to as methods These include upper for converting a string into uppercase and lower and title methods You learn about the find method which returns the index of a character or sequence of characters augmented assignment operator is a way to write the same code but in a shorter form It s not about python programming language So all the other programming languages behave the same way The multiplication operator has a higher precendence which means …


View Full Document

Anna CS 123 - Python Tutorial

Course: Cs 123-
Pages: 3
Documents in this Course
Load more
Download Python Tutorial
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Python Tutorial and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Python Tutorial 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?