Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)

Similar presentations


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

1 Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)

2 - 2 - Objectives Using Letters and Numbers Together How To Use The Print() Function From Befor Writing and Saving With IDLE Running Programs With IDLE Questions & Answers

3 - 3 - Follow Up We set up Python We went over arithmetic operations in python –+ meaning to add two numbers – - meaning to subtract two numbers –* meaning to multiply two numbers – / meaning to divide two numbers and give back a float / decimal answer –// meaning to divide two numbers and round down the answer giving us an integer –** is the symbol for exponents, not ^ THIS IS SOMETHING ELSE WELL GET IN TO LATER! We learnt the difference of an int and a float, int meaning no decimal places and float meaning that it has decimal places

4 - 4 - Strings A ‘string' is simply a list of characters in order. A character is anything you can type on the keyboard in one keystroke, like a letter, a number, or a backslash. For example, “Hello, my name is Jeff!” all of the letters like H, e, l, l, 0, … are ‘strung” together to form a string. Ok how can I write a “String” and use it in python?

5 - 5 - Defining/Writing a String There are 3 ways of defining/writing a string, –1. ‘I am a string‘ –2. “I am a string” –3. “””I am a string””” These practically mean the same thing, but later we’ll discus the differences and how we’ll use them. Everything inside of the quotations is the string, the quotations wont be interpreted as a string.

6 - 6 - Using Strings First try typing hello into the command line and see what the out put is. If all goes to plan you’ll get an error. That is because hello is not defined in python as anything so the only thing python knows what to do with it is to just throw out an error, Now try typing ‘hello’ with the quotation thingies in front of and behind the word your trying to type out. You’ll get a response from python telling you that it understood what was trying to be done and it prints out ‘hello’ with no issues.

7 - 7 - String Examples Try to predict the out put of each string when we type them in –“test” –‘Hello, World!’ –“I am 4 years old” –‘I Like to cause errors” –“4” –‘2 + 2’

8 - 8 - Printing Out In python there is a built in function called print(). Print() is the command that allows you to display text on to the command line. The Print() command is called a function, and I’ll be getting into later what a function is, and we’ll get to writing out own functions just like the print() function; In this lecture I won’t be explaining how it works, I’ll just show you how to use it.

9 - 9 - Print() Use Ok so how to we use a print(), first of all you could just type print() in the command line, and it will do something. Lets say you want to do more. The print() function allows for data to be put in side of it, like a String, or an Int, or a Float. All of these work –print(‘I am a string’) –print(12) –print(3.141592653589793266) All of those work

10 - 10 - Printing Examples Try and guess the out puts of each print function –print(“Hello, World!”) –print(123) –print(“I am 4 Years Old”) –print(“2 + 2”) –print(2 + 2)

11 - 11 - Creating and Saving IDLE Files First of all we have to make a program file. First click FILE at the top of the page, and select NEW FILE. You will see a window appear. In this window you can type stuff in it. Now go to File again and press save, save it to your desktop FOR NOW! (later I’ll show you how to structure saving your files) now if you go to your desktop. Now if you have done all of that successfully close your IDLE and double click your test.py File and you should a window appear and disappear. This is good. Tell me if that doesn’t happen to you.

12 - 12 - Running Python With IDLE Once you have saved your file, click RUN and then click run module. You should see an error in the IDLE power shell. Now erase everything inside that window and type 2 + 2; You should see nothing when you save it and run it. That is because IDLE behaves differently with python then the command line. You must write a print statement when you want to display text on the power shell!

13 - 13 - That’s all Now you should be String and IDLE professionals

14 - 14 - Questions & Answers

15 © 2014 Chris Trenkov


Download ppt "Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 17, 2015)"

Similar presentations


Ads by Google