Belen Comp OCR
Belen Comp OCR
Belen Comp OCR
print(“Hello World')
#1b
print('Pleased to meet you')
#1c
print('This is\na computer program\nthat prints on several lines')
#2a
name='Bob'
print('Hello '+name)
#2b
language='Python'
print('I am learning to program in '+language)
#2c
word1=' the'
word2=' cat'
word3=' sat'
word4=' on'
word5=' mat'
print(word1+ +word2+ +word3+ +word4+ word1 +word5)
#3a
city=input('Where do you live?')
print('I love visiting '+city)
#3b
firstname=input('What is your first name?')
lastname=input('What is your last name?')
print('Hello '+firstname+' '+lastname)
#3c
print(name)
#Task 4a
print(1+6)
print(7-5)
print(3*9)
print(7/2)
#Task 4b
print(4+5)
print(2-1)
print(6*3)
print(8/4)
#4c
a=7
b=8
c=a+b
print(b)
#5a
a = int(input('Enter your first number:'))
b = int(input('Enter your second number:'))
c=a+b
print('Adding your numbers together makes:'+str(c))
#5b
width=int(input('Please enter the width: '))
height=int(input('Please enter the height: '))
area=width*height
print('The area is: '+str(area))
#5c
volume=pi*radius*radius*height
volume=round(volume,2
area=2*pi*radius*radius+2*pi*radius*height
area = round(area,2)
#6a
city=input('What is the capital of England?')
if city== 'London':
print('Correct')
elif city=='Cardiff':
print('Wrong’))
elif city=='L':
print('No.')
else:
print(‘incorrect’)
#6b
#6c
mark=int(input('Enter the mark'))
if(mark>=70):
print('Grade A')
elif(mark>=60):
print('Grade B')
elif(mark>=50):
print('Grade C')
elif(mark>=40):
print('Grade D')
else:
print('Grade U')
#8a
for i in range(0,15):
print('computing')
#8b
let=input('Please enter a letter: ')
num=int(input('Enter how many time you want me to print it: '))
output=""
for i in range(0,num):
output=output+let
print(output)
#8c
num=int(input('Enter number of the times table you want: '))
for i in range(1,11):
print(str(i)+" times "+str(num)+" is "+str(i*num))
import random
#9a
password=""
while password!="apple":
password=input('Enter a password: ')
#9b
count=1
while (count*count)<5000:
print(count*count)
count=count+1
#9c
num=random.randint(1,100)
guess=int(input('I am thinking of a number between 1 and 100. What do you think it is?'))
attempts=1
while guess!=num:
if num<guess:
guess=int(input('No, lower than '+str(guess)+".What do you think it is? "))
else:
guess=int(input('No, higher than '+str(guess)+". What do you think it is? "))
attempts=attempts+1
print('Well done the number was '+str(num)+'. You got it in '+str(attempts)+' gueses.')
import random
#11a
names=[]
entry=""
count=0
while entry!="END":
entry=input("Please enter a name:")
names.append(entry)
count=count+1
#11b
names=[]
for i in range(0,5):
names.append(input("Please enter a name: "))
x=random.randint(0,4)
#12a
sentence = 'The cat sat on the mat.'
for letter in sentence:
print(letter)
#12b
sentence = 'The cat sat on the mat.'
count=0
for letter in sentence:
if letter=='a':
count=count+1