In [ ]:
# Write a function to add two to a number
pass


In [ ]:
# Write a function that multiples a number by three
def multiplyThree(x):
pass

multiplyThree(2)

multiplyThree(5)

multiplyThree(-1)

multiplyThree(15647186)

multiplyThree(15)

multiplyThree(-40)

In [ ]:
# Write a function that adds two numbers
pass


In [ ]:
# Write a function that concatenates two strings
def concatTwoStrings(x, y):
pass

concatTwoStrings('hello', 'world')

concatTwoStrings('hello ', 'world')

concatTwoStrings('mango ', 'pineapple')

concatTwoStrings('My name is ', 'Daniel!')
# answer: My name is Daniel!

concatTwoStrings('first string', ' second string')
# answer: first string second string

In [ ]:
# Write a function that returns the sum of the numbers in a list
def sumNumbersInList(x):
pass

sumNumbersInList([1, 2, 3])

sumNumbersInList([5, 1, 8, 10])

sumNumbersInList([4, 6, 7, 13, 19])

sumNumbersInList([-10, -7, -5, 1, 18])

sumNumbersInList([17, -5, -19, -13, 2])

sumNumbersInList([14, 9, -7, 15, -5])

sumNumbersInList([2, -20, 12, 20, 14])

sumNumbersInList([-2, -10, 19, 13, 12])

sumNumbersInList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18])

In [ ]:
# Write a function which:
# a) if the input is even, returns the input divided by two
# b) if the input is odd, returns the input times two
# The function should use an else statement
def evenOdd(x):
pass

evenOdd(2)

evenOdd(7)

evenOdd(5)

evenOdd(6)

evenOdd(-40)

evenOdd(-2)

evenOdd(-3)

In [ ]:
# Write a function that sums the numbers from 1 to x
# x will be positive
# Your function should use a loop
def sumFromOneToX(x):
pass

sumFromOneToX(5)

sumFromOneToX(50)

sumFromOneToX(15)

sumFromOneToX(3)

sumFromOneToX(50150)

In [ ]:
# Write a function which returns true if a list is in strictly increasing order and false otherwise
# Your function should use a loop
def isIncreasing(x):
pass

isIncreasing([1, 2, 3])

isIncreasing([1, 2, 2])

isIncreasing([0, 3, 6])

isIncreasing([0, 3, 6, 9])

isIncreasing([0, 3, 2, 9])

isIncreasing([1, -2, 3, 4])

In [ ]:
# Write a function that returns a list of all the multiples of three between 0 and the input x
# Your function should use a while loop
def multOfThree(x):
pass

multOfThree(3)

multOfThree(4)

multOfThree(6)

multOfThree(8)

multOfThree(9)
# answer: [0, 3, 6, 9]

multOfThree(30)
# answer: [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30]

In [ ]:
# Write a function which takes a number x and returns True if it is a prime and False otherwise
def isPrime(x):
pass

isPrime(0)

isPrime(1)

isPrime(2)

isPrime(3)

isPrime(4)

isPrime(5)

isPrime(67)

isPrime(80)

isPrime(1541)

isPrime(15749)

In [ ]:
# Write a function which takes a string and returns True if it is a palindrome and False otherwise.
# Your function should use a loop
def isStringPalindrome(x):
pass

isStringPalindrome('abcba')

isStringPalindrome('abcbac')

isStringPalindrome('1111111111')

isStringPalindrome('1112111111')

isStringPalindrome('rfjewafefawejfr')

isStringPalindrome('1112112111')

isStringPalindrome('1112112211')

In [ ]:
# Write a function which takes an integer and returns True if it is a palindrome and False otherwise.
# Can you reuse the code above?
def isNumPalindrome(x):
pass

isNumPalindrome(111)

isNumPalindrome(112)

isNumPalindrome(114564511)

isNumPalindrome(11454645411)

isNumPalindrome(48611684)

isNumPalindrome(48612684)

In [ ]:
# Write a function that sums the numbers from 0 to x, inclusive, if the number is divisible by 3 or 5
# For example, sum 3, 5, 6, 9, 10, 12, 15 for x=17
# Your function should use a loop.
# Your function should use the 'or' keyword.
def sumDivisibleThreeFive(x):
pass

sumDivisibleThreeFive(3)

sumDivisibleThreeFive(14)

sumDivisibleThreeFive(15)

