blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
241f27d852cd7afe98e48478230ee1cd92ebf611 | enzo-mandine/runtrack-python | /jour04/job08/main.py | 700 | 3.828125 | 4 | def defineX(d, posX):
if posX == d:
posX = 1
elif posX == d - 1:
posX = 0
else:
posX += 2
return posX
def printBoard(board):
i = 0
while i < len(board):
print(board[i])
i += 1
def placeQueen(board, posY, posX):
d = len(board)
board[posY][posX] ... |
ae89977da0668433e3c01f41c89f216feb9848e1 | GregGamer/python_homework | /Übungsblatt3/U3Bsp6.py | 1,344 | 3.53125 | 4 | """
Gregor Wagner
U3Bsp6.py - Klassen Kreis, Rechtek, Quadrat mit Methoden
Gregor Wagner, 52005240
"""
from cmath import pi as pi
class Kreis:
def __init__(self, radius):
self.radius = radius
def flaeche(self):
f = self.radius * self.radius * pi
return round(f, 2)
def umfang(self)... |
172cf6da126911110dda329d13e074e642d76bb1 | remote-worker-id/crash-course2-modularisasi | /modularisasi_tahap_1.py | 1,655 | 4.0625 | 4 | '''
Program menghitung luas segitiga = alas * tinggi / 2
'''
print('Menghitung luas segitiga 1 dengan copas')
alas = 6
tinggi = 2
luas_segitiga = alas * tinggi / 2
print(f'Segitiga dengan alas = {alas} dan tinggi = {tinggi} luasnya adalah = {luas_segitiga}')
print('Menghitung luas segitiga 2 dengan copas')
alas = 12
ti... |
b0f27e95ea3045f77f5caff05b0ca70a2cc6e318 | AndreSlavescu/DMOJ | /Fraction-Action.py | 431 | 3.953125 | 4 | #https://dmoj.ca/problem/ccc02s2
from fractions import Fraction
div = int(input())
num = int(input())
result = div//num
remainder = div - num * result
newfraction = Fraction(remainder, num)
if result * num < div and result != 0 and num < div:
print(str(result)+" "+str(newfraction))
elif num > div:
print(st... |
faba607c88ad0c595e06005d504ec42be76ff056 | AndreSlavescu/DMOJ | /WhoIsInTheMiddle.py | 305 | 3.65625 | 4 | #https://dmoj.ca/problem/ccc07j1
bowl1= int(input())
bowl2 = int(input())
bowl3 = int(input())
if (bowl1 > bowl2 and bowl1 < bowl3) or (bowl1 > bowl3 and bowl1 < bowl2):
print(bowl1)
elif (bowl2 > bowl1 and bowl2 < bowl3) or (bowl2 > bowl3 and bowl2 < bowl1):
print(bowl2)
else:
print(bowl3) |
0fe1d27bae934a01dc7c93e023d1bba924fc780a | AndreSlavescu/DMOJ | /RollTheDice.py | 317 | 3.609375 | 4 | #https://dmoj.ca/problem/ccc06j2
m = int(input())
n = int(input())
total = 0
for i in range(1, m+1):
for j in range(i,n+1):
if i+j == 10:
total = total + 1
if total == 1:
print(f"There is {total} way to get the sum 10.")
else:
print(f"There are {total} ways to get the sum 10.")
|
5077815f19f7bd1d729650704069e64e448cd89c | Souravdg/Python.Session_4.Assignment-4.2 | /Vowel Check.py | 776 | 4.15625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
"""
Problem Statement 2:
Write a Python function which takes a character (i.e. a string of length 1) and returns
True if it is a vowel, False otherwise.
"""
def vowelChk(char):
if(char == 'a' or char == 'e' or char == 'i' or char == 'o' or char == 'u'):
ret... |
2ff83f165b89c4b0d36166ccdfbdb54974ad17f7 | Gsoin/randomStuff | /phonewithREGEX.py | 165 | 4.0625 | 4 | import re
import sys
phoneNum = input("Please Enter Your Phone Number: ")
regex = r"\w{3}-\w{3}-\w{4}"
lmao = re.search(regex, phoneNum)
print(lmao)
|
a2f4d8df9a88780d1528261d23a387787f3871a5 | angulo4/python | /dni-letra.py | 1,110 | 3.640625 | 4 | def dnil(dni):
# convert DNI to integer before '%'
let = ((int(dni)) % 23)
if let == 0:
return 'T'
elif let == 1:
return 'R'
elif let == 2:
return 'W'
elif let == 3:
return 'A'
elif let == 4:
return 'G'
elif let == 5:
return 'M'
elif le... |
fb6ac747fcf5d0fc4fc360cdfbb7e146f9e099e4 | sharyar/design-patterns-linkedin | /visitor.py | 1,285 | 4.25 | 4 | class House(object):
def accept(self, visitor):
''' The interface to accept a visitor '''
# Triggers the visiting operation
visitor.visit(self)
def work_on_hvac(self, hvac_specialist):
print(self, 'worked on by', hvac_specialist)
# This creates a reference to the HVAC s... |
9e535f3debddcf01e1285c9de932c93b7d886561 | panenming/demo | /process.py | 421 | 3.625 | 4 | '''
python线程池使用
'''
import multiprocessing
import time
def func(msg):
print("msg:",msg)
time.sleep(3)
print("end")
if __name__ == '__main__':
pool = multiprocessing.Pool(processes=3)
for i in range(4):
msg = "hello %d" %(i)
pool.apply_async(func,(msg,))
print("Mark~ Mark~ Mark~... |
fb6ef873a4798349dda0d45aacc4ced5f63d65ba | spoorgholi/Python-Mini-projects | /encryption/encryption.py | 3,053 | 3.765625 | 4 | #importing the libraries
import random as rnd
################################################################
#function to get the message from the user
response_type = input('Do you want to input a message or read from the text file? (msg\text) \n')
if response_type == 'msg':
message = input('Input your messag... |
226310768c827fd3f8d2d03302563f4e10241e25 | scv119/thehardway | /leetcode/023.swapPairs/swapPairs.py | 987 | 3.75 | 4 | #leetcode: https://leetcode.com/problems/swap-nodes-in-pairs/description/
def swapPairs(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
# time: O(n), space: O(1)
if head == None or head.next == None:
return head
sentry = pre = ListNode(0)
sentry.next = head
first ... |
9af344d4575cad7e5a4df91d5806417f7d05c141 | scv119/thehardway | /leetcode/010.intersectionLinkedList/interseciontLinkedList.py | 1,032 | 3.703125 | 4 | # leetcode: https://leetcode.com/problems/intersection-of-two-linked-lists/#/description
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def getIntersectionNode(self, headA, headB):
"""
: type headA, headB: ListNode
: ... |
9dd9050ffca4e9c67628c713695472613b6ef5bd | mas254/tut | /String methods.py | 349 | 4.125 | 4 | course = "Python for Beginners"
print(len(course))
print(course.upper())
print(course.find("P"))
# You get 0 here as this is the position of P in the string
print(course.find("z"))
# Negative 1 is if not found
print(course.replace("Beginners", "Absolute Beginners"))
print(course)
print("Python" in course)
# All case se... |
132d54605b7b373f7d8494dce66665cf80cd9373 | mas254/tut | /creating_a_reusable_function.py | 935 | 4.28125 | 4 | message = input('>')
words = message.split(' ')
emojis = {
':)': 'smiley',
':(': 'frowney'
}
output = ''
for word in words:
output += emojis.get(word, word) + ' '
print(output)
def emojis(message):
words = message.split(' ')
emojis = {
':)': 'smiley',
':(': 'frowney'
}
outpu... |
7a1229b6dafcccfa6877302a07c694eee6d82b4a | mas254/tut | /if statements.py | 995 | 3.953125 | 4 | # if it's hot
# it's a hot day
# drink plenty of water
# otherwise if it's cold
# it's a cold day
# wear warm clothers
# otherwise
# it's a lovely day
is_hot = False
if is_hot:
print("It's a hot day")
print("Drink plenty of water")
print("Enjoy your day")
is_hot = True
if is_hot:
pri... |
cbec22cf9f6d6130b5a038c465391857c462ce30 | Alist07/pyintro | /temp.py | 152 | 3.71875 | 4 | c = -1
factor = 1.8
result = c * 1.8 + 32
print("If its is "+str(c)+" degrees celcius outside, then it is "+str(result)+" degrees fahrenheit outside")
|
f44e664979e4a35608643e72ab9ce4d38041c7f7 | xinhen/AutomaticTestSummarizer | /third.py | 887 | 3.578125 | 4 | import tkinter
from tkinter import *
from gui import window, bottom_frame
global thirdlabel
global thirdbutton
global thirdbutton1
def goback():
thirdbutton.destroy()
thirdbutton1.destroy()
thirdlabel.destroy()
exec(open(r".\fourth.py").read())
def gotosix():
thirdbutton.dest... |
00c5ee50e9991dc8c5e16ae6bd5ec1b78cf48147 | jiyeon2/coding-test-practice | /leetcode/344_reverse_string.py | 510 | 3.859375 | 4 | # list.reverse() 메서드 사용
class Solution:
def reverseString(self, s: List[str]) -> None:
s.reverse()
# 투포인터 사용(두개의 포인터 이용해 범위 조정하면서 풀이)
class Solution:
def reverseString(self, s: List[str]) -> None:
left = 0 # 배열의 첫번째 요소
right = len(s)-1 # 배열의 마지막 요소
while left < right:
... |
844f4ebb10a44eacaffbb01b459a53463272f39f | ruanyangry/pycse-data_analysis-code | /PYSCE-code/11.py | 563 | 3.6875 | 4 | # _*_ coding: utf-8 _*_
import numpy as np
import matplotlib.pyplot as plt
def f(x):
return np.sin(3*x)*np.log(x)
x = 0.7
h=1e-7
# analytical derivative 貌似下式是对函数求偏导
dfdx_a = 3*np.cos(3*x)*np.log(x)+np.sin(3*x)/x
# finite difference 有限差分
dfdx_fd = (f(x+h)-f(x))/h
# central difference 中心差分
... |
76f1da5bc35d4ba5d777163877369f69d85f39d7 | kellischeuble/cs-module-project-algorithms | /single_number/single_number.py | 862 | 3.890625 | 4 | '''
Input: a List of integers where every int except one shows up twice
Returns: an integer
'''
def single_number(arr):
repeats = list()
for i, num in enumerate(arr):
if not num in arr[i+1:] and not num in repeats:
return num
repeats.append(num)
# First solution:
# Loo... |
65df669d4c69dc87a639fda570fa464d19b1d325 | 1bm17cs074-ravi/PP-Lab | /fibo.py | 116 | 3.625 | 4 | def fib(n):
if n==0:
return 1
else:
return n*fib(n-1)
n = int(input())
print(fib(n))
|
2b11a6a7cc7072124064b071e3b29e59226e7faa | Hannigan/bipartite | /bipartite_push_relabel.py | 6,339 | 3.71875 | 4 | #!//Library/Frameworks/Python.framework/Versions/2.7/bin/python
from random import shuffle, seed, sample
from sys import argv
class Edge:
def __init__(self, left, right, height=0):
self.left = left
self.right = right
self.order = ""
self.direction = ""
self.capacity = 1
... |
ae70140bf88116bd3b0b37ff5e6d1bdf91d2add1 | archibald1418/hello-people | /calc_sqrt.py | 375 | 4.09375 | 4 | def calc_root(n, limit):
'''Calculate using Babylon. Limit is the number of iterations'''
x1 = 1
for i in range(limit):
x_n_plus_1 = 1/2 * (x1 + (n / x1))
x1 = x_n_plus_1
return x1
n = int(input("Введите основание корня: "))
for i in [10, 100, 1000]: # Test on whether accuracy improves with more iterations
... |
fbd4d0daacc9b3966b28e8bebd05aae4e5810e90 | sabach/restart | /test1.py | 257 | 4 | 4 | counter = 1
while (counter < 5):
count = counter
if count < 2:
counter = counter + 1
else:
print('Less than 2')
if count > 4:
counter = counter + 1
else:
print('Greater than 4')
counter = counter + 1
|
cda3560dfafcb1c358ea0c6ff93477d6e868bb68 | sabach/restart | /script10.py | 540 | 4.375 | 4 | # Write a Python program to guess a number between 1 to 9.
#Note : User is prompted to enter a guess.
#If the user guesses wrong then the prompt appears again
#until the guess is correct, on successful guess,
#user will get a "Well guessed!" message,
#and the program will exit.
from numpy import random
randonly_sele... |
bab4919fc4a74ad44e2828e8214d8801e8854ab2 | sabach/restart | /random_text.py | 435 | 3.90625 | 4 | #lista=['a', 'b', 'c','d']
#print(lista)
#for i in lista:
# print(i)
import random
#listb=[]
#n=int(input("insert name: "))
#for I in range (0, n):
# ele=str(input("enter: "))
# listb.append(ele)
# print(listb)
listc=[]
x=int(input("enter number: "))
y=int(input("enter second number: "))
for i in range(x,y):
list... |
a65562f771f2a303f652c05cb16f75f27d3ebefe | shwethav29/ShowMeDatastructure | /merge_sorted_list.py | 1,958 | 4.03125 | 4 | class Node(object):
def __init__(self,value):
self.value = value
self.next = None
class LinkedList(object):
def __init__(self):
self.head = None
def append(self,node):
if(self.head == None):
self.head = node
return
else:
current =... |
4658d4dd37d4432ea582bf11f8d3894911e4fab6 | VelizarMitrev/Python-Homework | /Homework3/venv/Exercise1.py | 176 | 4.0625 | 4 | def factorial(num):
if int(num) == 1:
return 1
return factorial(int(num)-1) * int(num)
inpur_number = input("Input a number: ")
print(factorial(inpur_number)) |
713773b1c5d7b50b23270a1ac5f7ca2aa62ac58b | VelizarMitrev/Python-Homework | /Homework1/venv/Exercise6.py | 343 | 4.34375 | 4 | nand = input("Choose a number ")
operator = input("Input + OR * for either computing a number or multiplying it ")
sum = 0
if operator == "+":
for x in range(1, int(nand) + 1):
sum = sum + x
if operator == "*":
sum = 1
for x in range(1, int(nand) + 1):
sum = sum * x
print("The final ... |
797e50d61535310dfdb4a6527db3bdcf9004d977 | VelizarMitrev/Python-Homework | /Homework4/venv/Exercise4.py | 417 | 3.96875 | 4 | number_list = [3, 6, 13, 2, 3, 3, 13, 5, 5]
occurences_dictionary = {}
for number in number_list:
if number not in occurences_dictionary:
occurences_dictionary[number] = 1
else:
occurences_dictionary[number] = occurences_dictionary[number] + 1
for number in occurences_dictionary:
print("T... |
ef91c75a3f4b16b4529a0d6e88db23f78a1bdf38 | VelizarMitrev/Python-Homework | /Homework1/venv/Exercise7.py | 356 | 4.03125 | 4 | import sys
vowels = ['a','o','u','e','i','y'] # I'm including 'y' as a vowel despite that 'y' can be both a vowel and a consonant
vowels_count = 0
print("Type something and I will count the vowels!")
input_text = input()
input_text = list(input_text)
for x in input_text:
if x in vowels:
vowels_count = vo... |
b44c3fcdf3aa99d88f9d5a03c7d12cb64e9715d6 | VelizarMitrev/Python-Homework | /Homework2/venv/Exercise10.py | 387 | 4.34375 | 4 | def fibonacci(num): # this is a recursive solution, in this case it's slower but the code is cleaner
if num <= 1:
return num
else:
return(fibonacci(num-1) + fibonacci(num-2))
numbers_sequence = input("Enter how many numbers from the fibonacci sequence you want to print: ")
print("Fibonacci sequenc... |
6b48bbaadd59de3f10f2784c195b19ac43e107fd | MadJFish/DataPipeline | /WFQ/nearby_resale/1_get_filtered_distance.py | 2,582 | 3.65625 | 4 | from math import radians, cos, sin, asin, sqrt
import pyspark.sql.functions as sql_functions
from pyspark.sql import SparkSession
from pyspark.sql.functions import lit
from pyspark.sql.types import *
APP_NAME = "get_filtered_distance" # Any unique name works
INPUT_RESALE_FILE = "../resale-flat-prices/cleaned_data/re... |
02d3f469da092a1222b12b48327c61da7fc1fea3 | mvargasvega/Learn_Python_Exercise | /ex6.py | 903 | 4.5 | 4 | types_of_people = 10
# a string with embeded variable of types_of_people
x = f"There are {types_of_people} types of people."
binary = "binary"
do_not = "don't"
# assigns a string to y with embeded variables
y = f"Those who know {binary} and those who {do_not}."
print(x)
print(y)
print(f"I said: {x}")
# printing a st... |
0933d196941665856228eb849dda31babe7876ea | GustavoGomes9/python_basics_review | /ex10.py | 339 | 3.9375 | 4 | # class inheritance
class Mother:
def __init__(self, dna='mother'):
self.dna = dna
def dna_test(self):
return self.dna
m = Mother('mother-alone')
print(m.dna_test())
class Son(Mother):
def __init__(self, dna='Son'):
super().__init__(dna)
s = Son()
print(s.dna_... |
cfdecdb930492a6d260018e5196ea1797e8b2196 | NoraVasileva/School-database | /Class_People.py | 1,728 | 3.75 | 4 | class People:
"""
Information about students, users and teachers.
"""
def __init__(self, first_name, last_name, email, password):
"""
Entering attributes.
:param first_name: user's first name
:param last_name: user's last name
:param email: user's e-mail address
... |
0c6e56154648a44069f61e114aae97bfce397701 | NoraVasileva/School-database | /Registration_functions.py | 13,136 | 3.875 | 4 | import csv
import os
from print_functions import print_registration, print_reg_1, print_reg_2, print_reg_3
from Class_Student import Student
from Class_Teacher import Teacher
import datetime
import re
def registration():
"""
Registration form with options for students and teachers.
"""
print_registra... |
cbe1736657addb20e04b2a4e6560247610223bfa | dungkarl/python-tutorial | /OOP/unit4.py | 1,582 | 4.0625 | 4 | """
Inheritance and Creating Subclass
"""
class Employee:
#count_emps = 0
raise_amount = 1.04
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = self.first + self.last + '@gmail.com'
#Employee.count_emps +=1
def fullname(self):
#return self.fir... |
f11a5d001000b57572d9031f2c4a87394a0073d4 | Denriful/python | /Словари/vowels_dict.py | 510 | 3.890625 | 4 | vowels = ["a","e","i","o","u"]
word = "Hitchhiker"
#word = input("Provide a word to search for vowels: ")
found = {}
#found['a']=0
#found['e']=0
#found['i']=0
#found['o']=0
#found['u']=0
for letter in word:
if letter in vowels:
found.setdefault(letter,0)
# if found[letter] not in found:
# ... |
fa5bb60e3bc6dfc20e358cd97163f08f3f0873f9 | vbrunell/python | /misc/misc.py | 498 | 3.765625 | 4 | #!/usr/bin/python
'''
del
'''
# remove a variable
var = 6
del var
# delete list elems
l = [1,2,3,4,5]
del l[0]
print l
del l[-2:0]
print l
# delete dictionary elems
d = {'a':1,'b':2,'c':3}
del d['b']
print d
print
'''
codecs
The "codecs" module provides support for reading a unicode file.
For writing, use f.writ... |
8c83006938ace2a749581c2d7d36b1583135d3d4 | Saud-01/Phython-Codes | /Alphabets.py | 514 | 3.953125 | 4 | con = True
while True:
alnum = noalphnum = 0
str1 = input("Input your String: ")
str1 = str1.lower()
for count in range(len(str1)):
let = str1[count]
if let < "a" or let > "z":
noalphnum += 1
else:
alnum += 1
print(alnum, "Alphabets in... |
ae40d862a7d184e37434708015af56762eb5f240 | Tinasamayasundaram/pythonguvi | /prime.py | 161 | 3.546875 | 4 | n=int(input())
count=0
for i in range(2,n):
if n % i == 0:
count=count+1
if(count >= 1):
print("no")
else:
print("yes")
|
609485218e5bf74543268de8413d09dbe3117a1a | appinha/adventofcode_2020 | /my_solutions/day_18/main.py | 1,641 | 3.75 | 4 | # Import common core
import sys
sys.path.append('../common_core')
from common_core import ft_core
# Import requirements
import re
input_file = sys.argv[1]
class Nbr(int):
'''
Class for storing numbers from math expressions.
The subtraction method will perform a multiplication instead, in order to
perform multi... |
973983a34fdfbb942138bf3ab6ffcdea10f67bfd | appinha/adventofcode_2020 | /my_solutions/day_10/main.py | 1,757 | 3.609375 | 4 | # Import common core
import sys
sys.path.append('../common_core')
from common_core import ft_core
# Import requirements
from numpy import prod
input_file = sys.argv[1]
def ft_input_parser(raw_input):
'''
This function parses the input, converting the given list of strings
(lines from input file) to a list of ... |
35da50ad5c852ae98de19d9982339fa99ef7edf8 | jcasas31-mvm/pytest-example | /exercici1.py | 443 | 3.6875 | 4 | #Function to transform the name and the number to a final and real id
def generate_userid (name, identifier):
letters=""
words=name.split(" ")
for w in words:
letters += w [0].lower()
return str(identifier)+ "_" + letters
#Function maked to do a test for the correct us of the program
def test_ge... |
4d45abf36b5a92057e795f5165444c1b6092762f | Saneter/Education | /Assignment7-skeleton.py | 8,101 | 3.734375 | 4 | """
Author: Travis Jarratt
CIS 1600 - Assignment 7
Saint Louis University
A program to analyze test files using the Flesch scale.
Will take two files as inputs and output various results
based on user choices.
"""
from functools import reduce
import os
def num_sentences(textStr):
# This function is complete
... |
f95a3729fcc7e2e5476081156a8f1d3a2378eb4d | Saneter/Education | /assignment_5_travis_jarratt.py | 4,287 | 4.15625 | 4 | """
author: Travis Jarratt
CIS 1600 - Assignment 5
Saint Louis University
"""
def get_data():
fileObj = open("./exam-scores.csv")
lines = fileObj.readlines()
dict_scores = {}
for line in lines[1:]:
lst_items = line.strip().split(",")
dict_scores[lst_items[0]] = (float(lst_items[1]), f... |
d5844b1e496c7623183bbdd642f083dcb8df8dc5 | grace-pham/CS260-Summer-2021 | /HW/HW1/Refactor/results.py | 809 | 3.671875 | 4 | # Student: Grace Pham - ntp33 - Course: CS 260
# Script Purpose: Generate result lists by running 12 functions (implemented in functions.py) with the elements of x in
# x_list as input values
from functions import *
# Create a list for x(s) to run these fx functions on
x_list = [1, 2, 4, 8, 16, 32, 64]
# Run fx fun... |
3fdbb2ddcc559d32bfc53b13f1c20a7e971ad6e6 | sakshamchauhn/CS50 | /CS50's_Introduction_to_CS/Week6/Problem_set_6/mario/less/mario.py | 263 | 3.875 | 4 | from cs50 import get_int
while True:
# Getting input from user:
height = get_int("Height: ")
if height > 0 and height < 9:
break
# Iterating for rows:
for i in range(1, height + 1):
print(" " * int(height - i), end="")
print("#" * i)
|
ae9db23556c0d9f5fad29bacaec103b2b79cddfd | tituvely/Python_Efficiency | /Lesson4/replace.py | 924 | 4.03125 | 4 | import re
import fileinput
# 파일을 읽으면서 수정하려고 할 때는 fileinput 사용
def convertToLowerCase():
# inplace는 문제가 생길 경우에 대비해 백업 파일을 생성해주는 것
with fileinput.FileInput('./replace_test_file', inplace=True) as f:
for line in f:
print (line.replace(line, line.lower()), end='')
def convertToUpperC... |
be24c6bb71f0c7754f1b6ec26c73294c7ca9248c | bleepster/exercism | /python/raindrops/raindrops.py | 320 | 3.703125 | 4 | def plxng(number, factor, drop_string):
return drop_string if number % factor == 0 else ""
def convert(number):
raindrops = ""
raindrops += plxng(number, 3, "Pling")
raindrops += plxng(number, 5, "Plang")
raindrops += plxng(number, 7, "Plong")
return str(number) if not raindrops else raindrops
|
6f9bf5aa91fda6f7657dfe3eb3b9fabbcf9a7326 | 787264137/Python | /leetcode/hash/寻找重复的子树.py | 607 | 3.625 | 4 | class Solution:
def findDuplicateSubtrees(self, root):
"""
:type root: TreeNode
:rtype: List[TreeNode]
"""
def hierarchicalTraversal(root,ans):
if not root:
return '#'
seq = str(root.val) + hierarchicalTraversal(root.left,ans)+hierarchi... |
80ad00f69d2d91bb3ae0698f210838e12cdadc4d | jaquemff/exercicio-aprendizagem-python | /ExercicioContagemRegressiva.py | 305 | 3.640625 | 4 | #Faça um programa que mostre na tela uma contagem regressiva para o estou de fogos
#de artifício, indo de 10 até 0, com uma pauda de 1 segundo entre eles.
from time import sleep
print('A CONTAGEM REGRESSIVA IRÁ COMEÇAR!')
sleep(2)
for i in range(10, -1, -1):
print(i)
sleep(1)
print('FIM!') |
a7e5d87ff3af437e273955a04ca6534ae3abe82b | jaquemff/exercicio-aprendizagem-python | /ExercicioTuplas001.py | 493 | 4.03125 | 4 | '''Crie um programa que tenha uma tupla totalmente preenchida com uma contagem por
extenso, de zero até vinte. Seu programa deverá ler um número pelo teclado (entre 0 e
20) e mostrá-lo por extenso'''
n = ('zero', 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove', 'dez')
while True:
n2 = int(i... |
6e6abd3de78936fa5260baaa7f8a5a3fcdd09762 | hhm4/AlgorithmsOnGraphs | /MinimumNumberOfEdges.py | 898 | 3.625 | 4 | class Graph:
def __init__(self,ver,edg):
self.noOfVertices=ver
self.noOfEdges=edg
self.edges=[]
self.queue=[]
for i in range(self.noOfVertices+1):
self.edges.append([False])
def addEdges(self,v1,v2):
self.edges[v1].append(v2)
self.edges[v2].append(v1)
def bfs(self,v,u):
if v==u:
return 0
el... |
3faac07504afdd5d5b12d8651945a426e6a49635 | anikesh4/Projects | /Personal projects/python projects/ceasar_cipher.py | 1,634 | 3.796875 | 4 | alphabet_list=['#','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
alphabet_dict = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8,'i':9,'j':10,'k':11,'l':12,'m':13,'n':14,'o':15,'p':16,'q':17,'r':18,'s':19,'t':20,'u':21,'v':22,'w':23,'x':24,'y':25,'z':26}
d... |
a7006682b79cc27ab8d53513dd530b26c44f6f7d | dzemildupljak/object_oriented_programming | /vezba1.py | 2,016 | 3.828125 | 4 | # Funkcija print () ispisuje navedenu poruku na ekran ili neki drugi standardni izlazni uređaj.
#
# Poruka može biti niz ili bilo koji drugi objekt, objekt će se pretvoriti u niz prije nego što se upiše na ekran.
# print(object(s), separator=separator, end=end, file=file, flush=flush)
print("Hello world")
print("He... |
14d1a8527bb1231952fc3a93723b684f2ba1b7ed | qszhhd/PythonSpace | /python_old/MyPython/lesson3.py | 5,825 | 4.3125 | 4 | ###--------1113:第1个小游戏------------------
####num=10;
####print('Guess what I think?');
####answer=int(input());#Python3中input()默认输入的都是字符串;
####
####while answer!=num:
#### if answer<num:
#### print("too small!");
#### else:
#### print("too big!");
####print('Bingo!');
##
##
####按照上述方式写的程序... |
2d97212501ea53237f39f753cb7da63fee9a5c08 | matheus-cal/cpftests | /validacpf_matheus.py | 659 | 3.5 | 4 | def retira_cpf(cpf):
format_cpf = ''
for i in cpf:
if i.isalnum():
format_cpf += i
print(format_cpf)
return format_cpf
def valida_cpf(num):
if len(num) < 11:
return False
if num in [s * 11 for s in [str(n) for n in range(10)]]:
return False
... |
174ab3e0f488b9e2431989cf412dbb4a1640bfc0 | pallavi23022/Python-Programs | /string.py | 73 | 3.578125 | 4 | str1=input()
str2=int(input())
print(str2*str1)
print(str1+ str(str2) )
|
55ec5d557a6bcedcabd4324898f531f696e8dab8 | pallavi23022/Python-Programs | /Bill.py | 275 | 3.96875 | 4 | quantity=float(input("Enter quantity"))
value=float(input("Enter price"))* quantity
discount=float(input("Enter discount percentage"))
tax=float(input("Enter tax amount percentage"))
bill= value-( (discount/100)*value )+ ( (tax/100)*value )
print("Total bill: " , bill)
|
4b88afec8fb0deb41b99e71b6a114525c5e4ab82 | pallavi23022/Python-Programs | /program1.py | 238 | 3.734375 | 4 | #Q 2. WAP to create list of numbers divisible by 4 or 13
#all th eelements of the list should lie in the range from 200 to 500
list1=[]
for num in range(200,501,1):
if(num%4==0) or (num%13==0):
list1.append(num)
print(list1)
|
b2882b72d0f4681535c0009a5fdcc98249fefe98 | pallavi23022/Python-Programs | /listbegining.py | 170 | 4.125 | 4 | n=int(input("Enter a list"))
list1=[]
for i in range(0,n):
list1.append((input("Enter a element of a list ")))
print(list1)
l1=[1,2,3]
list1.append(l1)
print(list1)
|
b2fb7a3e0815ef919ffa920619e082597adb45eb | pallavi23022/Python-Programs | /CopiesOfString.py | 197 | 3.828125 | 4 | string=input("Enter String: ")
copies=int(input("Enter number of copies to be printed: "))
l=int(input("Enter length to be extracted: "))
for i in string:
slice=string[0:l]
print(slice*copies)
|
e8c226bb156c7f7e88664fedb3d3ee0eca2cf605 | pallavi23022/Python-Programs | /factorOfeachElement.py | 279 | 4 | 4 | num=int(input("ENter a number: "))
list1=[]
modified=[]
while(num!=0):
list1.append(num)
modified.append(num*10)
num=int(input("ENter a number: "))
print(list1)
print(sorted(list1)," :sorted list")
print(modified)
print(sorted(modified),": modified list")
|
c2faadf1267de8933b1fce5b64acd3c564ad95c3 | adwaithkj/random_problems_dynamicprog | /fib.py | 481 | 4 | 4 | def fib(n, db, data):
if n == 0:
return 0
elif n == 1:
return 1
elif n == 2:
return 1
elif n in db:
return data[db.index(n)]
val = fib(n-1, db, data)+fib(n-2, db, data)
db.append(n)
data.append(val)
return val
def main():
n = int(input("Type in t... |
b13dd7edaf3c6269f3d3fa90682eeeb989d78571 | TigerAppsOrg/TigerHost | /deploy/deploy/utils/click_utils.py | 586 | 4.1875 | 4 | import click
def prompt_choices(choices):
"""Displays a prompt for the given choices
:param list choices: the choices for the user to choose from
:rtype: int
:returns: the index of the chosen choice
"""
assert len(choices) > 1
for i in range(len(choices)):
click.echo('{number}) {... |
81bfaa5b74312076cd2bd660ebb58a9cbb172664 | mingziV5/python_script | /thread_queue_ring.py | 1,092 | 3.65625 | 4 | #!/usr/bin/python
#coding:utf-8
from threading import Thread
from Queue import Queue
class TestRing(Thread):
def __init__(self,q,thread_num,thread_name):
Thread.__init__(self)
#self.q_out = q_out
#self.q_in = q_in
self.q = q
self.thread_num = thread_num
self.thread_... |
5492a26a3881c41ce5ad9a013f9541d834146ac6 | shreyassgs00/Ciphers | /caesar_cipher/decrypt.py | 585 | 3.75 | 4 | #To decrypt the strings in encrypt.txt and write them to decrypt.txt
to_decrypt_file = open('encrypted.txt','r')
decrypt_file = open('decrypted.txt','w')
s = int(input('Enter the shift pattern to decrypt: '))
encrypted_lines = to_decrypt_file.readlines()
for a in encrypted_lines:
ans = ''
for i in range(0, le... |
b5659a82b681c6c80ecdc1ee2e217519f8b1a852 | Anny8910/Electricity-Consumption-vs-States | /plot.py | 813 | 3.5625 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df=pd.read_csv('Per capita consumption of electricity.csv')
print(df.head())
desc=df.describe()
print(desc)
print(df.columns)
df=df.drop(40,axis=0)#to remove all india data that is total
for each in desc.columns:
print('details of--',each... |
ae3af6069669c629916b11f7771cccbebc83e89e | andidietz/python_data_structures | /14_compact/compact.py | 502 | 3.765625 | 4 | def compact(lst):
"""Return a copy of lst with non-true elements removed.
>>> compact([0, 1, 2, '', [], False, (), None, 'All done'])
[1, 2, 'All done']
"""
# Source: Accessing index in python for loop (6/21/2021): https://realpython.com/python-enumerate/
# Source: Understanding Enumrat... |
e9c18facb40dc769063bc59a4364804ee16f88bf | vineet247/text-extractor | /src/desktop.py | 2,939 | 3.734375 | 4 | from tkinter import filedialog
from tkinter import *
from tkinter.filedialog import askopenfilename
from app import extract_from_folder, extract_from_file
from tkinter import messagebox;
def browse_button():
# Allow user to select a directory and store it in global var
# called folder_path
global folder_pa... |
092c70f41ebe8ad994fe679742c76aa9af2e76f7 | MrZhangzhg/nsd_2018 | /nsd1811/python01/day04/check_idt.py | 606 | 3.515625 | 4 | import sys
import keyword
from string import ascii_letters, digits
first_chs = ascii_letters + '_'
other_chs = first_chs + digits
def check_idt(idt): # abc@123
if keyword.iskeyword(idt):
return '%s 是关键字' % idt
if not idt[0] in first_chs:
return '第1个字符不合法'
for ind, ch in enumerate(idt[1... |
702a6a7a507adab77dd080f235544229d6c219b6 | MrZhangzhg/nsd_2018 | /nsd1809/python2/day01/stack.py | 1,102 | 4.28125 | 4 | """
列表模拟栈结构
栈:是一个后进先出的结构
"""
stack = []
def push_it():
data = input('data to push: ').strip()
if data: # 如果字符串非空
stack.append(data)
def pop_it():
if stack: # 如果列表非空
print('from stack, popped \033[31;1m%s\033[0m' % stack.pop())
else:
print('\033[31;1mEmpty stack\033[0m')
... |
de1736077c5565ee27abb6868337ea2a84ee64a1 | MrZhangzhg/nsd_2018 | /nsd1808/python2/day03/oop.py | 761 | 3.796875 | 4 | class Date:
def __init__(self, year, month, day):
self.year = year
self.month = month
self.day = day
@classmethod
def create_date(cls, date_str):
# tlist = date_str.split('-')
# year = int(tlist[0])
# month = int(tlist[1])
# day = int(tlist[2])
... |
01aaacdbb9d0efa13175bbb822dd7b7ff72c587b | MrZhangzhg/nsd_2018 | /nsd1810/python1/day02/while_continue.py | 260 | 3.90625 | 4 | # 计算1-100以内偶数之和
result = 0
counter = 0
while counter < 100:
counter += 1
# if counter % 2 == 1:
if counter % 2: # counter除以2的余数只有1或0,1是True,0是False
continue
result += counter
print(result)
|
a2040c08d3ed7057355f57cf9fbdb522d1096702 | MrZhangzhg/nsd_2018 | /nsd1807/python1/day02/game2.py | 413 | 3.734375 | 4 | import random
all_choice = ['石头', '剪刀', '布']
win_list = [['石头', '剪刀'], ['剪刀', '布'], ['布', '石头']]
computer = random.choice(all_choice)
player = input('请出拳(石头/剪刀/布): ')
print('你的出拳:', player, ', 计算机出拳:', computer)
if player == computer:
print('平局')
elif [player, computer] in win_list:
print('You WIN!!!')
else:
... |
ea790c65632f47dd6d0e78d0f366b8b042d0b3ad | MrZhangzhg/nsd_2018 | /nsd1807/python1/day03/fibs_func.py | 819 | 4.15625 | 4 | # def generate_fib():
# fib = [0, 1]
#
# for i in range(8):
# fib.append(fib[-1] + fib[-2])
#
# print(fib)
#
# # generate_fib() # 调用函数,即将函数内的代码运行一遍
# # generate_fib()
# a = generate_fib()
# print(a) # 函数没有return语句,默认返回None
##############################
# def generate_fib():
# fib = [0, 1]
#... |
fc0b8a09ad96e90490b28fae6374818a51bf7ed5 | MrZhangzhg/nsd_2018 | /nsd1808/python2/day02/day02.py | 2,405 | 3.828125 | 4 | # def foo():
# print('in foo')
# bar()
#
#
# def bar():
# print('in bar')
#
# if __name__ == '__main__':
# foo()
###############################
#
# def myfunc(*args): # *表示args是个元组
# print(args)
#
# def myfunc2(**kwargs): # **表示kwargs是个字典
# print(kwargs)
#
# if __name__ == '__main__':
# ... |
ef21ec72f602453a7a0111302890bd6c85eb3d85 | MrZhangzhg/nsd_2018 | /nsd1808/python2/day03/toys4.py | 502 | 3.734375 | 4 | class PigToy:
def __init__(self, name, color):
self.name = name
self.color = color
def show_me(self):
print('Hi, my name is %s, I am %s' % (self.name, self.color))
class NewPigToy(PigToy):
def __init__(self, name, color, size):
# PigToy.__init__(self, name, color)
s... |
78f78f2e1925e85974f9c89988c04b48b71746db | MrZhangzhg/nsd_2018 | /nsd1811/python02/day01/try1.py | 486 | 3.53125 | 4 | try: # 把有可能发生异常的代码放到try中执行
num = int(input('number: '))
result = 100 / num
except (ValueError, ZeroDivisionError): # 用except捕获异常
print('无效的数字')
except (KeyboardInterrupt, EOFError):
print('\nBye-bye')
exit() # 程序序到exit就会退出,后续代码不再执行
else: # 没有发生异常才执行的语句
print(result)
finally: # 不管是否发生异常,都会... |
81b8771788890aa2f6794dde1f7552b4c07a80cd | MrZhangzhg/nsd_2018 | /weekend1/py0102/for1.py | 550 | 3.90625 | 4 | astr = 'tom'
alist = [10, 20]
atuple = ('tom', 'jerry')
adict = {'name': 'tom', 'age': 20}
# for ch in astr:
# print(ch)
#
# for i in alist:
# print(i)
#
# for name in atuple:
# print(name)
#
# for key in adict:
# print(key, adict[key])
# range函数
print(range(10))
print(list(range(10)))
for i in range... |
5ed42743a1c6a789d0cd39eb0945dbdc758be5fb | MrZhangzhg/nsd_2018 | /nsd1808/python2/day03/toys2.py | 589 | 3.734375 | 4 | class Vendor:
def __init__(self, company, ph):
self.company = company
self.phone = ph
def call(self):
print('Calling %s...' % self.phone)
class PigToy: # 定义玩具类
def __init__(self, name, color, company, ph):
self.name = name
self.color = color
self.vendo... |
69b21bbb24cf992e9c0d4b50c0d68e9240a82df4 | MrZhangzhg/nsd_2018 | /nsd1811/python01/day03/forloop.py | 248 | 3.734375 | 4 | chs = 'hello'
alist = ['bob', 'alice']
atuple = (10, 20)
adict = {'name': 'tom', 'age': 23}
for ch in chs:
print(ch)
for name in alist:
print(name)
for i in atuple:
print(i)
for key in adict:
print('%s: %s' % (key, adict[key]))
|
bf2281c858a66bdc70cb6be934b5d8e42504ba1a | MrZhangzhg/nsd_2018 | /nsd1807/devops/day01/myfork.py | 339 | 3.9375 | 4 | import os
# print('开始')
# os.fork()
# print('你好')
# print('start')
# a = os.fork()
# if a:
# print('in parent')
# else:
# print('in child')
#
# print('end')
for i in range(3):
retval = os.fork()
if not retval:
print('hello world!')
exit() # 一旦遇到exit,进程将彻底结束
|
ca74db9ec4f2c69978919b8f28987638505ea69c | sealanguage/somePythonChallenges | /yahtzee1.py | 597 | 3.96875 | 4 | import random
# from operator import setitem
dice = []
reroll = []
dienums = random.randint(1, 6)
all_dice = 5
for value in range(all_dice):
dice.append(random.randint(1, 6))
print (dice)
shopList = []
maxLengthList = 6
while len(shopList) < maxLengthList:
item = input("Enter your Item to the List: ")
... |
6cbf9d107e36dad6efbc143b4778260dea37f0c0 | sealanguage/somePythonChallenges | /string_loops5.py | 1,837 | 3.84375 | 4 | # a, b = input("Enter two of your lucky number: ").split()
T = int(input())
S = input() # S is a string of chars, it prints each letter in a word
splits = S.split()
print("1 ", splits)
lines = []
# lines = input().strip()
# print("2 ", lines)
# while True:
# line = S.split()... |
9aa376fd604e2b891016b7c8847def98b1539416 | medialab/ural | /scripts/utils.py | 336 | 3.609375 | 4 | from timeit import default_timer as timer
class Timer(object):
def __init__(self, name="Timer"):
self.name = name
def __enter__(self):
self.start = timer()
def __exit__(self, *args):
self.end = timer()
self.duration = self.end - self.start
print("%s:" % self.name,... |
40480382b93eeb0999228c54a12ee53b2c2ef638 | medialab/ural | /ural/classes/trie_dict.py | 5,238 | 3.65625 | 4 | # =============================================================================
# TrieDict
# =============================================================================
#
# A simple Python implementation of a (prefix, value) Trie.
#
NULL = object()
class TrieDictNode(object):
__slots__ = ("children", "value", "... |
111b6c2759bfd7676336db845106102f7b94fb00 | pythrick/python-javonico | /python_javonico/models/palestra.py | 922 | 3.609375 | 4 |
class Palestra:
__codigo: str = None
__tema: str = None
__descricao: str = None
def __init__(self, codigo: str, tema: str, descricao: str):
self.set_codigo(codigo)
self.set_tema(tema)
self.set_descricao(descricao)
def get_codigo(self):
return self.__codigo
de... |
6ccce55fe0b842ffc006d85bceafde2849a9ffb8 | jzaldumbide/lab4 | /conteo.py | 174 | 3.671875 | 4 | contador=int(0)
frase =input("ingrese una frase \n")
fraux=frase.split (" ")
for i in fraux:
contador=contador+1
print("El numero de palabras ingresadas es"+str(contador))
|
a4dc65a8f1f19df3230fff9a879dcbf23d77201b | ElAnbals/Mision-08 | /listas.py | 1,768 | 3.5625 | 4 | def sumarAcumulado(lista):
listaSumada=[]
for k in (0,len(lista)+1):
contador=0
for x in range (0,k+1):
contador=contador+lista[k]
if k==x:
listaSumada.append(contador)
return listaSumada
def recortarLista(lista):
listaRecor=[]
... |
f701b712294044a7f89048017be6f173094c0580 | insuajuan/snake_game | /main.py | 1,238 | 3.703125 | 4 | from turtle import Screen
import time
from snake import Snake
from food import Food
from scoreboard import Score
screen = Screen()
# Create Window
screen.setup(width=600, height=600)
screen.bgcolor("black")
screen.title("Snake Game")
screen.tracer(0)
# Instantiate Classes
snake = Snake()
food = Food()
score = Score(... |
f57ac27ef8aa579c0a10eab584f72ca15d84f41d | manuel-delverme/games | /flaskTictacToe/blocks_src.py | 3,414 | 3.609375 | 4 | import random
from copy import deepcopy
import functools
def pick_random_move(board):
row = random.randint(0, 2)
column = random.randint(0, 2)
if board[row][column] != None:
return pick_random_move(board)
return [row, column]
def findEmptyCells(board):
empty_cells = [] # count_freeSpace... |
cbb7499303ee47083a330a9e50f5b5af3c9a3756 | voooltexx/Summer_School2021 | /My Code/Calculator.py | 3,571 | 3.703125 | 4 | from tkinter import *
from tkinter import messagebox
def add_digit(digit):
value = calc.get() + digit
calc.delete(0, END)
calc.insert(0, value)
def add_operation(operation):
value = calc.get()
if value[-1] in '+-*/':
value = value[:-1]
value = value + operation
calc.delete(0, END)
... |
1076b8facc5fcdddd9282ea7d257a82933bd52fa | voooltexx/Summer_School2021 | /My Code/GraphicsWindow.py | 1,580 | 3.703125 | 4 | from tkinter import*
import tkinter.font as font
clicks=0
def button_click():
global clicks
clicks += 1
button_text.set('Clicks: {}'.format(clicks))
root = Tk()
root.title('New Python Program!')
root.geometry('800x600')
root.configure(bg='#424242')
button_text = StringVar()
button_text.set('Make Kiriki... |
0263e18809fea766f9455be0853036079af1736f | mjs139/PythonPractice | /Kaggle Titanic Competition.py | 8,668 | 3.5 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Kaggle Titanic Competition
#
# In this project, I will compete in the Kaggle Titanic Competition.
# In[12]:
import pandas as pd
train = pd.read_csv("train.csv")
holdout = pd.read_csv("test.csv")
print(train.shape)
train.head()
# ## Loading Functions
# In[13]:
# %lo... |
2609c2b1f06d647b086493c1294a1652787cefd8 | FranciscoValadez/Course-Work | /Python/CS119-PJ 6 - Simple Calculator/PJ 6 - Simple Calculator/PJ_6___Simple_Calculator.py | 1,900 | 4.5 | 4 | # Author: Francisco Valadez
# Date: 1/23/2021
# Purpose: A simple calculator that shows gives the user a result based on their input
#This function is executed when the user inputs a valid operator
def Results(num1, num2, operator):
if operator == '+':
print("Result:", num1, operator, num2, "=", (num1 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.