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
f1 = 1 | |
f2 = 1 | |
term = 2 | |
while True: | |
temp = f1 | |
f1 = f2 | |
f2 = temp + f2 | |
term += 1 | |
if(len(str(f2)) == 1000): | |
print term , " : " , f2 |
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
INSTALLED_APPS = ( | |
'django.contrib.admin', | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'converters', | |
) |
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
from django.conf.urls import patterns, include, url | |
from django.contrib import admin | |
urlpatterns = patterns('', | |
url(r'^$', 'converters.views.index', name='index'), | |
url(r'^admin/', include(admin.site.urls)), | |
) |
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
from django import forms | |
class UploadForm(forms.Form): | |
image = forms.ImageField(); |
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
from django.shortcuts import render | |
from django.http import HttpResponse | |
from PIL import Image | |
from converters.forms import UploadForm | |
def index(request): | |
form = UploadForm(request.POST, request.FILES) | |
if form.is_valid(): | |
grey(request.FILES['image']) |
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
TEMPLATE_DIRS = ( | |
os.path.join(BASE_DIR, 'templates'), | |
) |
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
<h1>Hello, upload a file and I will turn it grey</h1> | |
<form method="POST" action="" enctype="multipart/form-data"> | |
{{ form.as_p }} | |
<input type='submit' value='Upload'/> | |
</form> |
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
import math | |
print "Enter a number and I will print out that many decimal places of PI." | |
places = int(raw_input('>')) | |
print str(math.pi)[:places+2] |
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
import math | |
print "Enter a number and I will print that many decimal places of e" | |
places = int(raw_input('>')) | |
print str(math.e)[:places+2] |
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
from __future__ import division | |
from decimal import * | |
print "Enter a number and I will print out that many decimal places of PI." | |
places = int(raw_input('>')) | |
getcontext().prec = places | |
pi = 0 |