This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Write a program that asks the user how many Fibonnaci numbers to generate and | |
then generates them. Take this opportunity to think about how you can use | |
functions. Make sure to ask the user to enter the number of numbers in the | |
sequence to generate.(Hint: The Fibonnaci seqence is a sequence of numbers | |
where the next number in the sequence is the sum of the previous two numbers | |
in the sequence. The sequence looks like this: 1, 1, 2, 3, 5, 8, 13, …) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Write a program that takes a list of numbers (for example, | |
a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last | |
elements of the given list. For practice, write this code inside a function. | |
@author: Jeff Garcia | |
""" | |
userlist = input("Please enter a list of numbers separated by a single space:") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Ask the user for a number and determine whether the number is prime or not. | |
(For those who have forgotten, a prime number is a number that has | |
no divisors.). You can (and should!) use your answer to Exercise 4 to help you. | |
Take this opportunity to practice using functions, described below. | |
@author: Jeff Garcia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Author: Jeff Garcia | |
This week’s exercise is going to be revisiting an old exercise | |
(see Exercise 5), except require the solution in a different way. | |
Take two lists, say for example these two: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Fri Jul 28 13:11:24 2017 | |
@author: Jeff Garcia | |
Generate a random number between 1 and 9 (including 1 and 9). Ask the user to | |
guess the number, then tell them whether they guessed too low, too high, or | |
exactly right. (Hint: remember to use the user input lessons from the very |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Jul 27 15:15:31 2017 | |
@author: Jeff Garcia | |
Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays | |
(using input), compare them, print out a message of congratulations to the | |
winner, and ask if the players want to start a new game) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Jul 27 15:05:44 2017 | |
@author: Jeff Garcia | |
Let’s say I give you a list saved in a variable: | |
a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write one line of Python that | |
takes this list a and makes a new list that has only the even elements of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Jul 27 14:41:13 2017 | |
@author: Jeff Garcia | |
Take two lists, say for example these two: | |
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Jul 27 13:53:35 2017 | |
@author: Jeff Garcia | |
Create a program that asks the user for a number and then prints out a list of | |
all the divisors of that number. (If you don’t know what a divisor is, it is a | |
number that divides evenly into another number. For example, 13 is a divisor of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Jul 27 13:33:46 2017 | |
@author: Jeff Garcia | |
Take a list, say for example this one: | |
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] |