IS340 Class Notes PDF
IS340 Class Notes PDF
# - Declaring variables =
#================================================================
numStudents = 40
myName = input()
myAge_integer = int(myAge_string)
Score1 = 99
Score2 = 86
Score3 = 72
print( type(AverageScore) )
print("Hello\nWorld\n\n\nGoodbye")
#=============================================================
import datetime
currentTime = datetime.datetime.now()
print(currentTime.year)
import calendar
#===================================================
import math
print( math.pi )
print(f"{math.pi:.5f} ")
valA = 3
valB = 5
result = math.pow(valA, valB) # moduleName.methodName()
print(f"result is {result} \n\n\n\n\n")
#===================================================
# Random Number Demo
#
import random
print(random.random()) # moduleName.methodName()
for i in range(5):
dice1 = random.randint(1, 6) # generates 1 thru 6
dice2 = random.randrange(1, 7) # Also generates 1 thru 6
print("You rolled a ", dice1 + dice2 )
#===============================================================
====
# turtle is a module with tools for drawing graphics on the
screen
#
import turtle
turtle.bgcolor("black")
pencil = turtle.Turtle()
pencil.speed(20)
pencil.pencolor("red")
pencil.pencolor("yellow")
#=================================================
# Python also has built-in Modules that are ALWAYS imported
automatically.
# These provide functionality for Strings, Integers and other
data types.
# In the example below, we are using string methods, but notice
that we
# did not import a String module.
#
print( phrase )
print( phrase.upper() ) # .upper() is a String method
print( phrase.title() ) # .title() is a String method
print("Num Characters = ", len(phrase)) # .len() works on
Strings and other data types
#========================================================
#—————————————————————————————
# LISTS OF STRINGS
print(friends)
boys.append("Lee")
girls.remove("Monica")
print(newFriends[4])
print(min(newFriends))
print(max(newFriends))
#—————————————————————————————
# A LIST OF NUMBERS
nums = [12, 56, 82, 9, 15, 53, 42, 21, 8]
nums.append(newNum)
print(nums)
print(nums)
#—————————————————————————-------------————-
print( len(student) )
print( student[0] )
print( student[1] )
print( student[2] )
print( student[3] )
#—————————————————————————————
# STRING METHODS
print(newString)
anotherString = newString.upper()
print(anotherString)
anotherString2 = newString.lower()
print(anotherString2)
# CONCATENATING STRINGS
print(myString)
print(myString2)
print(newString)
print("Num Characters = ", len(myString) )
print(len(myString))
print(myString[8])
print(min(myString))
print(max(myString))
#—————————————————————————————
score1 = 75
score2 = 88
score3 = 99
totalScore += score3
#—————————————————————
# USING A DICTIONARY
# KEY : VALUE
tvChannels = { "CBS" : 2,
"NBC" : 4,
"ABC" : 7,
"FOX" : 11 }
"oranges" : ".50",
"grapes" : ".65",
"bananas" : ".85" }
print(prices)
print(prices)
#—————————————————————————————
# TESTING DATA WITH if - elif
print("Just a Kid!")
print("Go to school")
print("In College")
else:
if x:
print(x)
else:
print("zero")
print("Goodbye")
#==========================================================
Balance = 100.00
amt = 0.00
print("\nD - Deposit")
print("W - Withdrawl")
print("Q - Quit")
if choice not in ['B', 'W', 'D', 'Q']: # Did the User enter a valid
choice ?
loopAgain = False
Balance += amt
if Balance > 0:
else:
Balance -= amt
print("Goodbye")
#===================================================================
#===================================================================
#######################################################
#######################################################
print(f"\t({x},{y})")
###################################################
###################################################
x = 0
while x < 5 :
print("X is ", x)
x += 1
else:
###########################################
###########################################
initial_savings = 10000
interest_rate = 0.05
savings = initial_savings
for i in range(years):
#=============================================
#=============================================
import random
import time
"maybe later"]
def main():
for x in range(10):
person2 = person1
say2(person2, someIdea)
say3(person1, reply[random.randrange(5) ])
print("\n")
time.sleep(.75)
################################################
################################################
def newFile():
def openFile():
def saveFile():
###############################################
###############################################
def myFunction(someData):
#########################################
#########################################
return (x + y + z) / 3
###################################################
###################################################
return 0,0
for x in range(3):