Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)

Similar presentations


Presentation on theme: "Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)"— Presentation transcript:

1 Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)

2 - 2 - Objectives Review, review, review, review, review, review; REVIEW Review on world politics, and the effects on the French economy after world war 2 Review on everything we have learned There will be more review after the review Questions & Answers

3 - 3 - IDLE IDLE, is what’s used to code python, its called IDLE just incase you seemed to of forgotten, It is better than the command line in every way, this is what were using. IDLE. IDLE has 2 modes, one mode is the command line mode. It works just the same as the command line, but is white and has color; the other mode is for writing multi lined programs and saving them. Please never make me have to open IDLE for you again.

4 - 4 - Everything we know so far These are the things we all should know by now, but we will be going over them with small practices, and less images Data types Arithmetic stuff Variables Boolean type operators If statements Else statements Functions

5 - 5 - Data types Data type is anything that is represented as a values in Python 10 – int 10.1 – float / double (not really though (but that is for a nother lesson) ) “I am word” – string True - boolean

6 - 6 - Small exercise Can you name these data types “10.1” 22.0 True “False” -123

7 - 7 - Converting data types In python you can convert data types to each other here are the example conversion types str() – converts anything to a string int() – converts anything to an integer float() – converts anything to a float bool() – converts anything to a boolean

8 - 8 - Fun exarcises Here are some intuitive conversions str(12) int(7.5) float(7) int(“-12”) Here are some not so intuitive, try to guess them str(False) Int(True) float(false) bool(0) bool(1) bool(1337)

9 - 9 - Arithmetic This is a simple one + adds two numbers/strings - subtracts two numbers * multiplies two numbers / divides two numbers and will give decamle ** is an exponent like 2 ^ 2 but with two stars like 2 ** 2 // is divide also but it gives back an integer

10 - 10 - Comparative type operators Comparative types operators are just like Arithmetic type operators but with booleans == equals - if both values are the same it returns true <= less than or equal to – compares if the integer in front is less than the second one >= greater than or equal to – compares if the integer in front is more than the second one;

11 - 11 - Comparative type operators 2 Comparative types operators are just like Arithmetic type operators but with booleans and And: if both booleans are true it returns true Or Or – if at least one of the booleans are true it returns True, other wise its false

12 - 12 - If statements If statements allow for logic In your code, it takes three steps to write an if statement 1 type if 2 put parentheses after the if like if() 3 put a colon after it if(): That’s all it takes to write an if statement, now all you have to do is fill it up with a boolean in the middle

13 - 13 - Example if All of these ifs have a boolean inside of it Tell them to type it in their IDLE

14 - 14 - Write your own if Write an if that compares if 10 is less than 10.1 and if 1 equals to 1

15 - 15 - Ifs I hope yall are good with if statements now, Any questions, if no one says anything and say your good, you better never ask me a question again, and go to MIT to graduate right now with a comp sci degree in Python analitics(I am just kidding of Course)

16 - 16 - One Input for functions When you define a function, inside the brackets, you can tell python you want an input by giving it a new variable to use. like

17 - 17 - When you define an input As you can see, at the top of the function, specified to python that this function requires one input, (name). This variable is only visible inside the function.

18 - 18 - Defining multiple inputs Obviously in python you can define multiple inputs, but to do that all you have to do is create more variables and separate them with commas, and when you use them you call them you give the required inputs to run the function

19 - 19 - Lets make an adding function Even though this function will be useless in real world applications, it is still good practice. First we define our function and call it like addSum() or something, then we define 2 inputs, them inside the function, we add them together and store it into a variable, then we print the variable!

20 - 20 - Out puts Lets say you want your function to give you a number as an output, instead of printing every thing. All you have to do is type return and give it a variable to return like

21 - 21 - Did it do anything? If you typed that out and compiled it, you'll see that nothing “appeared” to of happened. Well something did happen you just can’t see it. When you called the function it returned a number for your to use, all you have to do to get that number is to set it equal to a variable, as you can see it is now treated as a number

22 - 22 - Seriously????!!?!?!? Are there any questions, or concerns, would you like me too explain something again, This is the most fundamental part of programming, and is what allows you to do some really awesome things later down the line

23 - 23 - Questions & Answers

24 © 2014 Chris Trenkov


Download ppt "Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)"

Similar presentations


Ads by Google