Skip to content

Instantly share code, notes, and snippets.

@jervislam0911
jervislam0911 / dlAttachments.py
Created November 6, 2017 02:05 — forked from baali/dlAttachments.py
Python script to download all gmail attachments.
# 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 = '.'
@jervislam0911
jervislam0911 / dlAttachments.py
Created November 6, 2017 02:05 — forked from baali/dlAttachments.py
Python script to download all gmail attachments.
# 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 = '.'
# 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)
# 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__":
# 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
# 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