code
stringlengths
1
1.72M
language
stringclasses
1 value
from sys import stdin n = int(stdin.readline().strip()) print "%.3lf" % sum([1.0/x for x in range(1,n+1)])
Python
from sys import stdin print len(stdin.readline().strip())
Python
from itertools import product from math import * def issqrt(n): s = int(floor(sqrt(n))) return s*s == n aabb = [a*1100+b*11 for a,b in product(range(1,10),range(10))] print ' '.join(map(str, filter(issqrt, aabb)))
Python
from sys import stdin a = map(int, stdin.readline().strip().split()) print "%d %d %.3lf" % (min(a), max(a), float(sum(a)) / len(a))
Python
from sys import stdin def cycle(n): if n == 1: return 0 elif n % 2 == 1: return cycle(n*3+1) + 1 else: return cycle(n/2) + 1 n = int(stdin.readline().strip()) print cycle(n)
Python
from sys import stdin n = int(stdin.readline().strip()) count = n*2-1 for i in range(n): print ' '*i + '#'*count count -= 2
Python
for abc in range(123, 329): big = str(abc) + str(abc*2) + str(abc*3) if(''.join(sorted(big)) == '123456789'): print abc, abc*2, abc*3
Python
from sys import stdin n, m = map(int, stdin.readline().strip().split()) print "%.5lf" % sum([1.0/i/i for i in range(n,m+1)])
Python
from sys import stdin data = map(int, stdin.readline().strip().split()) n, m = data[0], data[-1] data = data[1:-1] print len(filter(lambda x: x < m, data))
Python
from sys import stdin def solve(a, b, c): for i in range(10, 101): if i % 3 == a and i % 5 == b and i % 7 == c: print i return print 'No answer' a, b, c = map(int, stdin.readline().strip().split()) solve(a, b, c)
Python
from itertools import product sol = [a*100+b*10+c for a,b,c in product(range(1,10), range(10), range(10)) if a**3+b**3+c**3 == a*100+b*10+c] print '\n'.join(map(str, sol))
Python
from sys import stdin from math import * n = int(stdin.readline().strip()) print sum(map(factorial, range(1,n+1))) % (10**6)
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) 2011 by Alessandro Presta # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the...
Python
#!/usr/bin/env python # Copyright (C) 2011 by Alessandro Presta # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, ...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) 2011 by Alessandro Presta # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the...
Python
# Copyright (C) 2011 by Alessandro Presta # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish,...
Python
#!/usr/bin/env python # Copyright (C) 2011 by Alessandro Presta # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, ...
Python
# -*- coding: utf8 -*- from fuzzywuzzy import fuzz from fuzzywuzzy import process from fuzzywuzzy import utils import itertools import unittest class UtilsTest(unittest.TestCase): def setUp(self): self.s1 = "new york mets" self.s1a = "new york mets" self.s2 = "new YORK mets" self....
Python
import string bad_chars='' for i in range(128,256): bad_chars+=chr(i) table_from=string.punctuation+string.ascii_uppercase table_to=' '*len(string.punctuation)+string.ascii_lowercase trans_table=string.maketrans(table_from, table_to) def asciionly(s): return s.translate(None, bad_chars) # remove non-ASCII c...
Python
#!/usr/bin/env python # encoding: utf-8 """ process.py Copyright (c) 2011 Adam Cohen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights t...
Python
#!/usr/bin/env python # encoding: utf-8 """ score.py Copyright (c) 2011 Adam Cohen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to ...
Python
#!/usr/bin/env python # encoding: utf-8 """ StringMatcher.py ported from python-Levenshtein [https://github.com/miohtama/python-Levenshtein] """ from Levenshtein import * from warnings import warn class StringMatcher: """A SequenceMatcher-like class built on the top of Levenshtein""" def _reset_cache(self):...
Python
#!/usr/bin/env python # encoding: utf-8 """ process.py Copyright (c) 2011 Adam Cohen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights t...
Python
#!/usr/bin/env python # encoding: utf-8 """ StringMatcher.py ported from python-Levenshtein [https://github.com/miohtama/python-Levenshtein] """ from Levenshtein import * from warnings import warn class StringMatcher: """A SequenceMatcher-like class built on the top of Levenshtein""" def _reset_cache(self):...
Python
#!/usr/bin/env python # encoding: utf-8 """ score.py Copyright (c) 2011 Adam Cohen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to ...
Python
from distutils.core import setup setup(name='fuzzywuzzy', version='0.1', description='Fuzzy string matching in python', author='Adam Cohen', author_email='adam@seatgeek.com', url='https://github.com/seatgeek/fuzzywuzzy/', packages=['fuzzywuzzy'])
Python
# -*- coding: utf8 -*- from timeit import timeit from fuzzywuzzy import utils iterations=100000 cirque_strings = [ "cirque du soleil - zarkana - las vegas", "cirque du soleil ", "cirque du soleil las vegas", "zarkana las vegas", "las vegas cirque du soleil at the bellagio", "zarakana - cirque...
Python
#!/opt/ActivePython-2.7/bin/python ##################################################################################################### # Nicholas Harner # CSE411 # Homework 7 # 11/19/2012 # This program is an exact mimic of Coelacanth: a simple password generator. It is a very simple # application for ...
Python
#!/usr/bin/python # Sean Hill # Fall 2012 # CSE 411 # Homework 7 # # Description: Translates the image segmentation code from the following website from C++ to Python: # http://www.cs.brown.edu/~pff/segment/ # # Instructions: The command-line usage is as follows, where "sigma" and "k" and "min" are # algori...
Python
#! /usr/bin/python from optparse import OptionParser import os.path import sys parser = OptionParser() parser.add_option("-L", "--line", dest="stripLine", action="store_true", default=False, help="strip single-line comments //...\\n") parser.add_option("-C", "--cstyle", dest="s...
Python
#!/opt/ActivePython-2.7/bin/python ##################################################################################################### # Nicholas Harner # CSE411 # Homework 7 # 11/19/2012 # This program is an exact mimic of Coelacanth: a simple password generator. It is a very simple # application for ...
Python
#!/usr/bin/python # Sean Hill # Fall 2012 # CSE 411 # Homework 7 # # Description: Translates the image segmentation code from the following website from C++ to Python: # http://www.cs.brown.edu/~pff/segment/ # # Instructions: The command-line usage is as follows, where "sigma" and "k" and "min" are # algori...
Python
#! /usr/bin/python from optparse import OptionParser import os.path import sys parser = OptionParser() parser.add_option("-L", "--line", dest="stripLine", action="store_true", default=False, help="strip single-line comments //...\\n") parser.add_option("-C", "--cstyle", dest="s...
Python
#!/opt/ActivePython-2.7/bin/python # Sequence Creation # Create a sequence comparision based on user input or file reading from Tkinter import * class Application(Frame): """ GUI application that creates based on user input. """ def __init__(self, master): Frame.__init__(self, master) self.g...
Python
#!/opt/ActivePython-2.7/bin/python # Sequence Creation # Create a sequence comparision based on user input or file reading from Tkinter import * class Application(Frame): """ GUI application that creates based on user input. """ def __init__(self, master): Frame.__init__(self, master) self.g...
Python
#!/opt/ActivePython-2.7/bin/python # movie_chooser.py from Tkinter import * class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): Label(self, text = "Choose your favorite movie types...
Python
#!/opt/ActivePython-2.7/bin/python # longevity.py from Tkinter import * class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): # create label for instructions self.inst_lbl = Label(self, ...
Python
#!/opt/ActivePython-2.7/bin/python # Mad Lib # Create a story based on user input from Tkinter import * class Application(Frame): """ GUI application that creates a story based on user input. """ def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets(...
Python
#!/opt/ActivePython-2.7/bin/python # labeler.py from Tkinter import * root = Tk() root.title("Labeler") # root.geometry("200x100") app = Frame(root) app.grid() lbl = Label(app, text = "I'm a label!") lbl.grid() root.mainloop()
Python
#!/opt/ActivePython-2.7/bin/python # movie_chooser2.py from Tkinter import * class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): Label(self, text = "Choose your favorite movie type...
Python
#!/opt/ActivePython-2.7/bin/python # longevity.py from Tkinter import * class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): # create label for instructions self.inst_lbl = Label(self, ...
Python
#!/opt/ActivePython-2.7/bin/python # Mad Lib # Create a story based on user input from Tkinter import * class Application(Frame): """ GUI application that creates a story based on user input. """ def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets(...
Python
#!/opt/ActivePython-2.7/bin/python # lazy_buttons2.py from Tkinter import * class Application(Frame): """ A GUI application with three buttons. """ def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): self.bttn1 = Button(self, text ...
Python
#!/opt/ActivePython-2.7/bin/python # lazy_buttons.py from Tkinter import * root = Tk() root.title("Lazy Buttons") root.geometry("200x100") app = Frame(root) app.grid() bttn1 = Button(app, text = "I do nothing!") bttn1.grid() bttn2 = Button(app) bttn2.grid() bttn2.configure(text = "Me too!") bttn3 = Button(app) b...
Python
#!/opt/ActivePython-2.7/bin/python # movie_chooser.py from Tkinter import * class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): Label(self, text = "Choose your favorite movie types...
Python
#!/opt/ActivePython-2.7/bin/python # click_counter.py from Tkinter import * class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.bttn_clicks = 0 # number clicks self.create_widget() def create_widget(self): self.bttn =...
Python
#!/opt/ActivePython-2.7/bin/python # Mad Lib # Create a story based on user input from Tkinter import * class Application(Frame): """ GUI application that creates a story based on user input. """ def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets(...
Python
#!/opt/ActivePython-2.7/bin/python # simple_gui.py from Tkinter import * root = Tk() root.title("Simple GUI") root.geometry("200x100") root.mainloop()
Python
#!/opt/ActivePython-2.7/bin/python # movie_chooser2.py from Tkinter import * class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): Label(self, text = "Choose your favorite movie type...
Python
#!/opt/ActivePython-2.7/bin/python # labeler.py from Tkinter import * root = Tk() root.title("Labeler") # root.geometry("200x100") app = Frame(root) app.grid() lbl = Label(app, text = "I'm a label!") lbl.grid() root.mainloop()
Python
#!/opt/ActivePython-2.7/bin/python # Mad Lib # Create a story based on user input from Tkinter import * class Application(Frame): """ GUI application that creates a story based on user input. """ def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets(...
Python
#!/opt/ActivePython-2.7/bin/python # simple_gui.py from Tkinter import * root = Tk() root.title("Simple GUI") root.geometry("200x100") root.mainloop()
Python
#!/opt/ActivePython-2.7/bin/python # lazy_buttons2.py from Tkinter import * class Application(Frame): """ A GUI application with three buttons. """ def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): self.bttn1 = Button(self, text ...
Python
#!/opt/ActivePython-2.7/bin/python # lazy_buttons.py from Tkinter import * root = Tk() root.title("Lazy Buttons") root.geometry("200x100") app = Frame(root) app.grid() bttn1 = Button(app, text = "I do nothing!") bttn1.grid() bttn2 = Button(app) bttn2.grid() bttn2.configure(text = "Me too!") bttn3 = Button(app) b...
Python
#!/opt/ActivePython-2.7/bin/python # click_counter.py from Tkinter import * class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.bttn_clicks = 0 # number clicks self.create_widget() def create_widget(self): self.bttn =...
Python
# graphics.py """Simple object oriented graphics library The library is designed to make it very easy for novice programmers to experiment with computer graphics in an object oriented fashion. It is written by John Zelle for use with the book "Python Programming: An Introduction to Computer Science" (Franklin, Beedl...
Python
''' Created on 2012-10-15 @author: wangxin ''' import sys import os import re import time import md5 import random import thread from sets import Set import socket import traceback from Tkinter import * #record the path #action: # DELETE=0 # INSERT=1 # SUBSTITUTION=2 #...
Python
import sys import os import re import time import md5 import random import thread from sets import Set import socket import traceback from Tkinter import * #record the path #action: # DELETE=0 # INSERT=1 # SUBSTITUTION=2 # SAMEVALUE=3 class Path: def __init__(self,...
Python
#!/usr/bin/python # Copyright 2011 Google, Inc. All Rights Reserved. # simple script to walk source tree looking for third-party licenses # dumps resulting html page to stdout import os, re, mimetypes, sys # read source directories to scan from command line SOURCE = sys.argv[1:] # regex to find /* */ style commen...
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
#!/usr/bin/env python import gzip, sys, threading import crawle class SaveURLHandler(crawle.Handler): """This handler simply saves all pages. into a gziped file. Any reponses with status other than 200 is placed back on the queue. This example also demonstrates the importance of synchronization as mul...
Python
#!/usr/bin/env python import getpass, re, sys, threading import crawle class TwitterHandler(crawle.Handler): """This is an example of doing authentication with CRAWL-E. It must first be noted that twitter's robots.txt file disallows crawling thus proceed at your own risk. """ TWITTER_SESS_RE = re...
Python
#!/usr/bin/env python from distutils.core import setup from crawle import VERSION setup(name='CRAWL-E', version=VERSION, description='Highly distributed web crawling framework', author='Bryce Boe', author_email='bboe (_at_) cs.ucsb.edu', url='http://code.google.com/p/crawl-e', py_mo...
Python
"""CRAWL-E is a highly distributed web crawling framework.""" import Queue, cStringIO, gzip, httplib, logging, mimetypes, resource, socket import sys, subprocess, threading, time, urllib, urlparse from optparse import OptionParser VERSION = '0.6.4' HEADER_DEFAULTS = {'Accept':'*/*', 'Accept-Language':'en-us,en;q=0.8'...
Python
print("输入:") year=int(input()) print(year) for i in range(1,100): if (year%400==0 or (year%4==0 and year%100!=0)): print('year') else: print("平年!")
Python
#!/usr/bin/python # Filename: using_file.py import re i=1000 poem="" f = open('poem.txt', 'w') # open for 'w'riting while i>0: poem=poem+"B" i=i-1 f.write(poem) # write text to file f.close() # close the file
Python
import ftplib, string import os, sys import threading class MyFTP: def __init__(self, host='', user='', passwd=''): self.host = host self.user = user self.passwd = passwd self.filename = '' self.ftp = ftplib.FTP(host,user,passwd) def download_by_thread(self, f...
Python
bigFile= open("big.txt", 'w') bigFile.seek(28132) #大小自己定,需要几个G, fileSize就是几,速度绝对快 bigFile.write('\x00') bigFile.close()
Python
import os def DirFile(rootDir): list_dirs = os.walk(rootDir) for root,dirs,files in list_dirs: for d in dirs: print (os.path.join(root,d)) for f in files: print (os.path.join(root,f)) DirFile('c:')
Python
from sys import stdin a, b, c = map(int, stdin.readline().strip().split()) print "%.3lf" % ((a+b+c)/3.0)
Python
from sys import stdin from math import * r, h = map(float, stdin.readline().strip().split()) print "Area = %.3lf" % (pi*r*r*2 + 2*pi*r*h)
Python
from sys import stdin from math import * n, = map(int, stdin.readline().strip().split()) rad = radians(n) print "%.3lf %.3lf" % (sin(rad), cos(rad))
Python
from sys import stdin n, = map(int, stdin.readline().strip().split()) print n*(n+1)/2
Python
from sys import stdin a, b = map(int, stdin.readline().strip().split()) print b, a
Python
from sys import stdin n, m = map(int, stdin.readline().strip().split()) a = (4*n-m)/2 b = n-a if m % 2 == 1 or a < 0 or b < 0: print "No answer" else: print a, b
Python
from sys import stdin n, = map(int, stdin.readline().strip().split()) money = n * 95 if money >= 300: money *= 0.85 print "%.2lf" % money
Python
from sys import stdin n, = map(int, stdin.readline().strip().split()) print ["yes", "no"][n % 2]
Python
from sys import stdin from math import * x1, y1, x2, y2 = map(float, stdin.readline().strip().split()) print "%.3lf" % hypot((x1-x2), (y1-y2))
Python
from sys import stdin n = stdin.readline().strip().split()[0] print '%c%c%c' % (n[2], n[1], n[0])
Python
from sys import stdin x, = map(float, stdin.readline().strip().split()) print abs(x)
Python
from sys import stdin from calendar import isleap year, = map(int, stdin.readline().strip().split()) if isleap(year): print "yes" else: print "no"
Python
from sys import stdin f, = map(float, stdin.readline().strip().split()) print "%.3lf" % (5*(f-32)/9)
Python
from sys import stdin a, b, c = map(int, stdin.readline().strip().split()) if a*a + b*b == c*c or a*a + c*c == b*b or b*b + c*c == a*a: print "yes" elif a + b <= c or a + c <= b or b + c <= a: print "not a triangle" else: print "no"
Python
from sys import stdin a = map(int, stdin.readline().strip().split()) a.sort() print a[0], a[1], a[2]
Python
s = i = 0 while True: term = 1.0 / (i*2+1) s += term * ((-1)**i) if term < 1e-6: break i += 1 print "%.6lf" % s
Python
from sys import stdin from decimal import * a, b, c = map(int, stdin.readline().strip().split()) getcontext().prec = c print Decimal(a) / Decimal(b)
Python