blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
250e805dddf769c26c49b71f47cf46e13dfa78b0
guilhermea23/Python-Exercises
/exercises/recursion/melanciaV1.py
159
3.546875
4
def sedeDeMelancia(w): if w%2==0: print("SIM") else: print("NAO") w = int(input("Insira o peso da melância: ")) sedeDeMelancia(w)
b25805f73a214dd3e13c3e35f991ce7b2f27e96e
guilhermea23/Python-Exercises
/exercises/lists/remove_duplicates.py
336
3.625
4
def remove_duplicatas(lista): for e in lista: counter = lista.count(e) if counter!=1: lista.remove(e) new_lista = lista.copy() new_lista=sorted(new_lista) counter-=1 return new_lista x = [i for i in input().split(",")] print(remov...
b5809b77a50b66db651878f9f6c5868193142994
guilhermea23/Python-Exercises
/exercises/recursion/valid_triangle.py
356
3.859375
4
def valid_triangle(a,b,c): if (a <(b+c)) and (a >(b-c)): if (b<(a+c)) and (b>(a-c)): if (c<a+b) and (c>(a-b)): print("valido") else: print("invalido") else: print("invalido") else: print("invalido") a,b,c = map(int, inp...
738812e2784bbfd7d57dc71bf954e522d48ff695
guilhermea23/Python-Exercises
/exercises/strings/AinB.py
147
3.828125
4
def confere(x,y): if x.endswith(y): print("ta dentro!!!") else: print("ta fora...") a,b = input().split() confere(a,b)
ef921997db09b953ac2813814de69a25bd95d097
jonasberge/euler
/desk/464.py
4,020
3.84375
4
#!/usr/bin/env python3 # https://projecteuler.net/problem=464 """ """ from math import floor, sqrt from helper.prime import Primes primes = Primes() def divide_evenly(n, m): r = n // m if r * m == n: return r return False def divides_evenly(n, m): return divide_evenly(n, m) != False...
6087e1d610a83e24d17b52d37bbc524e0157d77c
tobiting/data-analysis
/readfile.py
300
3.859375
4
""" Using pandas to read in a dataframe from a csv-file. """ import pandas as pd # use the pandas library, conventionally named as pd df = pd.read_csv('testdata.csv') # Read in file 'testdata.csv' as a dataframe print df.head() # Display first five rows of dataframe
b7bbee06e7b5ed38c6f82a263cbb0f714e1aef65
Gomavijayan/python-basics-learning
/pip.py
129
3.625
4
import camelcase x = camelcase.CamelCase() a = "hi! there all how are you guys waht are all of u doing" print(x.hump(a))
9d26a0e6dd4a9f5b07852b306a314c19674f3602
zukahai/Support-everyone
/GonPhan/Gon.py
138
3.796875
4
a = [1, 2, 3, 4, 5, 6] print(a) b = [] for i in range(len(a)): b.append([a[i]]) print(b) print(b[0][0]) print(b[1][0]) print(b[2][0])
c4b4c8d5ab32dc950b8d9a3da7e024a1792c99ad
saxenarohan97/image-processing
/subtract_images_naive.py
838
3.59375
4
import cv2 from matplotlib import pyplot as plt path = '/Users/RohanSaxena/Documents/projects/cv' image1 = cv2.imread(path + '/car1.png') image2 = cv2.imread(path + '/car2.png') # Always use OpenCV for image subtraction. See cv_vs_np_subtract.py difference1 = cv2.addWeighted(image1, 1, image2, -1, 0) difference2 = c...
951c7e5183fa5c141cc354c47dadf1b4821c19e8
BlackHeartEmoji/Python-Practice
/PizzaToppings.py
511
4.15625
4
toppings = ['pepperoni','sausage','cheese','peppers'] total = [] print "Hey, let's make a pizza" item = raw_input("What topping would you like on your pizza? ") if item in toppings: print "Yes we have " + item total.append(item) else: print "Sorry we don't have " + item itemtwo = raw_input("give me anothe...
3845cc5f8c427cfcd79adc39c90e674bfb3933f5
firekind/theBetterEducationProject
/Lecture-5/code/allPaths.py
1,133
4.0625
4
# problem is to find all the paths from a # source vertex to a destination vertex # in a directed graph adjList = { 0: [1, 3], 1: [2, 3], 2: [5], 3: [4, 3], # cycle here 4: [5], 5: [] } visited = [False for _ in range(len(adjList))] walk = [] path = [] def dfs(v, dest): # marking vertex a...
7fca8ff0cec660dbf2c22d658bad5ba1b6d4a8a4
Aditya-Malik/Edyoda-Assignments
/subArray.py
444
4.3125
4
# 1. Print all sub arrays for a given array. Ex - if array is [2, 7, 5], Output will be: [2] [2, 7] [2, 7, 5] [7] [7, 5] [5]. def subArray(array): n=len(array) for i in range(0,n): for j in range(i,n): k=i sub_array=[] while k<=j: sub_array.app...
4e08f34745c97fbeb045a212762f7d5932baaa32
Qubaef/uwsgi-nginx-flask-servers-on-docker
/webapp/app/models.py
2,106
3.515625
4
import sqlite3 class Schema: def __init__(self): self.conn = sqlite3.connect('todo.db') self.create_chat_table() def __del__(self): # body of destructor self.conn.commit() self.conn.close() # create schema for ChatTable def create_chat_table(self...
ece004113a7323cb498de7288ac34864a79dec86
juliocmalvares/2048
/teste.py
656
3.921875
4
#!/usr/bin/python3 # -*- coding: utf8 -*- def mergeLine(line: list): moved = True merged = [0,0,0,0] while(moved): moved=False print(line) for i in range(len(line) - 2, -1, -1): if (line[i+1] == 0 and line[i] != 0): line[i], line[i+1] = line[i+1], line[i] merged[i], merged[i+1] = merged[i+1], merge...
9e2fcf05a82de2918b89b816f23a9cc915ec3e18
pminkov/wip
/algorithms/lru_cache.py
2,916
3.953125
4
class Node: def __init__(self, value): self.prev = None self.next = None self.value = value class LinkedList: def __init__(self): self.head = None self.tail = None self.size = 0 def insert(self, value): if self.head == None: self.head = Node(value) self.tail = self.head ...
5d57474b9831ec4a0eb27de5ec75fd2ecbed8fde
pminkov/wip
/stats/hypothesis.py
613
3.828125
4
from stats import * def hypothesis_test(original_mean, original_stddev, n_samples, new_mean): """ See this video: https://www.khanacademy.org/math/probability/statistics-inferential/hypothesis-testing/v/hypothesis-testing-and-p-values """ sample_mean_stddev = original_stddev / math.sqrt(n_samples) print "...
81759e71075aee6fc6a560b17b14a23236163e1f
madma10/lenguajes-automatas
/cadena 3.0.py
539
3.828125
4
#Yosimar Davila Garcia #Fernanda Aidee Garcia Novas #Ricardo Hernadez Carrillo #Socorro Abigail Cristóbal Hernández #Adrian Madrid Morales abc = [] num = int(input("ingresa el numero de los elementos del alfabeto: ")) for i in range(num): abc.append(input("intruduce los elementos de alfabeto: ")) print ("t...
427c56be5421b41389034850733440b70837217a
jtanwk/reddit-dailyprogrammer
/easy-challenges/37_e.py
431
3.984375
4
# Challenge 37, easy # https://www.reddit.com/r/dailyprogrammer/comments/rzdwq/482012_challenge_37_easy/ def count_lines(doc): file = open(doc) line_count = 0 word_count = 0 for line in file: print(line_count, line) line_count += 1 word_count += len(line.split()) ...
a1a9e851bc59a38a4ea45317c80b40bc423f89ac
jtanwk/reddit-dailyprogrammer
/easy-challenges/54_e.py
1,153
3.859375
4
# Challenge 54, easy # https://www.reddit.com/r/dailyprogrammer/comments/tux8f/5192012_challenge_54_easy/ import math import random mystring = "The cake is a lie!" key = 7 def matrix_cypher(input_string, key): num_rows = math.ceil(len(input_string) / key) num_fill = len(input_string) % key # fills empty...
59bf124a585d1ca065d9e5c35d62d1d42bab6202
dsardelic/Battleships
/battleships/ship.py
8,586
3.796875
4
"""This module contains data structures for managing ship data.""" import dataclasses from typing import Any, Dict, Tuple, Type, Union from battleships.grid import FieldType, FieldTypeGrid, Position, Series class ShipGrid(FieldTypeGrid): """Acts as a storage of grids corresponding to possible ship types. ...
78dea301d180738d0697eea14087b15e5b215abe
tianyu0901/code_basket
/algorithm/offer/6.py
819
3.78125
4
# -*- coding: utf-8 -*- # @Time : 2019-09-14 23:05 # @Author : TanXueFeng # @Site : # @File : 6.py # @Software: PyCharm # 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 # 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。 # 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 # NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。 class Solution: def minNumberInRotat...
6e9adc7381042f3e91e919438af85831181228ea
tianyu0901/code_basket
/algorithm/bfs.py
457
3.65625
4
# encoding: utf-8 # 广度优先搜索 from queue import Queue def bfs(adj, start): visited = {} q = Queue() q.put(start) while not q.empty(): u = q.get() print(u) for v in adj.get(u, []): exist = visited.get(v, False) if not exist: visited[v] = Tru...
27e565a7b7fce1c6b57ac76cfa54ad940a24aa02
arasharchor/cs231n-cnn
/assignment1/cs231n/classifiers/softmax.py
5,208
3.75
4
import numpy as np from random import shuffle def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs: - W: C x D array of weights - X: D x N array of data. Data are D-dimensional columns - y: 1-dimensional array of length N with labels 0...K-1, for K class...
44404cf3a165209e099543d6f03ac44b83fec5cf
ahmed-adel2022/udacity-project
/bikeshare.py
13,381
3.640625
4
import time import pandas as pd import numpy as np CITY_DATA_files = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): print('Hello! Let\'s explore some US bikeshare data!') # Get user input for city (chicago, new...
64e18fd43ee7bbd6141bd29f6df0004b2ec96fc7
mahima-c/opencv
/tutorial3.py
680
3.59375
4
#how to draw diffrent geomentric shapa import cv2 import numpy as np #img=cv2.imread('ex.jpg',1) #we can create an image from numpy zero method #for black image 3 img=np.zeros([512,512,3],np.uint8)#heigth width img=cv2.line(img,(0,0),(455,0),(255,0,0),3) img=cv2.arrowedLine(img,(0,0),(455,0),(255,0,0),3) #top lest ...
63730ba6c8d140659a6c1d1164e0d88fc993c486
compas-teaching/geometry-and-data-structures-lottilotte
/assignment_2_geometry_2.py
2,300
3.96875
4
# Assignment 2, Geometry - Task 2: # Use the cross product to compute the area of a convex, 2D polygon. __author__ = "Lotte Aldinger" __email__ = "aldinger@arch.ethz.ch" __date__ = "30.10.2019" import compas_rhino from compas.geometry import Polygon from compas.geometry import Vector from compas.utilities import pai...
cf6835abda29e48615f74c7e777d06af8245f02b
RollyPanda/py
/other/exercises/dad_class/matrix_transpose.py
226
3.875
4
def transpose(m): x, y = len(m), len(m[0]) m_t = [[0] * x for i in range(y)] for i in range(len(m)): for j in range(len(m[i])): m_t[j][i] = m[i][j] return m_t print(transpose([[-1], [-1]]))
587cd80ad95ecf293ca4cf961f8aa956ed3aa19e
RollyPanda/py
/other/python/debug.py
231
3.53125
4
def solve(num): for n in num: for i in n: temp = i ** 2 print(temp) if __name__ == "__main__": with open(0) as f: nums = [list(map(int, line.strip().split())) for line in f] solve(nums)
eb02da191a74b6de1269fe4f6cc3bd43750f1004
RollyPanda/py
/other/python/lost_cow.py
517
3.71875
4
def lost_cow(x, y): is_add = True count = 0 i = 0 while True: if is_add: if x <= y <= x + 2 ** i: count += y - x return count else: if x - 2 ** i <= y <= x: count += x - y return count count ...
71c4afb28b846e89917b7d781a91fd09135bdb51
RollyPanda/py
/other/exercises/usaco_guide/cses/weird_algorithm.py
311
3.71875
4
def solve(num): lst = [num] while True: if lst[-1] == 1: return lst if lst[-1] % 2 == 0: lst.append(int(lst[-1] / 2)) else: lst.append(int(lst[-1] * 3 + 1)) if __name__ == "__main__": with open(0) as f: num = int(f.readline().strip()) print(*solve(num))
b382cb8a2ec1fc8e03eb3b1b53e2434ce7b09d03
RollyPanda/py
/other/python/testturtle.py
967
3.671875
4
import turtle rock = turtle.Turtle() wn = turtle.Screen() wn.bgcolor("darkgoldenrod") rock.color("darkblue") rock.speed(0) rock.shape("turtle") rock.pensize(1) rock.hideturtle() # for i in range(10): # rock.penup() # rock.goto(0, 350) # rock.pendown() # rock.forward(50) # rock.right(90) # rock....
4a8856e0b3f6e3b2a9a90e37283f7328a27c0d38
RedGry/ITMO
/Computational math/LAB_2/main.py
1,541
3.765625
4
import colors as color import solvers print(color.BOLD + color.RED, "Решатель Нелинейных Уравнений!", color.END) while True: try: print('\n', color.UNDERLINE + color.YELLOW + "Выберите уравнение или выход (цифра):" + color.END) print(color.GREEN, '\t', "1: x^2 - 3 = 0", '\n'...
030e3abfd6bce4b33f9f5735aefbc21d94543304
jamarrhill/CS162Project6B
/is_decreasing.py
810
4.15625
4
# Name: Jamar Hill # Date: 5/10/2021 # Description: CS 162 Project 6b # Recursive functions # 1. Base case -> The most basic form of the question broken down # 2. If not base, what can we do to break the problem down # 3. Recursively call the function with the smaller problem # lst = [5, 6, 10, 9, 8, 7, 64, 10] # ...
58a4de9900cdfcc825800f5c2a39f660ece015ab
pnovotnyq/python_exercises
/12_Fibonacci.py
947
4.75
5
#! /usr/bin/env python ''' 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...
3fb5dc7f790d7aca2a5faa6ce1672f5ee04e0eab
m-soro/basic_session_in_flask
/basic_session_in_flask.py
1,810
3.6875
4
from flask import Flask, session # session enables us to add a piece of identification data to... # browser using cookie and linking this to a piece of... # identification data to a web server aka session ID... # these two piece of data are stored in a dictionary called session. from checker import check_logged_in # m...
33c62a45327ebf74beb9b1128d06185ed47678ad
soderdrew/Encoder-Decoder
/min_pq_tests.py
1,076
3.546875
4
import unittest from min_pq import * class MyTestCase(unittest.TestCase): def test_pq(self): pq = MinPQ([3, 10, 231, 5]) self.assertEqual(pq.is_empty(), False) self.assertEqual(pq.size(), 4) self.assertEqual(pq.capacity, 4) self.assertEqual(pq.min(), 3) s...
b4b26b1c7af25df62cf16da25cf7605d80a34c81
py2-10-2017/JoeCalise
/OOP/CallCenter.py
1,282
3.6875
4
from datetime import datetime class Call(object): def __init__(self,uni_id,caller_name,caller_number,call_reason): self.uni_id = uni_id self.caller_name = caller_name self.caller_number = caller_number self.call_reason = call_reason self.call_time = datetime.now() def d...
e1861230c7603062c2faee51e6e97d81d45badc5
py2-10-2017/JoeCalise
/Python 1/names.py
1,048
3.71875
4
students = [ {'first_name': 'Michael', 'last_name' : 'Jordan'}, {'first_name' : 'John', 'last_name' : 'Rosales'}, {'first_name' : 'Mark', 'last_name' : 'Guillen'}, {'first_name' : 'KB', 'last_name' : 'Tonel'} ] def printStudents(dict): for d in dict: print d['first_name'] + " " + d['la...
fb66f03ce4b02b02ce3190e0d3c814e0e117f90f
debugger22/BinPy
/BinPy/examples/source/Combinational/Encoder.py
977
3.6875
4
# coding: utf-8 # Example for Encoder class # In[1]: from __future__ import print_function from BinPy.Combinational.combinational import * # In[2]: # Initializing the Encoder class # Exacly 1 input must be 1 encoder = Encoder(0, 1) # Output of encoder print (encoder.output()) # In[3]: # Changing the numbe...
cb3c33674d4168186b552b32847e3dd17aa6bfb5
debugger22/BinPy
/BinPy/examples/source/Combinational/Decoder.py
1,012
3.640625
4
# coding: utf-8 # Example for Decoder class # In[1]: # Imports from __future__ import print_function from BinPy.Combinational.combinational import * # In[2]: # Initializing the Decoder class decoder = Decoder(0, 1) # Output of decoder print (decoder.output()) # In[3]: # Input changes # Input at index 1 is...
491ce2c3231bd61fa9cd343df29964f0876b506f
amankumarnb/python
/pylab1.py
2,599
3.8125
4
Python 3.7.3 (default, Apr 3 2019, 05:39:12) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license()" for more information. >>> print("aman") aman >>> int(input("enter the value:")) enter the value:20 20 >>> b=int(input("enter the value:")) enter the value:30 >>> a=int(input("enter the value:")) enter ...
570f580d387c5415da7196e6386d19a2482f1d1a
worricek/ATBS
/umbrellaReminder.py
764
3.5
4
# Code that checks the weather forecast and sends an SMS if its going to rain. # Uses custom code library directSMS with the input being the message. import requests,bs4, json, directSMS message = 'Grab the brolly!' # Get the html from the Weather website for Kellyville url = 'http://api.openweathermap.org/data/2.5...
e51515170d673bbf244f2294070ad3612ecf135a
worricek/ATBS
/MadLibFileRegex.py
1,002
4.0625
4
#! /usr/local/python import re #Function to Open a txt file in read only and print contents Madlibfile=open('madlibfile.txt', 'r') OriginalText=Madlibfile.read() print(OriginalText) #Take input on adjective, noun, adverb and verb Adjective=input('Enter adjective: ') Noun=input('Enter noun: ') Adverb=input('Enter adv...
57162509257ef4409515fc12b75d4076bbe5233f
worricek/ATBS
/AutoEmail.py
1,961
3.703125
4
#! /usr/bin/python # Write a program that takes an email address and string of text on the command line and #then, using Selenium, logs into your email account and sends an email of the string to the #provided address. (You might want to set up a separate email account for this program.) #This would be a nice way to a...
952246ef2950d04035fd2446e6e9782cb2702e84
worricek/ATBS
/RegEx-PWChecker.py
451
4.03125
4
#! /usr/bin/python3 import re while True: PW=input('Enter Password (Must be upper lower and number : ') if re.match(r'([a-zA-Z0-9]){8,}', PW): break else: print('Password does not match complexity requirements') #Result=PasswordRegEx.findall(PW) #if Result==None: # print('Test') #...
1855881febd5a8e0bf6a51b524a510b2116fef07
worricek/ATBS
/encryptORdecryptPDF.py
3,498
4
4
#! /usr/bin/python3 ''' This code takes 3 arguments on the command line: arg1 - Folder to target arg2 - mode. Either encrypt or decrypt. arg3 - password to encrypt or decrypt It then searches the directory for PDF files and either encrypts or decrypts depending on what the user input. After encrypting...
8e7f6ba06ed75315d6ede537402bb44a581b9ada
andrew-curthoys/CS50
/pset6/mario/mario.py
924
4.0625
4
from cs50 import get_int def main(): height = get_height("Height: ") # we need to subtract 1 from height & add 1 to i to account for zero indexing for i in range(height): blanks = height - i - 1 blocks = i + 1 print_blocks(blanks, blocks) print() # makes sure the height is...
4252e93aafd1a1b86352112f86639131632658e5
dawnonme/Eureka
/main/leetcode/95.py
844
3.828125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def generateTrees(self, n: int) -> List[TreeNode]: if n == 0: return [] def helper(lo, hi): if ...
0de4e68a6d6b9991f53d96540b26da613bb32beb
dawnonme/Eureka
/main/algorithms/design_and_analysis_of_algorithms/divide_and_conquer/find_closest_pair_of_points.py
2,771
3.953125
4
""" In this problem, distance means Euclidean Distance. Moreover, for sake of simplicity, all the points are in 2-D plane. Task is to find the smallest distance between any pair of points in a point set. Naive algorithm: O(n^2) Divide and conquer: O(nlogn) """ class Point: def __init__(self, attr=[]): ...
3c612a64c74d3f5cd65f7ee2814468461200d5e2
dawnonme/Eureka
/main/leetcode/725.py
934
3.515625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def splitListToParts(self, root: ListNode, k: int) -> List[ListNode]: total_num, cur = 0, root while cur: total_num += 1 cur ...
41e2ae7491efb761ae9b4e1d6082af78c43f2db5
dawnonme/Eureka
/main/leetcode/403.py
1,262
3.671875
4
''' Frog Jump ''' class Solution: def canCross(self, stones: List[int]) -> bool: ''' Dynamic Programming ''' from collections import defaultdict if not stones: return True dp = defaultdict(set) dp[1] = set([1]) # first step must be 1 stones_set = se...
41e7f8b12b6b8b8ba62d6a00b4c0a874793e6c9d
dawnonme/Eureka
/main/leetcode/139.py
709
3.921875
4
# Dynamic Programming # filled[i] = True means string s in index range [0, i) can be break down by the # wordDict, then it can be divided intosub-problems. filled[i] = True if there # exist j < i s.t. filled[j] = True and s[j : i] can be found in wordDict. import collections class Solution: def wordBreak(self, ...
0af6d88466e9e15a43cd03e9e336223f53548255
dawnonme/Eureka
/main/leetcode/368.py
1,555
3.53125
4
class Solution: def largestDivisibleSubset(self, nums: List[int]) -> List[int]: ''' Dynamic Programming: O(N^2) ''' if not nums: return [] nums.sort() dp = [None] * len(nums) dp[0] = [nums[0]] for i in range(1, len(nums)): max_...
1aff664a1e44b4f3101e4f49537bda3818da8ed8
dawnonme/Eureka
/main/leetcode/147.py
831
3.90625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def insertionSortList(self, head: ListNode) -> ListNode: self.sorted_list = ListNode(float('-inf')) self.__helper(head) return self.sorted_l...
c9e3a10f8c2779abe69c2ad58397b15c1d445685
dawnonme/Eureka
/main/learning/python_functional_programming.py
682
3.6875
4
''' It's a memo for functional programming in Python. ''' from random import random # list comprehension test = [random() for _ in range(1000)] # map test_times_2 = list(map(lambda x: 2 * x, test)) # filter test_larger_than_1 = list(filter(lambda x: x > 1, test_times_2)) from functools import reduce # Python libr...
a9c36ce57be061647fc34f016123ee4fba979273
dtbinh/ba1-project
/part1/draughtsFunctions_correct.py
2,831
3.703125
4
#!/usr/bin/python # -*- coding: utf8 -*- from math import * from config import * def initBoard(dimension): myboard = [ [ FREE_SPACE for i in range(dimension) ] for j in range(dimension) ] for i in range(int(dimension/2)-1): for j in range(1-i%2,dimension,2): myboard[i][j]=BLACK_PLAYER for i in range(dimens...
bfdd8dcbc3e13cbe4bbf6394d7edd098be88dceb
irounik/Basic-IT-Workshop
/Lab 3/Q1_NoOfDigits.py
144
3.796875
4
num = int(input("Enter the number: ")) temp = num count = 0 while(temp>0): temp//=10 count+=1 print('Number of digts in',num,'is',count)
14653b928b4ed7013b09a1736602526d690a5525
irounik/Basic-IT-Workshop
/Lab 3/Q6_Cube_Series.py
85
4.09375
4
n = int(input('Enter number of terms:')) for i in range(1,n+1): print(i**3, end= ' ')
fb534cfa6967429c60752838108827b504e80832
irounik/Basic-IT-Workshop
/Lab 1/swap.py
143
3.984375
4
a = int(input('Enter first number(a): ')) b = int(input('Enter second number(b): ')) a = a+b b = a-b a = a-b print('Now a is:',a,'and b is', b)
aab3274977dc8e60f725e9bbb8c1ab6cade0f337
themuppet2/sql
/6.5.1-homework-b.py
529
4.03125
4
# Update the quantity of two of the records, and then output all # all the records from the table import sqlite3 with sqlite3.connect("cars.db") as connection: c = connection.cursor() # update quantity of the records c.execute("UPDATE cars SET quantity=10 WHERE model='GT'") c.execute("UPDATE cars SET...
3d365d8caaf072e02d4f1cab5481307aee2a7a05
themuppet2/sql
/6.5.1-homework-c.py
405
4.0625
4
# Output records from cars that are Ford vehicles. ############## Note: alternative (better?) solution can be # found in 6.5.1-homework-c-2.py ######################### import sqlite3 with sqlite3.connect("cars.db") as connection: c = connection.cursor() c.execute("SELECT * FROM cars") rows = c.fetchall...
9e81f8e5faf23a690b9a20eb06227c4a779848e4
Goutam-Kelam/Algorithms
/Square.py
813
4.25
4
''' This program produces the square of input number without using multiplication i:= val:= square of i th number ''' try : num = int(raw_input("\n Enter the number\n")) if(num == 0): # FOR ZERO print "\nThe square of 0 is 0\n" exit(1) ...
707f90f1699ab0db9c4c11d0e3cca9b407408b8f
Goutam-Kelam/Algorithms
/Bday_paradox.py
726
3.96875
4
"""" This program is to validate the Birthday Paradox """ from math import * try: print "\nThis program tells you the minimum number of people required to make the probabilty suggestd by you such that 2 people have bday on same day\n" # no_of_ppl =0 desired_prob = float(raw_input("\n\nEnter your ...
28a682655a048fcaf0a2543eb3ab1821a7219336
Goutam-Kelam/Algorithms
/necklace.py
1,642
3.875
4
''' This program helps in distributing the Diamonds and Emralds in the Necklace between 2 theives.. Notation:- Diamond = 1; Emerald = 0; Total no. of Gems = 2(k1 + k2) No. of Diamonds = 2D No. of Emralds = 2E Loop Invariant :- 1) Size of window := k1+...
bf63ab2ce233a70c2288198cf4ad307273e97433
kptsukhol/Friedmann-Integrator
/friedmann/integrators.py
5,921
4.03125
4
"""Friedmann equation integrators""" import numpy as np from scipy.integrate import cumtrapz # We are going to use a *class* for our Friedmann integrator. Classes are used # for many things, but here I'm using one to closely link *functionality* # with *data*. In functional programming you have functions that opera...
4bb20535ff350a064be110c38e278f8d69f84a05
konkisravankumar/practice
/src/L4_controlflow.py
1,762
4.0625
4
# #### conditional statments (if, else, elif) # a = 5 # if a>0 and a>4: # print("it is positive") # print("it is larger than 4" ) # a = 5 # if a > 0 : # print("it is positive") # else: # print("it is negative") # num = 20/30 # if num > 0 : # print("%f num is postive number " %(num)) # else : # ...
e3ac20620eb3702c9584c7cafc12dec99e1101b1
ginmanga/Text-parsing-with-python
/P_files_xls.py
3,832
3.75
4
"""Program to extract data from excel files.""" # ------------------------------------------------------------------------------ # Name: Extract Data Excel for Kay # Purpose: Extract Data Excel for Kay # # Author: Jorge Patron Boenheim # # Created: 17/02/2016 # Copyright: (c) Jorge 2016 # Licence:...
d5b7232c8ca33c4a16f9339ecc6767de0f5d6cb5
Johnson-wu/python
/20140522/yield01.py
889
3.671875
4
#coding:utf-8 # yield : 通过在函数中加入yield,可以控制函数运行的阶段和时机。 # 比如:当函数运行到一半yield一下,将函数挂起,完成其他事情后再回头继续运行 # 但是,关键的yield的运用场景是在什么地方? def f(): for i in range(4): yield i*2 # return y = f() # f()将返回一个generator对象 for i in range(4): print(next(y)) # python3 后,y.next()被废弃了,应该用next(y) delimeter = '======================' pri...
e8a587f892f49edeaf6927e57113a7eeec0f3495
prasadhegde001/Turtle_Race_Python
/main.py
1,115
4.28125
4
from turtle import Turtle,Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) user_input = screen.textinput(title="Please Make Your Bet", prompt="Which Turtle Will win the Race? Enter a color") colors = ["red", "orange", "yellow", "green", "blue", "purple"] y_positio...
d6e91528d13834231a950e675781ddccab502986
shabbir148/A-Hybrid-Approach-for-Text-Summarization-
/fuzzy-rank/Summarizers/file_reader.py
1,100
4.15625
4
# Class to simplify the reading of text files in Python. # Created by Ed Collins on Tuesday 7th June 2016. class Reader: """Simplifies the reading of files to extract a list of strings. Simply pass in the name of the file and it will automatically be read, returning you a list of the strings in that file.""" ...
771b16825cefce7075a6aa7b4928890d1ba98417
nadimhayat/cmu15-112
/extra.py
581
3.71875
4
#problem 11 a = int(input("Enter x1: ")) b = int(input("Enter y1: ")) c = int(input("Enter x2: ")) d = int(input("Enter y2: ")) e = int(input("Enter x3: ")) f = int(input("Enter y3: ")) def triangleArea(x1, y1, x2, y2, x3, y3): s1 = ((y2-y1)**2+(x2-x1)**2)**0.5 print("s1 =", s1) s2 = ((y3-y1)**2+(x3-x1)**2...
5f780186b0cd6e79b5cc4aac215038c41d3484cb
nadimhayat/cmu15-112
/Week-1/Dataexpression.py
1,251
3.6875
4
import math def f(): print("This is a user-defined function") return 42 print("Some basic types in Python:") print(type(2)) # int print(type(2.2)) # float print(type("2.2")) # str (string) print(type(2 < 2.2)) # bool (boolean) print(type(math)) # module print(type(math.tan))...
541b378e5b0ba364897995ca76389fb997186053
sepiggy/python-ref
/python27-liao/使用@property.py
596
3.515625
4
class Student(object): @property def score(self): return self._score @score.setter def score(self, value): if not isinstance(value,int): raise ValueError('socre must be an integer!') if value < 0 or value > 100: raise ValueError('socre must betwee...
b0304411d3408c08056d86457ef288d10ecf461d
pole55/repository
/Madlibs.py
1,360
4.21875
4
"""Python Mad Libs""" """Mad Libs require a short story with blank spaces (asking for different types of words). Words from the player will fill in those blanks.""" # The template for the story STORY = "This morning %s woke up feeling %s. 'It is going to be a %s day!' Outside, a bunch of %ss were protesting to keep %s...
1f48d9529ae94ae0deb313d495ffce1ee57179ec
Apropos-Brandon/py_workout
/code/ch01-numbers/e01_guessing_game.py~
634
4.25
4
#!/usr/bin/env python3 import random def guessing_game(): """Generate a random integer from 1 to 100. Ask the user repeatedly to guess the number. Until they guess correctly, tell them to guess higher or lower. """ answer = random.randint(0, 100) while True: user_guess = int(input("What is your...
b2976083e8f66af05504ccf4700e7a6ca945586e
liuxingyuxx/cookbook
/string_text/just_format.py
688
3.96875
4
#通过某种对齐方式来格式化字符串 text = 'Hello World' l = text.ljust(20) print(l) l = text.ljust(2,'=') r = text.rjust(20) r_ = text.rjust(20, "_") c = text.center(20, '$') print(r, r_) print(c) #format l = format(text, '>20') l_ = format(text,"=>20s") c = format(text, '^20') c_ = format(text, '*^20s') print([l],[l_]) print([c],...
6e9ae233ec122eeafe301ba8f76cfe4da0972798
liuxingyuxx/cookbook
/date_structure/zip.py
888
4.25
4
#怎样在数据字典中执行一些计算操作(比如求最小值、最大值、排序等等)为了对字典值执行计算操作,通常需要使用 zip() 函数先将键和值反转过来 prices = { 'ACME': 45.23, 'AAPL': 612.78, 'IBM': 205.55, 'HPQ': 37.20, 'FB': 10.75 } min_price = min(zip(prices.values...
cf251ea6cbdc275e37f4eadc53d77772df95534f
Ravi9562/CRM
/Collecting_Details_Without_Duplicates.py
1,256
3.546875
4
import re import time Input = open("Body.txt", "r") Output = open("Details.txt", "w+") #C:\Users\tejaw\PycharmProjects\CRM\Collecting_Details_Without_Duplicates.py def Searching_strings(): print('Collecting Details') for line in Input: if re.match("(.*)(Phone:)(.*)", line): pr...
086b3ebd6cea110adca29e752e1d9e2a32edd259
grant-park/Algorithms-and-Data-Structures
/closest_pair/point_set.py
2,274
3.625
4
import point_pair def getX(item): return item[0] def getY(item): return item[1] def bruteForce(x): minimum = float('inf') minimum_i = 0 minimum_j = 0 for i in range(0,len(x)-1): for j in range(i+1,len(x)): if point_pair.point_distance(x[i],x[j])<minimum: minimum = point_pair.point_distance(x[i],x[j]) ...
76259a1985f9c3e839764ed141969269ae74262a
kilarionov/Python3
/rotting_apples/rotting_apples.py
2,516
4.0625
4
''' Hack Bulgaria, “Programming 101 with Python” започващ на 24.02.2020 задачи за Кандидатстване от Кирил Иларионов, 359 878 719 304, k.ilarionov@gmail.com 02/02/2020 ''' def rotting_apples() : GOOD_APPLE = 'O' BAD_APPLE = 'X' DAYS_TO_BE_BAD = 3 nxm = input("Enter the size of t...
33ddbcdf3862883bb87593cc447c0c45a4d05273
dalealleshouse/python_algs
/algs/selection_sort.py
515
3.59375
4
def selection_sort(list, strategy, track=None): for i in range(len(list) - 1): lowest = i for j in range(i + 1, len(list)): if track: result = strategy(list[j], list[lowest], track) else: result = strategy(list[j], list[lowest]) ...
156b49b0b6adf97a896e3d0c892f3241ee8eb2f5
arthikk/Week-day_the_quick_way
/date.py
360
3.671875
4
y=raw_input("Enter the year: ") m=raw_input("Enter the month: ") d=raw_input("Enter the date: ") y=y%400 days=["Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"] print days[(3*int((9*m-8)/10)-int(abs(2*m-4)/5)+int(5*y/4)-int(y/100)+((1 if (y%4 == 0) else 0) - (1 if (y%100 == 0) else 0) + (1 if (y =...
eedde460936b41c711402499160c903855636a3a
Struth-Rourke/cs-module-project-iterative-sorting
/src/searching/searching.py
1,332
4.21875
4
def linear_search(arr, target): # for value in the len(arr) for i in range(0, len(arr)): # if the value equals the target if arr[i] == target: # return the index value return i # # ALT Code: # for index, j in enumerate(arr): # if j == target: # ...
7e79afd06e602b5fa0c1e7663ff72a41867a85c5
EikiObara/myMaze
/maze.py
1,937
3.625
4
# This maze generator is defined # 0 is wall, 1 is way import random as rd DIRECTION = 4 # 2D(Plane) WALL = 0 ROAD = 1 STEP_WIDTH = 2 D_MAT = [[0, 1], [1, 0], [0, -1], [-1, 0]] # direction matrix class Maze: def __init__(self, width, height): if self.Even(width): self.width = width - 1 else: self.width ...
d753b7d763d283428f39416c3400812b7b90b218
NBR-hugh/python
/books/learn-python-the-hard-way/ex_0/ex03.py
1,049
3.890625
4
# -*- coding: utf-8 -*- print "I will now count my chickens:" # 打印字符串:我现在要数我的鸡 print "Hens", 25.0 + 3 / 6 # 输出母鸡的只数,直接显示结果 print "Roosters", 100.0 - 25 * 3 % 4 # 输出公鸡的只数,直接显示结果 print "Now I will count the eggs :" # 打印字符串:现在我将数鸡蛋 print 3 + 2 + 1 - 5.0 + 4 % 2 - 1 / 4 + 6# 输出个数,运行时直接显示结果 prin...
c3b9660a48c8d9f3832592b219e105c0debac345
NBR-hugh/python
/books/learn-python-the-hard-way/ex_1/ex16.py
1,438
4.03125
4
# -*- coding: utf-8 -*- #BE 00 from sys import argv # 定义参数 script,filename = argv # 打印引导语 print "We're going to erase %r." % filename print "If you don't want that,hit CTRL-C(ˆC)" print "If you do want that, hit RETURN." # 等待用户输入 raw_input("?") # 以写入模式打开文件 print "Open the file..." target = open(filename,'w') # 清空...
33e09fc60b7ef437d3814623af9a3f214a891374
NBR-hugh/python
/books/learn-python-the-hard-way/ex_0/ex12.py
516
3.515625
4
# py2.7-origin ''' age = raw_input("How old are you?") height = raw_input("How tall are you?") weight = raw_input("How much do you weigh?") print "So,you're %r old,%r tall and %r heavy." % ( age,height,weight) ''' ''' !!! state: the i line in origin >>> the i+30 line in change ''' #py3.6.0-change age ...
efcbd39aee1e5fb912ffc3f52c7abaf6b963ca38
blairg23/common-interview-problems
/queue-using-stacks/queue_using_stacks.py
4,579
4.1875
4
# Task # - Implement a Queue using Stacks # Example: # >>> a = Stack() # >>> a.push(1) # >>> a.push(2) # >>> a.push(3) # >>> a.pop() # 3 # >>> a.pop() # 2 # >>> a.pop() # 1 # >>> a.pop() # IndexError: list index out of range import time # Solutions copied from https://www.geeksforgeeks.org/queue-using-stacks...
08c4fc6c021ab43d8b40d9b35df06dc4785a8ddf
blairg23/common-interview-problems
/balanced-parentheses-problem/balanced_parentheses_stack_solution.py
1,359
4.03125
4
""" The Balanced Parentheses Problem. https://bradfieldcs.com/algos/stacks/balanced-parentheses/ Given a string of parentheses, how to tell if they're balanced? --- ((({}[]))) -> true ((())) -> true (()) -> true () -> true ()()() -> true --- ()) -> false ))(( -> false ()(( -> false --- Solution translated into ...
432ab3527eb3a402218aeea4cd610fe19a7d183e
Charles-Ndugire/password-locker
/test_users.py
2,666
3.546875
4
import unittest from users import User import csv import os class TestUsers(unittest.TestCase): def setUp(self): '''Setting up data to be used in all the tests.''' self.new_user = User('Gaswoy', 'Holy', 'gaswoy@gmail.com','123@Iiht' ) def tearDown(self): '''Clean up data after all test...
e1d361af8b269fb03bea58596f483c3972e483d0
zedzijc/advent2019
/solutions/day1/day1_solution.py
1,710
3.84375
4
from solutions.common.parse import parse_input_as_list from solutions.common.util import strings_to_integers import math def get_required_fuel(puzzle_input): """ Solution to Day 1 Puzzle 1 Computes and prints the total fuel required to launch a list of modules based on their mass. """ _compute...
a32702347f6aed5b34efb9ca11fb20fe1b1178cb
Mihirsmi/Data-Structures
/building_tree_pre_post.py
5,160
4.34375
4
#Given Pre-order and In-order traversal we will build a binary tree with insertNode() method #Given Post-order and In-order traversal we will build a binary tree with insertInBinaryTree() method #Detail Explanation in Method class Node: def __init__(self, data=None, right=None, left=None): self.data = data self.r...
f433716c6cc148ecccb735b910fc7485113f91b6
malawson/miscellaneous
/client-side/_test.py
659
3.5
4
import requests import json """ r = requests.get("http://www.python.org/") with open("python_org.html", "wb") as code: code.write(r.content) """ url = 'http://httpbin.org/post' payload = {"colors":[ {"color": "red", "hex": "#f00"}, {"color": "green", "hex": "#0f0"}, {"color": "blue", "hex": "#00f"}, {...
6b5d0b0e499d860fdc27ceb40cb54c5b8996f71a
ailyanlu1/leetcode-4
/Python/141_Linked List Cycle.py
444
3.5
4
class Solution: # @param head, a ListNode # @return a boolean def hasCycle(self, head): if not head: return False if head.next == head: return True second = head.next first = head while second and second != first: second = second.ne...
7da1cb8dcb911c71e01f6e5618bd8b433557aed1
LiberoHS/big2-simulator
/game.py
8,675
3.640625
4
# Started by Jeremy Lim on 13/08/2019 # TO-DO LIST # - Implement states (most done) # - Check legal players # - If passing, will not go back to the player (done) # - Implement player prompts (most done) # - Implement point system (most done) # - Sort cards based on points and/or suits import random class Card(): ...
35b3ec3655013b556d7e65f03697b5376a65f62b
arunsprasath/kaggle-machine-learning
/Data Science Practice/Introduction to Functions-4.py
2,654
3.671875
4
## 1. Overview ## movie_data = [] movie_data_string = open("movie_metadata.csv", "r").read() movie_data_list = movie_data_string.split("\n") for i in movie_data_list: movie_data.append(i.split(",")) print(movie_data[1:5]) ## 3. Writing Our Own Functions ## def first_elts(movie_data): movie_names = [] ...
f9bdf6281a5b5dd0717e476d05888c48c3af0761
danny099/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
360
4.03125
4
#!/usr/bin/python3 """print a square size""" def print_square(size): """ irint a square """ if not isinstance(size, int): raise TypeError("size must be an integer") if (size < 0): raise ValueError("size must be >=0") for i in range(size): for j in range(size): ...
33949d421cad05804e4b7cdf8a48674cb9975ea8
jonesparg/ML-Models
/linear_model/LinearRegressor.py
1,729
3.671875
4
""" @author: Samarendra """ import numpy as np class LinearRegressor: def __init__(self,fit_intercept=True): ''' Basic Linear Regression without any regularizations (OLS) Parameters: ---------------------------------------------- fit_...
c593a89dc4ae7be983e2976cd0f550fb3131e20e
skycckk/Topics-in-Machine-Learning
/KMeans/my_kmeans.py
4,740
3.890625
4
import numpy as np import matplotlib.pyplot as plt __author__ = "Wei-Chung Huang" __copyright__ = "Copyright 2017" __version__ = "1.0.0" def _distance(a, b): """ Distance function. Use Euclidean distance so far. :param a: ndarray Set of data points :param b: ndarray Set of data points...
1755e262395a465cf7feac0969cac3422f15cf45
Dagim3/MIS3640
/excercise 2_wordplay.py
653
3.765625
4
with open('words.txt', 'r') as fd: word_list = fd.read().split() def is_abecedarian(word): return word == ''.join(sorted(word)) words = [word for word in word_list if is_abecedarian(word)] print ("There are {} abecedarian words.".format(len(words))) def rec_abecedarian(word): i= 0 word = 0 ...