CIS222 Notes 1 PDF

Title CIS222 Notes 1
Author Josiane Hibbs
Course Computer Scripting
Institution Fullerton College
Pages 2
File Size 27.1 KB
File Type PDF
Total Downloads 31
Total Views 141

Summary

Class notes for first session...


Description

CIS 222 F Lecture 190905 Python2 accepts print "hello world" Python3 must be print("hello world") Python2 does integer division by default with two integer arguments Python3 does floating point division, use // operator for integer division runtime error syntactically correct but fails at runtime logic error syntactically correct but not what is logically intended when typing an incomplete statement, such as print(3, into a python shell, it will display ... for you to complete the statement #! is called a (ha)sh bang good practice to type a sh bang like "#!/usr/bin/env python3" without the start/end quotation symbols so Linux can use it better # is the comment sign for Python A function is a reusable chunk of code print(1, 2, 3, 4, 5) print("The answer is", 5) will print multiple things separated by a space x = "Hello" 2*x #will evaluate to HelloHello a1 = 17 A1 = 32 a1 is not the same as A2 (Python is case sensitive) some operators + * / // integer division % ** exponent Precedence ** * / // % + -

High Low

escape characters \n new line \t tab \r return \" " \' '

\\

\

print(1,2,3,4,5,sep="|") makes | the separater instead of a space prints 1|2|3|4|5 print(1,2,3,4,5,sep="|",end=" cha,cha,cha\n") 1|2|3|4|5 cha,cha,cha name = input("What is your name? ") console prompts user with "What is your name? " and waits for input which is then stored into name cost = float(input("What is your meal cost? ")) print("Tax is", cost * 0.0775) count = 1 while count < 10 : print(count) count = count + 1 logical operators < > == = != and or for foo in range(5) : print(foo) # prints 0 to 4, exit on 5 for foo in range(1, 5, 2) : print(foo) # prints 1, 3 # start at 1, increment by 2 until 5 is reached for foo in range(5, 1, -1) : print(foo) # prints 5, 4, 3, 2...


Similar Free PDFs