myString="MIKE"
print "The pointer variable's value is: ", id(myString)
print "The pointer variable points to: ",myString
print "The memory locations for each character are::"
for x in range(0,4):
print id(myString[x]),
color=raw_input("Enter your favorite color: ")
print "You entered: ",color
color=raw_input("Enter your favorite color: ")
print "You entered: ",color
names = []
names.append("Michael")
names.append("Sheila")
names.append("Spencer")
names.append("Hunter")
names.append("Kenya")
print "\nNames in pointer array of type char:\n"
for i in range(5):
print names[i]
colors = []
print "Enter 3 colors: "
for i in range(3):
colors.append(raw_input())
print "Your entered: "
for i in range(3):
print colors[i]
str1="123.79"
str2="55"
print "String1 is:\"",str1,"\""
print "String2 is:\"",str2,"\""
x=float(str1)
y=int(str2)
print "String 1 converted to a float is ",round(x,2)
print "String 2 converted to an integer is ",y
str1="37"
str2="20"
print "String1 + String2 is ", str1+str2
str1="37"
str2="20"
iResult=int(str1)+int(str2)
print "String1 + String2 is ", iResult
str1="Michael"
str2="Vine"
print "The length of string1 is ",len(str1)
print "The length of string2 is ",len(str2)
def convertL(char):
char=char.lower()
print "The first name converted to lower case is: ",char
def convertU(char):
char=char.upper()
print "The first name converted to Upper case is: ",char
name1="Michael"
name2="Vine"
convertL(name1)
convertU(name2)
str2="C Language"
str1=str2
print "String 1 now contains ", str1
str1="Computer Science "
str2="is applied mathematics"
print str1+str2
str1="A"
str2="A"
str3="!"
print str1
print str2
print str3
if str1==str2:
print "Letter A is equal to letter A"
if str1>str3:
print "Letter A is greater than character !"
if str3<str1:
print "Character ! is greater than letter A"
str1="Analyzing strings with with the strstr() function"
str2="ing"
str3="xyz"
print str1
print str2
print str3
if((str1.find(str2))!=-1):
print "Str2 was found in str1"
else:
print "Str2 was not found in str1"
if((str1.find(str3))!=-1):
print "Str3 was found in str1"
else:
print "Str3 was not found in str1"
import time
import os
from array import array
def checkAnswer(string1,string2):
for x in range(len(string2)):
string2=string2.upper()
if(set(string2).intersection(string1.split())):
print "Great job"
else :
print "Sorry no word found..."
starGame=[]
starGame.append("ADELANGUAGEFERVZOPIBMOU")
starGame.append("ZBPOINTERSKLMLOOPMNOCOT")
starGame.append("PODSTRINGGDIWHIEEICERLS")
starGame.append("YVCPROGRAMMERWQKNULTHMD")
starGame.append("UKUNIXFIMWXIZEQZINPUTEX")
displayed=0
startTime=0
os.system('cls')
print "word find"
startTime=int(round(time.time()*1000))
for x in range(0,5):
while ((startTime+3)>int(round(time.time()*1000))):
if displayed==0:
print "find a word in:"
print "",starGame[x]
displayed=1
os.system('cls')
answer=raw_input("Enter word found:")
checkAnswer(starGame[x],answer)
displayed=0
startTime=int(round(time.time()*1000))