sumDivisibleThreeFive(17)

sumDivisibleThreeFive(1548)

In [ ]:
# Write a function that returns a list of prime numbers from 0 to x, inclusive.
# Your function should use a loop
# Can you use some code above?
def primesToX(x):
pass

primesToX(2)

primesToX(10)
# answer: [2, 3, 5, 7]

primesToX(15)
# answer: [2, 3, 5, 7, 11, 13]

primesToX(100)
# answer: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

In [ ]:
# Write a function that returns the largest element in a list.
# Your function should use a loop
def largestInList(x):
pass

largestInList([1, 2, 3])

largestInList([3, 5, 2, 7, 5, 7])

largestInList([5, 7, 75, 78, 23, 73, 53])

largestInList([-69, -81, 1, -36, 90, 28, -82, -91, -37, -69])

largestInList([5, 2, -75, 76, -40, 0, 29, -41, 63, -40])

largestInList([68, 21, -13, -46, -64, 26, 17, 6, -42, 57])

largestInList([59, 32, -42, -49, -63, -21, -69, -36, 5, 41])

largestInList([9, 37, -2, 95, -75, 64, 63, 25, 91, -60])

largestInList([-129, -413, 793, -47, 609, 585, -843, 965, 294, 877])

In [ ]:
# Write a function that reverses a list.
def reverseList(x):
pass

reverseList([1, 2, 3])

reverseList([-4, 0, 3, 6, 9])
# answer: [9, 6, 3, 0, -4]

reverseList(['lists', 'can', 'have', 'multiple', 'types', True])
# answer: [True, 'types', 'multiple', 'have', 'can', 'lists']

reverseList([True, False, False, True])
# answer: [True, False, False, True]

reverseList(['hello', 123, False])

In [ ]:
# Write a function returns the elements in the odd positions of a list.
def oddPositionsInList(x):
pass

oddPositionsInList([1, 2, 3, 4, 5])

oddPositionsInList([1, 2, 3])

oddPositionsInList([1])

oddPositionsInList([8, -9, -3, -7, 6])

oddPositionsInList([-61, -15, 78, 41, 82, -62, -89, 19, 27, 3])
# answer: [-15, 41, -62, 19, 3]

In [ ]:
# Write a function that takes two lists and combines them in alternating order.
# e.g. [a,b,c], [1,2,3] → [a,1,b,2,c,3]
# The lists will be of the same size
def combineLists(x, y):
pass

combineLists(['a', 'b', 'c'], [1, 2, 3])
# answer: ['a', 1, 'b', 2, 'c', 3]

combineLists([1, 2, 3], [1, 2, 3])
# answer: [1, 1, 2, 2, 3, 3]

combineLists([3, 2, 1], [1, 2, 3])
# answer: [3, 1, 2, 2, 1, 3]

combineLists(['hello', 'pineapple', 'mango', 'strawberry'], [4, 7, 3, 5])
# answer: ['hello', 4, 'pineapple', 7, 'mango', 3, 'strawberry', 5]

In [ ]:
# Write a function that takes a string of length 1 and:
# a) Returns True if it is a vowel
# b) Returns False if it is a consonant
def isVowel(x):
pass

isVowel('a')

isVowel('c')

isVowel('d')

isVowel('o')

isVowel('e')

isVowel('p')

isVowel('i')

isVowel('w')

isVowel('u')

In [ ]:
# Write a function which takes two lists and:
# a) Returns True if any element of one list is in the other
# b) Returns False otherwise
def overlaps(x, y):
pass

overlaps([1, 2, 3], [4, 5, 6])

overlaps([1, 2, 3], [1, 5, 6])

overlaps([-26, -46, -56, 8, -70, -89, -29, -84, -44, -83], [1, 5, 6])

overlaps([-37, -58, 91, -51, 79, -87, 44, 97, 59, -78], [17, -87, 31, 52, -23, 93, 69, 91, 97, -64])

overlaps(['hello', 'pineapple'], ['mango', 'strawberry'])

overlaps(['hello', 'pineapple'], ['mango', 'strawberry', 'mango'])

overlaps(['hello', 'pineapple', 'mango'], ['mango', 'strawberry', 'mango'])

In [ ]:
# Write a function that takes a list of strings and returns the longest string in the list
# If multiple strings are the longest, return the first one.
def longestString(x):
pass

longestString(['a', 'ab', 'abc'])