Scroll to see replies
import string
def getAvailableLetters(lettersGuessed):
'''lettersGuessed: list, what letters have been guessed so far returns: string,
comprised of letters that represents what letters have not yet been guessed. '''
# FILL IN YOUR CODE HERE...
alphabet = (string.ascii_lowercase)
print(alphabet)
listAlphabet = list(alphabet)
print(listAlphabet)
''' how do i make lines 17 to 19 into a list comprehension'''
for char in listAlphabet[:]:
if char in lettersGuessed:
del(listAlphabet[listAlphabet.index(char)])
lst = [del (listAlphabet[listAlphabet.index(char)) if char in lettersGuessed for char in listAlphabet[:]]
return (''.join(listAlphabet))
lettersGuessed = ['e', 'i', 'k', 'p', 'r', 's']
print(getAvailableLetters(lettersGuessed))
import string
def getAvailableLetters(lettersGuessed):
for char in listAlphabet[:]:
if char in lettersGuessed:
del(listAlphabet[listAlphabet.index(char)])
lst = [del (listAlphabet[listAlphabet.index(char)) if char in lettersGuessed for char in listAlphabet[:]]
my_list = [1,2,3,4,5,6]
foo = [str(x)]
print(' '.join(foo))
listAlphabet = "abcdefghijklmnopqrstuvwxyz"
lettersGuessed = "fmqepb"
lst = [char for char in listAlphabet if char not in lettersGuessed]
print(' '.join(lst))
my_list = [1,2,3,4,5,6]
foo = [str(x)]
print(' '.join(foo))
listAlphabet = "abcdefghijklmnopqrstuvwxyz"
lettersGuessed = "fmqepb"
lst = [char for char in listAlphabet if char not in lettersGuessed]
print(' '.join(lst))
x = 3
WHILE x < 3 DO
PRINT x
x = x + 1
END WHILE
PRINT x
x = 3
LABEL: "BEGIN_WHILE"
IF x < 3 THEN
PRINT x
x = x + 1
GOTO "BEGIN_WHILE"
PRINT x
def fibonacci(n):
if n == 0 or n == 1:
return 1
else:
return fibonacci(n-2) + fibonacci(n-1)
print(fibonacci(5))
def fibonacci0():
return 1 # The first number in the sequence is always 1
def fibonacci1():
return 1 # the second number in the sequence is always 1
def fibonacci2():
return fibonacci0() + fibonacci1()
def fibonacci3():
return fibonacci1() + fibonacci2()
def fibonacci4():
return fibonacci2() + fibonacci3()
def fibonacci5():
return fibonacci3() + fibonacci4()
print(fibonacci5())
•
fibonacci(2) returns the result of fibonacci(0)+fibonacci(1) which is 1+1=2.
•
fibonacci(3) returns the result of fibonacci(1)+fibonacci(2) which is 1+2=3.
•
fibonacci(4) returns the result of fibonacci(2)+fibonacci(3) which is 2+3=5.
•
fibonacci(5) returns the result of fibonacci(3)+fibonacci(4) which is 3+5=8.
Last reply 1 day ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 2 days ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 2 weeks ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 4 weeks ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]Last reply 1 day ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 2 days ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 2 weeks ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 4 weeks ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]