lab 4 - elif score<60 print"F" s1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
# Lab 4 #### import math import random i = False or True print (i) a = True and False print (a) b = not (True and False) print (b) c = (not True) and (not False) print (c) d = 4<5 and 4>3 print (d) def calGPA(score): if score>= 90: print ("A") if score>=80 and score <90: print ("B") if score>= 70 and score <80: print ("C") if score>= 60 and score <70: print ("D") if score<60: print ("F") def calGPA2 (score): if score>= 90: print ("A") elif score>=80 and score <90: print ("B") elif score>= 70 and score <80: print ("C") elif score>= 60 and score <70: print ("D")
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: elif score<60: print ("F") s1 = "Franklin and Marshall" s2 = " College" print (s1[:8]) print (s1[8:12]) print (s1[12:21]) print (s1+s2) s = s1 + ''+s2 if "ank" in s: print ('yes') else: print ('no') for i in range (len(s)): print (s[0:i]) print (s.upper()) print (s.lower()) print (s.replace(and, &)) def montePi (numDarts): inCircle = 0 for i in range (numDarts): x=random.random() y=random.random() d = math.sqrt (x**2 + y**2) if d <=1: inCircle = inCircle +1 pi = inCircle/numDarts * 4 return pi...
View Full Document

This note was uploaded on 04/26/2011 for the course CPS 324 taught by Professor Safa during the Spring '11 term at Dickinson.

Page1 / 2

lab 4 - elif score<60 print"F" s1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online