This file contains hidden or 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
| # Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail | |
| # Make sure you have IMAP enabled in your gmail settings. | |
| # Right now it won't download same file name twice even if their contents are different. | |
| import email | |
| import getpass, imaplib | |
| import os | |
| import sys | |
| detach_dir = '.' |
This file contains hidden or 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
| # Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail | |
| # Make sure you have IMAP enabled in your gmail settings. | |
| # Right now it won't download same file name twice even if their contents are different. | |
| import email | |
| import getpass, imaplib | |
| import os | |
| import sys | |
| detach_dir = '.' |
This file contains hidden or 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
| # 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 26 because 26 / 13 has no remainder.) | |
| def divisor(new_list, number): | |
| return [item for item in new_list if number % item == 0] | |
| if __name__ == "__main__": | |
| my_list = range(2, 11) |
This file contains hidden or 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
| # Take a list, say for example this one: | |
| # | |
| # a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] | |
| # and write a program that prints out all the elements of the list that are less than 5. | |
| def list_check(new_list, number): | |
| return [item for item in new_list if item < number] | |
| if __name__ == "__main__": |
This file contains hidden or 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
| # Ask the user for a number. Depending on whether the number is even or odd, | |
| # print out an appropriate message to the user. | |
| # Hint: how does an even / odd number react differently when divided by 2? | |
| def is_odd(number): | |
| if number % 2 == 0: | |
| return False | |
| return True |
This file contains hidden or 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
| # Create a program that asks the user to enter their name and their age. | |
| # Print out a message addressed to them that tells them the year that they will turn 100 years old. | |
| from datetime import date | |
| def calculate(current_age): | |
| year = date.today().year + (100 - current_age) | |
| return year |