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 |
|---|---|---|---|---|---|---|
6ad46f0cb0d2abbb8a607f39b1408e1fa78657f6 | carlhinderer/python-exercises | /daily-coding-problems/problem302.py | 464 | 3.578125 | 4 | # Problem 302
# Medium
# Asked by Uber
#
# You are given a 2-d matrix where each cell consists of either /, \, or an empty space.
# Write an algorithm that determines into how many regions the slashes divide the space.
#
# For example, suppose the input for a three-by-six grid is the following:
#
# \ /
# ... |
c31c436f1f631cd2918287ca150dba78098b9c8f | carlhinderer/python-exercises | /daily-coding-problems/problem032.py | 454 | 3.5 | 4 | # Problem 32
# Hard
# Asked by Jane Street
#
# Suppose you are given a table of currency exchange rates, represented as a 2D array.
# Determine whether there is a possible arbitrage: that is, whether there is some
# sequence of trades you can make, starting with some amount A of any currency, so
# that you... |
06202b0a0cf7bb65452f39ba65fbb37891f3c022 | carlhinderer/python-exercises | /daily-coding-problems/problem300.py | 326 | 3.5 | 4 | # Problem 300
# Easy
# Asked by Uber
#
# On election day, a voting machine writes data in the form (voter_id, candidate_id)
# to a text file. Write a program that reads this file as a stream and returns
# the top 3 candidates at any given time. If you find a voter voting more than once,
# report this as fr... |
61a54b61e7f6f8f101e5cdbd90c43da54eca61a8 | carlhinderer/python-exercises | /daily-coding-problems/problem157.py | 329 | 3.6875 | 4 | # Problem 157
# Easy
# Asked by Amazon
#
# Given a string, determine whether any permutation of it is a palindrome.
#
# For example, carrace should return true, since it can be rearranged to form
# racecar, which is a palindrome. daily should return false, since there's
# no rearrangement that can form a pali... |
12c6b0b0a416ee598891ba425cd2332daf2d89ff | carlhinderer/python-exercises | /daily-coding-problems/problem397.py | 501 | 3.71875 | 4 | # Problem 397
# Medium
# Asked by Microsoft
#
# You are given a list of jobs to be done, where each job is represented by a
# start time and end time. Two jobs are compatible if they don't overlap. Find the
# largest subset of compatible jobs.
#
# For example, given the following jobs (there is no guarantee t... |
5479fc5d0715578cdafa71eed92622177108b12e | watsondr/python-3-prac | /data_cleaning_functions.py | 720 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jan 7 22:56:01 2020
@author: campb
"""
def parse_rows_with(reader, parsers):
"""
Use the reader to parse the rows with the perscribed expected format.
Yield means the reader can do something with one item, then move on
without escaping the function proc... |
c1cf1a4b35784a6ca09c96bb01e227a6d4a2b525 | Shavavv97/LifeStore_Analysis | /PROYECTO-01-VIDAL-SALVADOR.py | 18,603 | 3.5625 | 4 | from lifestore_file import lifestore_products, lifestore_sales, lifestore_searches
#Register admin users.
admin_users = []
while admin_users == []:
print('\nThere is no admin users registered.')
username = input('\nPlease register an admin user: ')
password = input('Please enter the password: ')
admin_... |
ded7b0fb6e56c105bdf7a50f6860bbb15e930929 | mh11375/burn_care | /wips/add_button.py | 646 | 4 | 4 | #!/usr/bin/env python3
# POC add rows
import tkinter as tk
class App:
def new_row(self):
new_entry = tk.Entry(root)
self.num_rows += 1
new_entry.grid(column=0, row=self.num_rows)
def __init__(self): #the code that executes when an class is initiated
self.num_rows = 1
crea... |
14e62b9b43f6fcc3d850dc335f0a054297f32d8c | Shropshire-EGIT/Connor-s_text_adventure | /text adventure/definitions.py | 11,013 | 3.671875 | 4 | import time
from random import randint
#displays the current room of the player
def user_look(current_room):
print('\n' + current_room['name'])
print('_' * len(current_room['name']) + '\n')
print(current_room['text'])
print('_' * len(current_room['text']) + '\n')
if len(current_room['c... |
7ff34f2c24aa24044cdeb50fc5ad75a74aad835a | Caustin122/Cryptology | /Challenges/challenge-1/keyword-cipher.py | 3,304 | 3.671875 | 4 | # Abraxas
# by: Chris Kalahiki
#
# NOTE: If you want to reverse alphabet, uncomment line 16
import sys
# The hard-coded alphabet
#ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`~!@#$%^&*()-_=+[{]}\|;:'\",<.>/? "
#ALPHABET = " -,;:!?/.'\"()[]$&#%012345789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrR... |
87e450358e82746ef29ce3afad9b46f457e12fc2 | lutzer/polylogue | /scripts/polylogue/lib/PrintFeed.py | 1,499 | 3.625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Lutz Reiter, Design Research Lab, Universität der Künste Berlin
# @Date: 2016-01-26 16:07:22
# @Last Modified by: lutz
# @Last Modified time: 2016-02-03 17:32:56
class Message:
def __init__(self, text):
self.text = text
#add 7 trailing spaces
self.... |
8225be5727f655df0da619e58341fd8b4cf05df6 | NMaslova/myhelper | /functions.py | 1,120 | 3.71875 | 4 | import math
import random
from collections import Iterable
from helper.exceptions import *
from exceptions import WrongLengthException
def check_iterable(seq):
if isinstance(seq, Iterable):
return
raise TypeError
def pick_from_list(simple_list):
return random.choice(simple_list)
def ncr(n, r)... |
069c09ec5a3bf11a00480ef3de0207f7161c0263 | suprajaarthi/DSA | /19 Day8 CheckPalindRec.py | 656 | 4.3125 | 4 | # Recursive function to check if `str[low…high]` is a palindrome or not
def isPalindrome(str, low, high):
# base case
if low >= high:
return True
# return false if mismatch happens
if str[low] != str[high]:
return False
# move to the next pair
else:
ret... |
322db8f52f43c93c7ee36440e6355b62f1054166 | schase15/Sprint-Challenge--Data-Structures-Python | /names/binary_search_tree.py | 2,965 | 4.4375 | 4 | # Utilize the BST from the hw assignment
# Only need contains and insert methods
class BSTNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
# Insert the given value into the tree
# Compare the input value against the node's value
# Check if ... |
22bdbf956d38ecd4327080b6be559d7a2bfddfe6 | ammaar8/TextAdventure | /Character.py | 3,567 | 3.625 | 4 | from random import randint
# Satmina chantged to sp (Stamin Points)
class Character(object):
# __repr__ should return str type.
# def __repr__(self):
# name = self.name
# return name
def setInfo(self, name, type, hp):
self.name = name
self.type = type
self.hp = hp
... |
198ce51002296c632ee5522b2ab4f5dec317727d | wangtaodd/LeetCodeSolutions | /069. Sqrt.py | 586 | 4.25 | 4 | """
Implement int sqrt(int x).
Compute and return the square root of x.
x is guaranteed to be a non-negative integer.
Example 1:
Input: 4
Output: 2
Example 2:
Input: 8
Output: 2
Explanation: The square root of 8 is 2.82842..., and since we want to return an integer, the decimal part will be truncated.
"""
class... |
44327cd41d09d206b171781dd89aae73376e2dec | wangtaodd/LeetCodeSolutions | /693. Binary Number with Alternating Bits.py | 770 | 4.25 | 4 | """
Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.
Example 1:
Input: 5
Output: True
Explanation:
The binary representation of 5 is: 101
Example 2:
Input: 7
Output: False
Explanation:
The binary representation of 7 is: 111.
Example 3:
Inp... |
42b522c5d47b3f31c12398ee1304a62814dec748 | wangtaodd/LeetCodeSolutions | /530. Minimum Absolute Difference in BST.py | 902 | 4.1875 | 4 | """
Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.
Example:
Input:
1
\
3
/
2
Output:
1
Explanation:
The minimum absolute difference is 1, which is the difference between 2 and 1 (or between 2 and 3).
Note: There are at l... |
510b6ab46bb5945bcdbef9f8f11c870222e6272e | wangtaodd/LeetCodeSolutions | /643. Maximum Average Subarray I.py | 791 | 3.9375 | 4 | """
Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.
Example 1:
Input: [1,12,-5,-6,50,3], k = 4
Output: 12.75
Explanation: Maximum average is (12-5-6+50)/4 = 51/4 = 12.75
Note:
1 <= k <= n <= 30... |
ed39b74e1159388de7197c532d17474bcf8d66d5 | wangtaodd/LeetCodeSolutions | /633. Sum of Square Numbers.py | 966 | 3.875 | 4 | """
Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c.
Example 1:
Input: 5
Output: True
Explanation: 1 * 1 + 2 * 2 = 5
Example 2:
Input: 3
Output: False
"""
class Solution(object):
def judgeSquareSum(self, c):
"""
:type c: int
... |
d1cc6d200c83e41b737d9a07ab0dcc61e96b8408 | wangtaodd/LeetCodeSolutions | /790. Domino and Tromino Tiling.py | 1,160 | 3.890625 | 4 | """
We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may be rotated.
XX <- domino
XX <- "L" tromino
X
Given N, how many ways are there to tile a 2 x N board? Return your answer modulo 10^9 + 7.
(In a tiling, every square must be covered by a tile. Two tilings are different if ... |
ea0ce1b541e74ca38790a66990d809be4ce825af | wangtaodd/LeetCodeSolutions | /107. Binary Tree Level Order Traversal II.py | 1,190 | 4.125 | 4 | """
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its bottom-up level order traversal as:
[
[15,7],
[9,20],
[3... |
54391ed1abc9713d4db095a6b8d26cb12153645d | JeeVeeVee/univ | /1steBachelor/AlgoritmenEnDatastructuren/SorteerAlgoritmen/QuickSort.py | 1,426 | 3.5625 | 4 | import random
import datetime
def quicksort(rij):
if len(rij) <= 1:
return rij
else:
rechts = []
links = []
spillen = []
spil = 0
#print(spil, rij)
for i in range(len(rij)):
if rij[i] < rij[spil]:
links.append(rij[i])
... |
5892317efca9afe1b20dbf81f196a4c2cc9d6c51 | abcmani/Python_projects | /webapp_volcano/webmap_1.py | 674 | 3.515625 | 4 | import folium
#create a map object
#at location=[] field you can place latitude and longitude values of your city.
map= folium.Map(location=[18.5204,73.8567], zoom_start=7)
print(map)
# need html file out of this object - to create/see the map
#look the directory of the map method to see all method we can appl... |
90a9f706abe7e0683ae587919dfaea1125ce25d6 | iagus92/CDI | /Practica_9_correccion/time.py | 727 | 3.53125 | 4 | """
=============================
Demo of the errorbar function
=============================
This exhibits the most basic use of the error bar method.
In this case, constant values are provided for the error
in both the x- and y-directions.
"""
import numpy as np
import matplotlib.pyplot as plt
# example data
plt.... |
1caf1e8d18c791936a0c287d58d596bc779a40c7 | Jian-Yin-Shine/py-patterns | /template_method.py | 1,346 | 4.09375 | 4 | '''
模板模式:
定义一个操作中的算法的架构,而将一些步骤的实现延迟到子类中
这样,可以使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤(相当于,只需要覆写某些方法)
- 在父类中定义处理流程的框架,在子类中实现具体处理的模式
- 在抽象类阶段定义处理的流程
- 使用继承改变程序的行为
- 把不变的行为放到超类,去除子类中的重复代码
- 提供了一个很好的代码复用平台
注意:在子类中实现父类中声明的抽象方法时,必须要理解这些抽象方法被调用的时机
在 c++ 中:相当于 virture 定义虚函数
'''
from abc import ABCMeta, abstractmethod
class Abstra... |
ecbbe63017ead8e16ba0e88c93b25794853bc7af | shashankm429/CS50_Shashank | /Pset6_Shashank/greedy.py | 497 | 3.75 | 4 | import cs50
def main():
while True:
print("How much change is owed?:")
change = cs50.get_float()
if change >= 0:
break
coinsNumber = 0
Change = int(round(change * 100))
coinsNumber += Change // 25
Change %= 25
coinsNumber += Change // 10
Ch... |
4dbe956221345fc21172a113256a6f2cb3fbc89d | akenYu/learnpy | /showme/12/replaceword.py | 433 | 4 | 4 | # 第 0012 题:敏感词文本文件 filtered_words.txt,当用户输入敏感词语,
# 则用 星号 * 替换
def replaceword(path):
word_list = []
with open(path, 'r') as f:
for word in f.read().split():
word_list.append(word)
# print(word_list)
inp = input('请输入一个句子:')
for i in word_list:
if i in inp:
print(inp.replace(i, '*'))
if __name__ == '... |
68f2d655840d3b4cd1b6a744af3ce588d7309834 | alsofro/GB_algorithms | /3/2.py | 773 | 3.703125 | 4 | # Во втором массиве сохранить индексы четных элементов первого массива. Например, если
# дан массив со значениями 8, 3, 15, 6, 4, 2, то во второй массив надо заполнить значениями 1,
# 4, 5, 6 (или 0, 3, 4, 5 - если индексация начинается с нуля), т.к. именно в этих позициях первого
# массива стоят четные числа.
import ... |
cc895bdb4d84dce7ead47eb9e661bf98b3ca8bc4 | alsofro/GB_algorithms | /1/1.py | 284 | 3.765625 | 4 | a = int(input('введите 3-х значное число: '))
a3 = a // 100
a2 = (a - a3 * 100) // 10
a1 = a - a3 * 100 - a2 * 10
sum3 = a1 + a2 + a3
comp3 = a1 * a2 * a3
print('сумма цифр = {}'.format(sum3))
print('произведение цифр = {}'.format(comp3))
|
92c7a7944639e194f4266749f56421fa480ea9d6 | alsofro/GB_algorithms | /2/4.py | 392 | 3.90625 | 4 | '''
Найти сумму n элементов следующего ряда чисел: 1 -0.5 0.25 -0.125 ...Количество элементов
(n) вводится с клавиатуры.
'''
x = 1
sum = 0
n = int(input('Введите количество слагаемых ряда: '))
for _ in range(n):
sum += x
x /= -2
print('Сумма ряда = {}'.format(sum))
|
6a668c75909beb04a3f7e7a0af215e47c12af356 | fabiojmendes/Math-for-Programmers | /Chapter 07/ex710.py | 376 | 3.53125 | 4 | import matplotlib.pyplot as plt
from vectors import *
def to_standard(u, v):
x1, y1 = u
x2, y2 = v
a = y2 - y1
b = x1 - x2
c = x1*y2 - x2*y1
return (a, b, c)
u = (3, 0)
v = (0, 1)
coords = [add(u, scale(i, v)) for i in range(50)]
xs, ys = zip(*coords)
std = to_standard(u, add(u, v))
prin... |
54db2a48a34d75e133cc3024a89a6adaa90d6075 | fabiojmendes/Math-for-Programmers | /Chapter 05/ex57.py | 416 | 3.546875 | 4 | from transforms import multiply_matrix_vector as proof
def multiply_matrix_vector(matrix, vector):
return tuple(
sum(col * coord for col, coord in zip(row, vector))
for row in matrix
)
if __name__ == "__main__":
A = (
(2, 1, 1),
(1, 2, 1),
(1, 1, 2),
)
v ... |
c33ae3ea29182638f3f6f565df4ea10efea20c1d | RocioMontero0803/unittestexample-1 | /main.py | 119 | 4.09375 | 4 | def is_odd(n):
# Function that returns a boolean. True if the number is odd, False if it is even.
return n % 2 == 1 |
e33852e26b6662422eeff789619db097768db0b0 | Cristopher-12/POO-1719110585 | /Semana_2/clase_vacaciones.py | 1,207 | 3.515625 | 4 | class Vacaciones:
#ATRIBUTOS
Entretenimiento = ""
Diversion = ""
Conocimiento = ""
Distraccion = ""
Comodidad = ""
#MÉTODOS
def desestresar(self):
print("Desestresar")
def gastar(self):
print("Gastar dinero")
def convivir(self):
print("Convivir c... |
6db8ae8971d79109a523c6760874bd0910b68fc7 | Cristopher-12/POO-1719110585 | /Semana_7/arreglos2.py | 3,733 | 4.0625 | 4 | print("[ TEMPERATURAS ]")
contador = 0 #variable contador
class Temperaturas: #definimos la clase
promedio_c = 0 #ayudara a almacenar en promedio °C
promedio_f = 0 #ayudara a almacenar el pomedio de °F
fechas = [] #almacena las fechas
centigrados = [] #almacena los °C
farentheit = [] #almacena la conve... |
eca83de7df6553e2513c9f6773123d0b89ea3c59 | Cristopher-12/POO-1719110585 | /Semana_5/cesartxt.py | 2,809 | 4 | 4 | print("[ CIFRAR/DESCIFRAR ARCHIVOS TXT ]")
class Cesartxt: #Definimos la clase primaria
def __init__(self): #definimos su metodo constructor
pass
def cifdesifrado(self): #Metodo que llevara a cabo el codigo que cifra o descifra
respuesta="S" #Variable que ayudara el bucle while
... |
6ddc282e3fa819f077a65146a131c9066b1fc7a7 | knissen123/University | /Homework 9.py | 4,988 | 3.5 | 4 | import unittest
from collections import defaultdict
from prettytable import PrettyTable
import os
def file_reader(path, number, header, separator):
'''part 2 of homework, path is file path, separate is separator, header is whether there is a header or not, number is number of fields'''
try:
... |
91a5a2dbc312d8819924bd2dbf28e998bba1c88c | DomSavickas/PirmojiPaskaita | /TreciaUzduotis.py | 585 | 3.953125 | 4 | # Trecia uzduotis
class third:
def get_input(self):
try:
char_list=[]
max_length=5
while len(char_list)<max_length:
char = input("Įveskite simbolį, raidę ar skaičių:")
char_list.append(char)
print('Pirmi trys simboliai: '+char_l... |
d6495586cd1a4b3d76b40030804a6af17f5e5821 | nicholas1026/Algorithm-diagram | /binary_search.py | 714 | 3.78125 | 4 | import random
#####生成指定个数随机数的有序列表#####
def make_list(nCount):
nList = []
n = 0
while n < nCount:
nList.append(random.randint(0,100))
n += 1
nList.sort()
return nList
#####二分查找函数#####
def binary_search(list,item):
low = 0
high = len(list) - 1
while low <= high:
... |
ea535be47821d1ef6a1d088529c77c7e51c18bb9 | ericlighthofmann/zillow_scrape | /Archive/zillow_zip2links.py | 305 | 3.671875 | 4 | """Takes a zipcode as input, gives you URLs of the properties."""
import selenium
from selenium import webdriver
import openpyxl
# UNCOMMENT THE FOLLOWING LINE FOR USER INPUT
# zipcode = input('Enter the zipcode: ')
zipcode = '92110'
print(zipcode)
URL = http://www.zillow.com/homes/for_sale/92110_rb/
|
80c52401a95e7b1edb898e75b985f5af85b8375c | kathiravan22/pythonpro | /count number of digits.py | 102 | 3.71875 | 4 | n=int(input("enter a number"));
count=0
while(n>0):
count=count+1
n=n//10
print("count is",count)
|
c8b59ab4c123aa74d690334d0daea7fc4e499f3f | andresfcardenas/SQL-String-Generator-Python | /generator/select.py | 1,188 | 3.578125 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Andres F. Cardenas
# Email: akardenasjimenez@gmail.com
instructions = (
'SELECT',
'WHERE',
'FROM',
)
def select(table_name, columns=None, table_esp=None, sign='=', value=None):
"""This function represent the select instruction.
"""
if is... |
edcbcb0e833b95c64b80696e2a324cf6d607895d | arifa06/ManualSort | /ManualSort.py | 1,695 | 4 | 4 | def manualSort(item): # membuat fungsi
angka = [] # menampung nilai sementara
for i in range (item): # membuat perulangan dengan for untuk input angka
num = int(input('Angka... |
4bd87146a4f85b80b2aed704a560ac6b66a98376 | morningwinter/Himalayas | /interview_questions/Python/lib/linked_list.py | 1,093 | 3.8125 | 4 | def print_linked_list(head):
node = head
if not head:
print 'NONE'
return
while node:
print " ->%s" % node.val,
node = node.next
print
def gen_linked_list(size):
head = None
if size:
for i in range(0, size):
tmp_node = head
head ... |
69b88db8d2103f12337dc1932bb2158536c53d14 | yenszen/Sprint-Challenge--Data-Structures-Python | /ring_buffer/ring_buffer.py | 866 | 3.546875 | 4 | class RingBuffer:
def __init__(self, capacity):
self.index = 0
self.capacity = capacity
self.data = []
def append(self, item):
if len(self.data) == self.capacity:
self.data[self.index] = item
else:
self.data.append(item)
self.inde... |
7e39ce35462594cfac7cd10cb87f72a782665587 | weih1121/Sort | /shellSort.py | 589 | 3.78125 | 4 | def ShellSort(array):
dk, length, j = 0, len(array), 0
while dk * 3 < length:
dk = dk * 3 + 1
print(dk, length)
while dk > 0:
for i in range(dk, length):
if (array[i] < array[i - dk]):
tmp = array[i]
j = i - dk
while j >= 0 and ... |
f22dff1300f7d3c45f433d7432356eb3c8356d85 | abhim-12/SL-Lab | /a9.py | 503 | 3.671875 | 4 | class Student:
name=""
age=0
marks=[]
def __init__(self,x,y,l):
self.name=x
self.age=y
self.marks=l
def accept(self):
self.name=input("Enter Name: ")
self.age=input("Enter Age: ")
print("Enter Marks: ")
l=input()
l=l.split()
x=[]
for i in range(len(l)):
x.append(int(l[i]))
self.marks=x
... |
27b6b990968bec685701a061da98c1e4258e32b6 | anastasiacebotari15/Instructiunea-If-While-For | /probl6.py | 414 | 3.734375 | 4 | #Se da numarul natural n.Sa se compare sumele S1 si S2, unde:
#a)S1=(1^3)+ (2^3)+...+(n^3) si S2=(1+2+...+n)^2
#b)S1=3((1^2)+(2^2)+...+(n^2)) si S2=(n^3)+(n^2)+(1+2+...+n)
n=int(input("Intrpduceti n : "))
s1=0
s2=0
p=0
for i in range(1,n+1):
s1+=i**3
p+=i
s2=p**2
if s1>s2:
print("s1 este mai... |
c130d758ef000ea0de0b0ed4154dfa711f0b4504 | D-Bits/Math-Scripts | /main.py | 1,918 | 4.40625 | 4 | from vectors import get_dot_product
from series import get_fibonacci, get_num_of_fib, sum_of_terms
from math import factorial
# Choices for the user
options = {
'1': 'Calculate the dot product of two vectors.',
'2': 'Get the sum of the first n terms in an arithmetic series.',
'3': 'Get a specific number in... |
096ac4e7c999f374495576ced8b6f9ac327a57de | pointmaster2/RagnarokSDE | /SDE/Resources/tut_part2.py | 1,281 | 4.3125 | 4 | """
Tutorial - Part 2
Selection
"""
# You can manipulate the selection of the editor and read its values.
# The example below prints the first three elements of the selected items.
if (selection.Count == 0):
script.throw("Please select an item in the tab!")
for tuple in selection:
print ... |
612a5eb267901530782ffe5f82876c970fe34f65 | robseeen/Python-Projects-with-source-code | /Mile_to_KM_Converter_GUI/main.py | 1,119 | 4.34375 | 4 | from tkinter import *
# creating window object
window = Tk()
# Program title
window.title("Miles to Kilometer Converter")
# adding padding to window
window.config(padx=20, pady=20)
# taking user input
miles_input = Entry(width=7)
# grid placement
miles_input.grid(column=2, row=0)
# showing input label
miles_label = ... |
5cba02efb718d3cfdb85ee3439261fb2fa28cf9f | robseeen/Python-Projects-with-source-code | /average_height_using_for_loop.py | 852 | 4.125 | 4 | # Finding average height using for loop.
# takeing students height and sperated
student_heights = input(
"Input a list of students heights. Seperated by commas.\n => ").split()
# checking the input in list
for n in range(0, len(student_heights)):
student_heights[n] = int(student_heights[n])
# printing the st... |
5526b7810d300e2f2cd2611281cca02b418804b9 | robseeen/Python-Projects-with-source-code | /whos_paying.py | 532 | 4.03125 | 4 | import random
# creating a random seed nubmer
test_seed = int(input("Create a seed number: "))
random.seed(test_seed)
# Split string method
nameAsCSV = input("Give me everybody's name, seperated by commas.\n =>")
names = nameAsCSV.split(", ")
# Get the total number of items in list
num_items = len(names)
# Generate... |
ee0b572d0cf4bcf6bad73e47773092a264514b32 | patidarjp87/python_core_basic_in_one_Repository | /56.sorttuple.py | 319 | 4.03125 | 4 |
print('program to sort tuple elements \n Enter a tuple')
p=eval(input())
l=list(p)
length=len(l)
r=1
while r<length:
i=0
while i<length-r:
if l[i]>l[i+1]:
t=l[i]
l[i]=l[i+1]
l[i+1]=t
i+=1
r+=1
else:
p=tuple(l)
print('sorted tuple is',p)
input()
|
530fb79024873eee062a23f2eec7096c00c2c3fc | patidarjp87/python_core_basic_in_one_Repository | /29.Co-Prime.py | 573 | 4.125 | 4 |
print('numbers which do not have any common factor between them,are called co-prime factors')
print('enter a value of a and b')
a=int(input())
b=int(input())
if a>b:
for x in range(2,b+1):
if a%x==0 and b%x==0:
print(a,'&',b,'are not co-prime numbers')
break
else:
continue
if x==b:
print(a... |
f8471e2937ec8f64d491a1856f103442e7ec41b3 | patidarjp87/python_core_basic_in_one_Repository | /71.cheacksubset.py | 461 | 4.34375 | 4 |
print("program to check whether a given set is a subset of another given set")
s1=set([eval(x) for x in input('enter elements in superset set 1 as it is as you want to see in your set with separator space\n').split()])
s2=set([eval(x) for x in input('enter elements subset set 2 as it is as you want to see in your set ... |
3fcf0263251d4d632e1b870efe795493a09f2d55 | patidarjp87/python_core_basic_in_one_Repository | /86.Nextprimeno.py | 357 | 4.09375 | 4 |
print("program to print next prime no. of a given no. \n Takes something returns something\n Enter a no.")
n=int(input())
def nextprime(n):
for x in range(n+1,n+100):
for y in range(2,x):
if x%y==0:
break
else :
return x
break
r=nextprime(n)
print... |
df67508b5f1cde2054b4e29cec34d07c5c05d5fd | patidarjp87/python_core_basic_in_one_Repository | /8.EvenOdd.py | 173 | 4.21875 | 4 |
n=float(input('enter a number'))
if n%2==0:
print("entered no. is even")
elif n>int(n):
print("entered no.is not even nor odd")
else:
print('no. is odd')
input()
|
d78cd51c22c282a5a5e9c2bdc69442237700985c | patidarjp87/python_core_basic_in_one_Repository | /92.Accoutclass.py | 1,168 | 4.25 | 4 |
print("define a class Account with static variable rate of interest ,instance variable balance and accounr no.make function to set them")
class Account:
def setAccount(self,a,b,rate):
self.accno=a
self.balance=b
Account.roi=rate
def showBalance(self):
print("Balance is ",self.b... |
33086a86c05bbe02f533a5ab09c8c2e1fef4b50a | patidarjp87/python_core_basic_in_one_Repository | /35.SquareOfNumbers.py | 337 | 3.953125 | 4 |
print("print Square of numbers from a to b\n enter values of a and b")
a=int(input())
b=int(input())
for x in range(a,b+1):
print(x**2,end=' ')
print('use of range \nenter step size s and boundary values a and b')
s=int(input())
a=int(input())
b=int(input())
for x in range(a,b+1,s):
print(x,end=' ')
input("\npress ... |
776b3c99569733f3f1746eb1dee10bb971d52684 | patidarjp87/python_core_basic_in_one_Repository | /84.countwords.py | 221 | 4.125 | 4 |
print("script to ciunt words in a given string \n Takes somthing returns something\n Enter a string")
s=input()
def count(s):
l=s.split()
return len(l)
print('no. of words in agiven string is ',count(s))
input()
|
ce9068cc52a7a84db8d10c3aad411200aa54d380 | patidarjp87/python_core_basic_in_one_Repository | /14.LeapYear.py | 206 | 4.09375 | 4 |
n=int(input("enter a year"))
if n%400==0:
print(n,"is a leap year")
elif n%100!=0 and n%4==0:
print(n,"is a leap year")
else:
print(n,"is not a leap year")
input("press enter to exit")
|
3e0dd0a7c205421f897bca3ce6e72bc3cf894ef5 | patidarjp87/python_core_basic_in_one_Repository | /50.countwords.py | 138 | 4.28125 | 4 |
print('program to count no. of words in a given string\n Enter a string')
s=input()
l=s.split()
print('no. of words are',len(l))
input()
|
6702e791c43e07402cc095d6f7341929ced68b8b | patidarjp87/python_core_basic_in_one_Repository | /62.comparetwotuples.py | 233 | 4.0625 | 4 |
print("program to compare two tuples\nEnter 1st tuple ")
t1=eval(input())
t2=eval(input("enter 2nd tuple\n"))
if t1==t2:
print("Both tuples contain same elements")
else:
print("Tuples does not cotain same elements")
input()
|
70d0a2b087e2092eed84433acbdd137bbfcd8ec4 | patidarjp87/python_core_basic_in_one_Repository | /69.union.py | 351 | 4.09375 | 4 |
print("program to find union bw two sets")
s1=set([eval(x) for x in input('enter elements for set 1 as it is as you want to see in your set with separator space\n').split()])
s2=set([eval(x) for x in input('enter elements for set 2 as it is as you want to see in your set with separator space\n').split()])
print('union... |
dfe1080317a0b65715bd815913a359217e35523b | VatsalOjha/CurProject | /Project/testingCode.py | 28,433 | 3.59375 | 4 |
def pigLatin5(s):
result=""
for word in s.split():
result += (word+"yay ")
return result.strip()
def testTestPigLatin():
print("Testing testPigLatin()...")
successCount = 0
try:
testPigLatin(pigLatin1)
print("pigLatin1: passed")
successCount += 1
... |
2bb07e04c7d9ddd84b744b29b41c232f6b4a4651 | vyhaophan/probability | /HackerRank's 10 Days of Statistics/Day_00_Mean_Median_Mode.py | 1,098 | 3.5625 | 4 | # I avoided using library despite their ability to save my time.
# To be honest, these are my first Python code in a while
# I haven't used Python for about 2-3 months, so maybe my code style is not clean enough. Pardon me if there are any issues.
# Get the input parameters
N = int(input())
X = input()
numbers = [int(... |
ca903da90a4a8ce81c24bcc3258259facbef43eb | kapari/exercises | /pydx_oop/adding.py | 629 | 4.15625 | 4 | import datetime
# Class that can be used as a function
class Add:
def __init__(self, default=0):
self.default = default
# used when an instance of the Add class is used as a function
def __call__(self, extra=0):
return self.default + extra
add2 = Add(2)
print(add2(5))
# >> 7
class Pers... |
20aba320ac1f08e8e091d8c576d3b5337f22401e | vioo-bkp/Google-Digital-Workshop | /Curs2/main.py | 446 | 3.921875 | 4 | l = [7, 8, 9, 2, 3, 1, 4, 10, 5, 6]
print("Lista initiala: ", l);
sorted_list = l.copy()
sorted_list.sort()
print("Lista sortata: ", sorted_list)
sorted_list2 = l.copy()
sorted_list2.sort()
sorted_list2 = sorted_list2[::-1]
print("Lista sortata descrescator: ", sorted_list2)
print("Numerele pare din lista: ", sorted... |
8a455b69b0724623f701d8fc6e44d0203d2b9143 | charlielin99/McGill-Bioinformatics-UnderGrad | /Assignment 3/mining_electronic_health_records.py | 19,299 | 3.625 | 4 | import pandas as pd
import json
import math
import gzip
import operator # sort dictionary in bonus
# !/Users/yueli/anaconda3/bin/python
# q1 reading ICD-9 definitions
def process_icd9_file(filename):
"""
args:
filename: Name of file containing ICD-9 definition
returns:
dictionary of diction... |
34daf4eb832c31b4b0ba4b74271588db25a498f2 | leopold-lll/aRobotToFollowPeople | /utils/storeVideo.py | 2,891 | 3.59375 | 4 | # import the necessary packages
from imutils.video import VideoStream
import cv2
class StoreVideo:
# The class accept a sequence of frames and store them as a video.
def __init__(self, output: str="out", show: bool=False, fps: int=50, width: int=None):
"""
Initialization function of the StoreVideo cla... |
9430a52182219ca0d525e06f439209ff93eb9b27 | sru/leetcode | /src/1678.py | 490 | 3.71875 | 4 | class Solution:
def interpret(self, command: str) -> str:
i = 0
interpretation = []
while i < len(command):
if command[i] == 'G':
interpretation.append('G')
elif command[i] == '(' and command[i+1] == ')':
i += 1
interpre... |
a6b026495dbd32b80c73e4443fdeed38c0e43e86 | amcosta/python-w3school | /multa-de-velocidade.py | 377 | 3.71875 | 4 | limiteDeVelocidade = 100
multaPorKm = 5
velocidade = int(input('Informe a valicidade do veiculo'))
if velocidade > limiteDeVelocidade:
print('O veiculo esta acima da velocidade permitida');
multa = (velocidade - limiteDeVelocidade) * multaPorKm
print('O valor da multa é: R$ {:.2f}'.format(multa))
else:
... |
8fed261a158947ba8e8b2a19967e5e467f507a54 | amcosta/python-w3school | /fatorial-com-funcao.py | 273 | 3.796875 | 4 | def fatorial(numero, quantidade):
fat = 1
i = 1
for i in range(quantidade):
fat *= numero
return fat
numero, quantidade = input('Diginte o número e a quantidade (separado por virgula): ').split(',')
print(fatorial(int(numero), int(quantidade))) |
6df37ec3e979c9507c2256281fbbeb9f5de32a46 | amcosta/python-w3school | /latas-de-tinta.py | 407 | 3.765625 | 4 | precoLata = 80
litrosLata = 18
metrosPorLitro = 3
metrosPorLata = litrosLata * metrosPorLitro
area = int(input('Informe o valor da área pintada: '))
quantidadeLatas = int(area / metrosPorLata)
if area % metrosPorLata != 0:
quantidadeLatas += 1
print('Para pintar a área de {:d}m² são necessárias {:d} latas, com... |
bea206bb331978c639c0e27645d4f74483bb4ad2 | natcaos/Compu-Grafica | /ciclo2.py | 152 | 3.59375 | 4 |
ls=[3,4,45, [2,5,7], 'hola', False]
for elemento in ls:
print elemento, type(elemento)
if type(elemento)== int:
print 'entero'
print e
|
108ed6ed2402f0f09d31025b874e15eeb8e44413 | channel960608/python-leanring | /lambda.py | 220 | 3.65625 | 4 | a = list(map(lambda x:x * x, [1, 2, 3, 4, 5, 6, 7, 8, 9]))
print(a)
def is_odd(n):
return n % 2 == 1
L = list(filter(is_odd, range(1, 20)))
L2 = list(filter(lambda x: x % 2 == 1, range(1, 20)))
print(L)
print(L2)
|
e1d3804cb5bfdbd3bac6969ccac8dced6fca8f8f | channel960608/python-leanring | /use_pillow.py | 313 | 3.546875 | 4 | from PIL import Image, ImageFilter
im = Image.open('test.jpg')
w, h = im.size
print('Original image size: %sx%s' % (w, h))
#模糊
im2 = im.filter(ImageFilter.BLUR)
im2.save('blur.jpg', 'jpeg')
#缩放
im.thumbnail((w//2, h//2))
print('Resize image to: %sx%s' % (w//2, h//2))
im.save('thumbnail.jpg', 'jpeg')
|
3d0bf0530b97e8b7dc82e0595664fb150868d009 | Sorcy32/VLessons | /dict_to_csv.py | 1,240 | 3.75 | 4 | """
Домашнее задание №2
Работа csv
* Создайте список словарей с ключами name, age и job
* Запишите содержимое списка словарей в файл в формате csv
"""
import csv
def main():
"""
Эта функция вызывается автоматически при запуске скрипта в консоли
В ней надо заменить pass на ваш код
"""
db=[{"age":"18... |
245e199e396002bbe33260ef115df904b2e6f1ab | kurrenda/aplikacja | /Zajecia_2/Cw4.py | 242 | 3.671875 | 4 | def temperature(a):
C = float(a)
temperature_f = float(32) + float((9/5)) * C
temperature_k = C + 273.15
temperature_r = (9/5) * float(temperature_k)
print(temperature_f, temperature_k, temperature_r )
temperature(40) |
50bf488055ece3cdfcdb211374ae547ae3e3116c | kurrenda/aplikacja | /Zajecia_2/Cw2.py | 377 | 3.578125 | 4 | def text(data_text):
slownik = {}
lenght = len(data_text)
slownik["Dlugosc"] = lenght
letters = [i for i in data_text]
slownik["Litery"] = letters
big_letters = data_text.upper()
slownik["Duze litery"] = big_letters
small_letters = data_text.lower()
slownik["Male litery"] = smal... |
4fcdf207fa5a5520e3a5c78551ae93c99d625029 | NitinSikarwar-32/Practice-1 | /Python Practice1/words_reprentation.py | 718 | 3.5625 | 4 | '''
Word representation:
input=100
output=one hundred
'''
ones=['','one','two','three','four','five','six','seven','eight','nine']
tens=['','','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']
hundreds=['','hundred','thousand']
twos=['','eleven','twelve','thirteen','fourteen','fifteen','sixteen','s... |
2adc7450daa8876b14fd9ee76db131e2ba7c187b | NitinSikarwar-32/Practice-1 | /Anagram_string.py | 263 | 4.0625 | 4 | '''
Anagram : The anagram of string is another string that contains same characters,only the order of characters are different.
ex: triangle,integral.
'''
a=input()
b=input()
if(sorted(a)==sorted(b)):
print("Anagram")
else:
print("Not Anagram")
|
36556ded52aa6687537f29deaa2aa127a4332349 | dangduongcoder/-Python-Simple-Snake-Game | /main.py | 4,331 | 3.515625 | 4 | import pygame
import time
import random
'''
SIMPLE SNAKE GAME
date : 6.4.2020
author : Truong Dang Duong
facebook : https://www.facebook.com/duongdzin
(Something in original snake game is not in there , I'm lazy to do more)
'''
BLOCK_SIZE = 20
GAME_MAX_X = 60
GAME_MAX_Y = 60
GAME_... |
7bc8dd1fa387a0b44eba18b530248adf37f6bebd | sasirajpuvvada/python-explore | /python-logging/basci-logging.py | 606 | 3.71875 | 4 | import logging
logging.basicConfig(level=logging.DEBUG, filename='test.log')
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
return x / y
num1 = 20
num2 = 2
result = add(num1, num2)
logging.debug("Add {} {} = {}".format(num1, num2... |
dc88a551fe2a1664ce64a5137bcf6cf7ab6d56fa | gurukanth/algorithms-ds | /fibnocci.py | 311 | 3.703125 | 4 | def fib(n, memo:dict={}):
if n in memo:
return memo[n]
if n <= 2:
return 1
else:
memo[n] = fib(n-1, memo) + fib(n-2, memo)
return memo[n]
print(fib(50))
print(fib(2))
print(fib(3))
print(fib(4))
print(fib(5))
print(fib(6))
print(fib(7))
print(fib(8))
print(fib(9)) |
1655cadd5067cab0518be10a06e6808b614f6b76 | Aegis-Liang/Python | /HackerRank/Statistic/day0_1_Mean_Median_and_Mode.py | 246 | 3.609375 | 4 | import numpy as np
from scipy import stats
#size = int(raw_input(""))
#numbers = map(int,raw_input("").strip().split(' '))
size = 5
numbers = [1, 1, 1, 2, 3]
print(np.average(numbers))
print(np.median(numbers))
print(stats.mode(numbers)[0][0]) |
394e21f7262da6bedbb53a667bc738662033d26a | Aegis-Liang/Python | /HackerRank/Data Structure/2_LinkedLists/10_GetNodeValue.py | 2,559 | 4.25 | 4 |
"""
Get Node data of the Nth Node from the end.
head could be None as well for empty list
Node is defined as
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
return back the node data of the linked list in the below method.
"""
def Get... |
d525e7b1fc92767c602e4911fed11253e09d58ff | Aegis-Liang/Python | /HackerRank/Data Structure/2_LinkedLists/2_InsertANodeAtTheTailOfALinkedList.py | 1,553 | 4.28125 | 4 |
"""
Insert Node at the end of a linked list
head pointer input could be None as well for empty list
Node is defined as
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
return back the head of the linked list in the below method
"""
de... |
5f0be8c10f4b6b33cad7c3da87483fc7e44fe53a | Aegis-Liang/Python | /HackerRank/Data Structure/1_Arrays/4_LeftRotation.py | 1,389 | 3.8125 | 4 | #setup_arr = map(int,raw_input().strip().split(' '))
#arr = map(int,raw_input().strip().split(' '))
arr = [1, 2, 3, 4, 5]
#d = setup_arr[1]
d = 4
start = 0
start = (start + d) % len(arr)
arr_new = arr[start:]
arr_new.extend(arr[0:start])
print " ".join(map(str, arr_new))
"""
A left rotation operation on an array... |
0f4f86f61546e0efb1e3e3b25b3924f874f41a99 | Aegis-Liang/Python | /Design of Computer Programs/Lesson 2/1_5-Nitty Gritty For Loops.py | 238 | 3.828125 | 4 | for x in items:
print x
# ===================>>>
i = 0
while i < len(items):
x = items[i]
print x
# Itemable
it = iter(items)
try:
while True:
x = next(it)
print x
except StopIteration:
pass |
62351503e0025c4fd5c358a16036c52d48eccac6 | Aegis-Liang/Python | /HackerRank/Data Structure/2_LinkedLists/3_InsertANodeAtTheHeadOfALinkedList.py | 1,496 | 4.21875 | 4 | """
Insert Node at the begining of a linked list
head input could be None as well for empty list
Node is defined as
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
return back the head of the linked list in the below method.
"""
def In... |
7e7448d4cd27edbb9b0c08c79e8c0d31a68fd3a6 | shreyazz/Number-guessing-game-in-tkinter | /maingame.py | 5,763 | 3.765625 | 4 | # made by Shreyas Pahune
import tkinter as tk
from random import randrange
import tkinter.font as font
from tkinter import messagebox
from tkinter import LabelFrame
window = tk.Tk()
window.title("Guessing Game")
window.config(bg="#41aea9")
myFont = font.Font(family='Comic Sans MS Bold')
window.iconbitmap(r"... |
c30ae41af1d4472229860447af0128783fde6cd6 | wchian2/Python_Health | /Automate_the_boring_stuff_with_python/chapter4_lists.py | 1,182 | 3.671875 | 4 | # Passing references
def eggs(someParameter):
someParameter.append("Hello")
spam = [1,2,3]
eggs(spam)
print(spam)
# Practice assignments
# Comma Code
spam = ['apples', 'bananas', 'tofu', 'cats']
def listingOut(list):
newList = []
for i in list[:-1]:
newList.append(i)
newList.append("and " ... |
d0046599eb7c994a6458fc9005b510b7ec89492a | Cvke/compuational_physics_N2014302580257 | /Exercise_07-Chapter-3-problem-3.12-3.14-Chaos-in-Physical-Pendulum/Codes/ex7-5.py | 1,444 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Oct 31 02:51:48 2016
@author: Administrator
"""
import math as mt
import matplotlib.pyplot as plt
# define a function that given amplitude of force, gives theta,omega and t
def change_amp(F,T):
# define some constants
l = 9.8
g = 9.8
q=0.... |
14c83f8519ca27a8e886887846160b6291f9af74 | dcreamer/eulerproblems | /euler_problem_28.py | 266 | 3.53125 | 4 | #!/usr/bin/env python3
import numpy as np
import random
# Problem 28
def num_spiral(n):
nums=[1]
x=1
spirals=n-2
for aa in range(1,spirals):
for bb in range(0,4):
x=x+(2)*aa
nums.append(x)
if x>spirals**2:
break
print(sum(nums))
num_spiral(1001)
|
3f4071529acedb3df3a535e9c7edcbf855152ad9 | dcreamer/eulerproblems | /euler_problem_6.py | 341 | 3.8125 | 4 | #!/usr/bin/env python3
import numpy as np
import random
# Problem 6
def sum_sqr_dif(n):
def sum_sqrs(x):
blah=[]
for aa in range(x+1):
blah.append(aa**2)
y=sum(blah)
return y
def sqr_sums(x):
blah=[]
for aa in range(x+1):
blah.append(aa)
y=sum(blah)**2
return y
z=sqr_sums(n)-sum_sqrs(n)
print... |
9e65b33a920e0fabbfbb304e30a182e3580c7e15 | RUC-CompThinking18/pythonproject-Cintronny | /TuitionCondition.py | 2,013 | 3.671875 | 4 | # -*- coding: utf-8 -*-
import re
import random
import time
#The goal of this project is to
#Due to incredible lack of ability to solve my issues with understanding textblob I decided to remove that portion of my code all together.
#As an adjustment I decided to take the top 50 tweets on that had the word "tuition" i... |
adc03f070d075c6beb81625c06bd8d9a05ad364b | ajluicifer/calculator | /Calculator.py | 3,692 | 4.03125 | 4 | #Program to design a simple Calculator using GUI Tkinter
#importing required module
from functools import partial
from tkinter import *
#Defining global variable for calculation
calc_euation=""
##Define various command functions
#function when a Button is pressed
def press_but(key):
global calc_euati... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.