blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
18c69c3d6007bbd6756afb8612f330de8ad7b74c | adityaranjan/KattisSolutions | /minimumscalar.py | 425 | 3.5 | 4 | #Minimum Scalar Product
NumTestCases = int(input())
for i in range(NumTestCases):
NumCoordinates = int(input())
Sum = 0
Vector1 = list(map(int, input().split(" ")))
Vector2 = list(map(int, input().split(" ")))
Vector1.sort()
Vector2.sort(reverse = True)
j = 0
for j in range(Num... |
294d46043960cc68c2588836bbababf0d61a686b | gaya38/devpy | /Python/assignment/pes-python-assignments-2x.git/maths.py | 582 | 3.875 | 4 | import calc
a=input("Enter the a value:")
b=input("Enter the b value:")
print "Sum of the a and b is:",calc.add(a,b)
print "Difference of the a and b is:",calc.diff(a,b)
print "Multiplication of the a and b is:",calc.mul(a,b)
print "Divison of the a and b is:",calc.div(a,b)
print "Square root of the a is:",calc.sqrt(a... |
87d440234f1d7b9b0afd67e74fcdd23fb847f8b8 | Rahul220198/Snake-Game | /main.py | 1,176 | 3.59375 | 4 | from turtle import Screen
from snake import Snake
from food import Food
from scoreboard import Scoreboard
import time
screen = Screen()
screen.setup(width=700, height=700)
screen.title("Snake Game")
screen.bgcolor("khaki")
screen.tracer(0)
snake = Snake()
food = Food()
score = Scoreboard()
screen.listen()
screen.o... |
04196f7a0b2c3d3e7db9907f79b32ce756426e4a | harshjohar/unacademy_a | /assignment_10/bnsrch2.py | 1,243 | 4 | 4 | import sys
def find_pos(x):
print('1 ' + str(x))
sys.stdout.flush()
t = int(input())
return t
# ----------------- Do not modify anything above this line -----------------------
# Complete this function count(n, x), this returns 0 always and hence is wrong, it should return the number of occurrences of... |
a137360ebb521839774fca076b2502edfb9e9b22 | karebearvfx/cspath-datastructures-capstone-project | /finalcodes/script.py | 5,491 | 4.15625 | 4 | ##import functions###
from data import *
from welcome import *
from hashmap import HashMap
from linkedlist import LinkedList
##GOAL:To retrieve a list of restaurants given a single input of what food type user enters
##
####variables###
#copy existing data
food_types = types
restaurants_list = restaur... |
769218984e88d76ba18df89795cf8c9d56bf3b5c | lhju4e/TIL | /algo/10809.py | 229 | 3.78125 | 4 | str1 = "backjoon"
# print(str1)
list1 = [s for s in str1]
alphabet_list = [chr(i) for i in range(97, 97+26)]
for s in alphabet_list:
if s in list1:
print(list1.index(s), end=' ')
else:
print(-1, end=' ')
|
6d6a8f5ca384ca21b3d93067675fdee7df6917d0 | solbrenneman/Python | /Text Coder/inspirational_text.py | 5,566 | 4.46875 | 4 | '''Solomon Brenneman
Project 3 (Inspirational Text)
November 9, 2018
This program asks the user for a textfile and then allows them to choose from 6 different options for
interacting with the text. Option 1 asks for a word or phrase and then searches for the text for the first occurence.
Option 2 asks f... |
0aed9f78781709472e89b4defc2fef82414ae1cf | cesquivias/rosalind | /py/reverse-complement.py | 313 | 3.65625 | 4 | #!/usr/bin/env python
def reverse_complement(strand):
comp = {
'A': 'T',
'C': 'G',
'G': 'C',
'T': 'A',
}
return ''.join(reversed([comp[c] for c in strand.strip()]))
if __name__ == '__main__':
import sys
print reverse_complement(open(sys.argv[1]).read())
|
8887cfe3a023e6212ed42ad456db9beee4d9f751 | ronysh/python_for_js_developers | /CH_02_03_end.py | 584 | 3.890625 | 4 | """
* lists may be modiefied
* tuples are leaner and immutable
"""
names = ["Ronnie", "Mona", "Jack"]
names[2] = "Fred"
print(names)
result = 1 in [1, 2, 3, 4, 5] # True
print(result)
print("==========")
names_tuple = (
"Ronnie",
"Mona",
"Jack",
)
print("==========")
names_age_dictionary = {"Jack": 2... |
7756e713ca7b36985ee9134ae66c50d211c561de | wissalLaassiri/MQtt_Project | /CalculateDisatance.py | 859 | 3.734375 | 4 | import sqlite3
from math import cos, asin, sqrt, pi
def distance(lat1, lon1, lat2, lon2):
p = pi/180
a = 0.5 - cos((lat2-lat1)*p)/2 + cos(lat1*p) * cos(lat2*p) * (1-cos((lon2-lon1)*p))/2
return 12742 * asin(sqrt(a)) #2*R*asin...
conn = sqlite3.connect('iot_database.db')
c = conn.cursor()
def minOfDist... |
f41ddf1d6548a8539254d92c3d6647068c64d6d8 | danilocamus/Pong-Game | /ball.py | 1,184 | 3.984375 | 4 | from turtle import Turtle
class Ball(Turtle):
def __init__(self):
super().__init__()
self.color('white')
self.shape('circle')
self.penup()
self.x_move = 10
self.y_move = 10
# ABAIXO o atributo para aumentar a velocidade da bola quando quicar em ... |
1851ad924a040e15121b6299a6398149e573a5ed | DIas-code/ICT_2021 | /task4/4.py | 206 | 3.71875 | 4 | def isTriangle(a,b,c):
if a+b>c and a+c>b and b+c>a:
return True
else:
return False
a=float(input())
b=float(input())
c=float(input())
print("Is it valid triange?",isTriangle(a,b,c)) |
f753038e49440ba66d93ba748f59aa613fe2eca0 | MegLip/calculator3 | /calculator2.py | 2,246 | 3.859375 | 4 | import sys #1 def function
import logging
logging.basicConfig(level=logging.DEBUG)
def calculator1(choice, num1, num2, *args):
if int(choice) == 1:
result = float(num1) + float(num2) + float(sum(args))
elif int(choice) == 3:
x = 1
for... |
e6d44f740cb5d9bcdacd65580bfbe8994b79ef9f | TharlesClaysson/Python-Basico | /primeiroModulo/retornos.py | 188 | 3.546875 | 4 | def somar(a=0, b=0, c=0):
s = a + b + c
print(f'os valores foram {s} ')
return s
r1 = somar(3,2,5)
r2 = somar(2,2)
r3 = somar(6)
print(f'os valores foram {r1}, {r2}, {r3} ')
|
388c2fa37f95b66b3d3f252156848e063a53142d | teotiwg/studyPython | /200/pt3/082.py | 178 | 3.5625 | 4 | msg = input('임의의 문장을 입력하세요')
if 'is' in msg:
print("입력한 문장에 is가 있습니다.")
else:
print('입력한 문장에 is가 없습니다.') |
8c284911112aed2fe44c568ef98034525caddf39 | AlexChristian720/OOP | /Object Oriented Programming/Accessing Items In list.py | 300 | 3.78125 | 4 | #This Session Covers All About the Accessing itmems in the list
mixed_list=['This',9,'is',18,45.9,'a',54,'Mixed',99,'list']
print(mixed_list[:-1])
print(mixed_list[3])
#Empty_objects
#Empty Objects
class EmptyObjects():
pass
obj=EmptyObjects()
obj.x='Hello World'
print(obj.x)
|
7620df7e3cd16d45e23864aee91e0e5f71311312 | BhavathariniAG/project-4 | /main.py | 101 | 3.515625 | 4 | def ascii(character):
print("ASCII value of " + " " + character, ord(character))
ascii("b") |
5825b922d008d4c77143bc8fb6fdab42976a60a9 | zhangshuyun123/Python_Demo | /function.py | 370 | 3.984375 | 4 | def print_any(*args):
arg1,arg2,arg3 = args
print("arg1: %r ,arg2: %r,arg3: %r" %(arg1,arg2,arg3))
print("1,2,3")
def print_two(arg1,arg2): #形参
print("两个形参是:arg1= %r ,arg2= %r" %(arg1,arg2))
print("5,10") #实参
'''
在定义函数(int add (int a,int b)中a和b是形参)
在调用函数时:add(1,2)中1和2就是实参
'''
|
76373e3483bfedc7aca0a26694a03a22004228a2 | hemanth2410/Metoids | /DataHandler.py | 1,148 | 3.53125 | 4 | import csv
import random
import re
def ReadData():
print("Reading Data")
FinalData = []
ReturnData = []
with open("Data.csv",mode='rt') as f:
data = csv.reader(f)
for row in data:
if(str(row).find(",") != -1):
l = str(row).split(',')
... |
aa230ba20d20e6799bd06cc32eb54f307544fba2 | xuexi567/test | /github123.py | 409 | 3.953125 | 4 | import string
def kaisa(s,k):
lower=string.ascii_lowercase
upper=string.ascii_uppercase
before=string.ascii_letters
after=lower[k:] +lower[:k] +upper[k:] +upper[:k]
table=''.maketrans(before,after)
return s.translate(table)
s="Python is a great programming language.I like it !"
print(kaisa(s,3))... |
00084ba52727f7e92b270fb8759777b52d4ea867 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2115/60762/262699.py | 702 | 3.59375 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-s=input()
#1.首先带奇环的显然是 NO;
#2.否则对于每个连通块,递归删掉所有度数为1的点(即将支出去的外向树删掉):
#剩下的是偶环,显然是 YES;
#剩下的图只有两个度数为3的点,那么这两个点之间有3条路径,这三条路径上边数次为2,2,even(偶数)则是 YES;
#其他情况全为 NO。
t=int(input())
for g in range (0,t):
s=input().split(" ")
n=int(s[0])
m=int(s[1])
l=[[] for i in range (n+1... |
a818ce808ce76e007069b5dfca456fcda95d44b0 | christian-miljkovic/python_projects | /python_project3/MiljkovicChristian_assign3_part1.py | 1,301 | 4.4375 | 4 | # Christian Miljkovic
# CSCI-UA.0002 section 03
# Assignment #3
print("Trianlge Tester")
#promt the user to enter 3 points
point1_x= float(input("Enter the x-coordinate for the first point: "))
point1_y= float(input("Enter the y-coordinate for the first point: "))
point2_x=float(input("Enter the x-coordinate for th... |
dba967390a35285564883380f5fec5721182c7d2 | lakshmikantdeshpande/Python-Courses | /Courses/PythonBeyondTheBasics(OO-Programming)_David-Blaikie/2_class/MyClass.py | 153 | 3.640625 | 4 | class MyClass(object):
var = 10
this_obj = MyClass()
print(this_obj)
print(this_obj.var)
that_obj = MyClass()
print(that_obj)
print(this_obj.var)
|
6466fb3c3e2a48d11edf29dfc5b1eb3f693b589b | esl4m/hacker_rank | /mix/python_num_sequenatial_pattern.py | 304 | 3.84375 | 4 | #!/bin/python3
# number sequential pattern
def py_num_seq_pattern(n):
num = 1
for i in range(0, n):
for j in range (0, i+1):
print(num, end= ' ')
num += 1
print('\r')
n = 5
py_num_seq_pattern(n)
# Output
# 1
# 2 3
# 4 5 6
# 7 8 9 10
# 11 12 13 14 15
|
2d216858531ab8c8307dfd50a2290d99bfd14e49 | jinurajan/Datastructures | /LeetCode/top_interview_qns/linked_list/merge_two_sorted_list.py | 1,919 | 4.0625 | 4 | """
Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists.
Example:
Input: 1->2->4, 1->3->4
Output: 1->1->2->3->4->4
"""
from typing import List
# Definition for singly-linked list.
class ListNode:
def __init__(self, va... |
949439071ea87181644bbcaa1abbf4ab33272e8d | apktool/LearnPython | /1.15.03.py | 273 | 4.0625 | 4 | # 函数|递归(factorial,Fibonacci)
# 求解factorial
def MyFunction(n):
if n==1:
return 1
return n*MyFunction(n-1)
temp=MyFunction(5)
print(temp)
# 求解Fibonacci sequence
def Feber(x):
if x==1 or x==2:
return 1
return Feber(x-1)+Feber(x-2)
print(Feber(20))
|
8abd3b5c3cec366cff61bf552ed04c85f2ddf410 | TraianVidrascu/GridWolrd-q-learning-sarsa | /main/gridworld.py | 1,378 | 3.53125 | 4 | from random import randint
class GridWorld:
NORTH = 0
EAST = 1
SOUTH = 2
WEST = 3
ACTIONS = [NORTH, EAST, SOUTH, WEST]
def __init__(self):
self.size = -1
self.world = [[]]
self.init()
def init(self):
self.size = 8
self.world = [[-1, -1, -1, -1, -1,... |
aa5af823d4e929d26ce0a6dc5dd3b6fc0e199008 | bhi5hmaraj/APRG-2020 | /Assignment 2/solutions/BMC201958/BMC201958.py | 4,451 | 3.5 | 4 | class Color:
black = 0
red = 1
class Node:
def __init__(self,info=None,color=None):
self.info = info
self.color = color
self.l = None
self.r = None
self.p = None
self.size = 1
class RedBlackTree:
def __init__(self):
self.ext = Node(-1,Color.black... |
8de25b379688cf54f5a636ccbae9fe90663d29b7 | caioledesma/520 | /tipos_erro.py | 842 | 3.953125 | 4 | #!/usr/bin/python3
convidados = ['hugo', 'caio', 'luiz', 'daniel']
num = 0
try:
convidado = int(input('Digite o numero do convidado: '))
print(convidados[convidado -1])
except IndexError:
print('Este convidado não existe! A lista tem {} itens. Vc digitou {}'.format(len(convidados),convidado)
except V... |
77e8c68b0b812e302ca350c275e72dc5f304270c | kenmueller/Standard-Structure | /struct-add/struct-add/ask.py | 1,219 | 3.984375 | 4 | import os
def location():
'''Get the location of structure
Raises:
Exception: Error if language or framework isn't chosen
Exception: Error if the folder chosen doesn't exist
Returns:
str -- path of structure
'''
path = ''
print(
'''
👋 Hello! Thank you for con... |
0a412bceed064d0a7584c1001f640fb439071fe8 | yordan-marinov/advanced_python | /iterators_and_generators/reverse_iter.py | 452 | 4.125 | 4 | class reverse_iter:
def __init__(self, iterable):
self.iterable = iterable
self.copy_iterable = self.iterable[::-1].copy()
def __iter__(self):
return self
def __next__(self):
if not self.copy_iterable:
raise StopIteration
current_element = self.copy_ite... |
4eaf299dda1d189edfbb0c3e732fe16225127a1b | tewarigargi/Hackerrank | /Day_10_Binary_Numbers.py | 1,348 | 4.03125 | 4 | '''
#Objective
#Today, we're working with binary numbers. Check out the Tutorial tab for learning materials and an instructional video!
#Task
#Given a base-10 integer, n, convert it to binary (base-2).
#Then find and print the base-10 integer denoting the maximum number of consecutive 1's in n's binary representation... |
218aacce95f3e96080a2a54e2744bf412e80e6a9 | tanaostaf/python | /lab7_3_1.py | 442 | 3.953125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def checkio(expression):
s = ''.join(c for c in expression if c in '([{<>}])')
while s:
s0, s = s, s.replace('()', '').replace('[]', '').replace('{}', '').replace('<>','')
if s == s0:
return False
return True
print (chec... |
f55ff28fa1b60ca1de9975ee6b8faf4c8c6b0423 | indraaulia-usu/contoh-ipkomc | /calculation.py | 215 | 4.0625 | 4 | # Store input numbers
A = input('Berikan angka pertama: ')
B = input('Berikan angka kedua: ')
# Add two numbers
sum = float(A) + float(B)
# Display the sum
print('The sum of {0} and {1} is {2}'.format(A, B, sum))
|
536116e3781e654bc0059fd7659d38cd57c0d1d5 | harute931507/Xvillage_python_practice | /week1/prime.py | 391 | 4.09375 | 4 | def isPrime(num):
for i in range(2, round(num/2)+1):
if num % i == 0:
return False
return True
Min = ""
Max = ""
while Min == "":
Min = input("Enter the Lower Bound : ")
while Max == "":
Max = input("Enter the Upper Bound : ")
Min = int(Min)
Max = int(Max)
for i in range(Min, Max)... |
b500e03808d0ab2cf8d4db310a3b542c4e87f0e8 | agvaibhav/Binary-tree | /continuous-tree.py | 880 | 4.09375 | 4 | class Node:
def __init__(self,data):
self.data = data
self.left = None
self.right = None
def treeContinuous(root):
if root is None:
return True
if root.left is None and root.right is None:
return True
if root.left is None:
return(abs(root.data - root.... |
4b46e74349f63f5ee2c550d8423c1cbb34c4f55e | MaryAyla/training-101 | /pre functions.py | 725 | 3.84375 | 4 | student1={85,82,78,65,66}
student2={73,42,84,52,55}
student3={55,74,92,86,100}
student4={55,74,92,58,87}
student5={79,80,90,76,85}
average1=sum(student1)/5
average2= sum(student2) / 5
average3 = sum(student3) / 5
average4 = sum(student4) / 5
average5= sum(student5) / 5
if average1>=80 and average1<101:
print("Stu... |
598541e7497d753b7e1ddbaf3da39ab0c4a21228 | desittisagar/Freelancing_Biodiversity-Estimation-Assignment | /Biodiversity.py | 1,317 | 3.796875 | 4 | import math
# CalculateDistance calculates the distance in kilometres (km) between two locations.
# CalculateDistance takes four variables, the latitude and longitude of the first
# location and the latitude and longitude of the second location. It returns the
# distance in km between the two locations.
#E... |
8f289f68f488126c5bd52a136ffa37cdb19afff0 | cthulhu1988/RandomPython | /formatdecimal.py | 80 | 3.59375 | 4 | num = 12345
num1 = 123.1
print(format(num,"10"))
print(format(num1,"10f"))
|
78c14497c90f6f22eaabf030a504057072dac1c1 | Angcelo/EDD_1S2019_P1_201701020 | /Usuarios.py | 2,094 | 3.546875 | 4 | import os
class NodoDoble:
def __init__(self, nombre):
self.nombre=nombre
self.siguiente = None
self.anterior = None
class usuarios:
def __init__(self):
self.primero=None
self.tamaño=-1
def estaVacia(self):
return self.primero==None
def get_tam(self):
return self.tamaño
d... |
3d4eb65834ddbf2dd93dd94b566cfe27874f8b1c | bgoonz/UsefulResourceRepo2.0 | /_PYTHON/DATA_STRUC_PYTHON_NOTES/python-prac/prac-4-beginners/solutions/ch-05-interactive-code/step_2_even_odd.py | 381 | 4.28125 | 4 | print("Let's talk about numbers!")
print()
num_text = input("What's your favorite whole number? ")
num = int(num_text)
if num % 2 == 0:
print(f"What a sweet number, {num:,} is even!")
else:
print(f"That's odd. Yeah, I mean {num:,} is an odd number mathematically.")
# Note:
# {num:,} does digit grouping: 1010... |
52e2e683ca2117146b371e82372bd126f598d344 | Austin-Bell/PCC-Exercises | /Chapter_10/addition.py | 438 | 4.15625 | 4 | """Write a program that prompts for two numbers. Add them together and print the result."""
print("Give me two numbers, and I'll add them")
print("Enter 'q' to quit")
while True:
first_number = input("\nFirst Number: ")
if first_number == 'q':
break
second_number = input("Second Number: ")
try:
answer = in... |
2b906972b987568f0dcaa766838ae04130d3a0b4 | mmoh-i/Wejapa_internship_Wave3_lab-soln | /multiples_3 soln.py | 213 | 4.25 | 4 | #Multiples of Three
#Use a list comprehension to create a list multiples_3 containing the first 20 multiples of 3.
multiples_3 = [x for x in range(0,20,3)]
# write your list comprehension here
print(multiples_3) |
89d97cd7114e61543f44486716f646351820022a | ashleycampion/IrisDataSetProject | /createScatterPlots.py | 10,991 | 3.703125 | 4 | # for creating the actual scatter plots we want matplotlib.pyplot
import matplotlib.pyplot as plt
# we will use pandas groupby() function to group by species
# when plotting the variables against each other
import pandas as pd
# we will use seaborn pairplot() to present all of the plots
# on one image file
import sea... |
37703f82dc847a428de2f498d9968b05fa90d30e | rhitik26/python | /DXCTraining/Examples/1Intro/DataTypes/3List/simple1.py | 486 | 3.671875 | 4 | obj=[
{"team":"India","fname":"Sachin","lname":"Tendulkar"},
{"team":"India","fname":"Saurav","lname":"Ganguly"},
{"team":"India","fname":"Rahul","lname":"Dravid"},
{"team":"Australia","fname":"Steve","lname":"Waugh"},
{"team":"Australia","fname":"Brett","lname":"Lee"},
{"team":"Australia","fname":"Ricky","lname"... |
b4106e5625841b81b791a768b5e4213b231e722f | Coorch/learn-python | /day16/test.py | 107 | 4.03125 | 4 | for i in range(5, 1, -1):
print(i)
l = [3,2,2,1,3]
print(l[:2])
print(l[2:])
#print(l[5])
print(l[5:]) |
62b70600a010014b13823ad7c555583e163400aa | danilo-patrucco/projects | /even or odd count.py | 525 | 3.625 | 4 | #inf 103
#danilo patrucco
#even or odd
import random
def randomnum(i1):
i1 = int(random.randint(1,1000))
print (i1)
if (i1 % 2) == 0:
return True
else:
return False
def main ():
var1 = 0
var2 = 0
var3 = 0
var4 = 0
for var2 in range (var2,100):
... |
9455006eae7efefaa35175f1cbf86594a13a15b8 | Lincoln12w/OJs | /PAT/Basic Level/1063.py | 215 | 3.8125 | 4 | import math
N = int(raw_input())
max_radius = 0
for i in range(N):
[a, b] = raw_input().split()
radius = math.sqrt(int(a)**2 + int(b)**2)
if radius > max_radius:
max_radius = radius
print '%.2f' % max_radius |
13fb43ae1792289f5224d61083d90da51b05bdd1 | RoboDK/RoboDK-API | /Python/Examples/Scripts/ImportCSV_XYZ.py | 5,313 | 3.625 | 4 | # This macro shows how to load a list of XYZ points including speed
# The list must be provided as X,Y,Z,Speed. Speed is optional. Units must be mm and mm/s respectively
# The file can be loaded as a program in the GUI or directly simulated.
from robodk.robodialogs import *
from robodk.robofileio import *
from robodk.... |
e456af0fd91b326017b54d082eb08cf8da3eecdb | akimi-yano/algorithm-practice | /lc/review_991.BrokenCalculator.py | 1,846 | 4.03125 | 4 | # 991. Broken Calculator
# Medium
# 1076
# 146
# Add to List
# Share
# There is a broken calculator that has the integer startValue on its display initially. In one operation, you can:
# multiply the number on display by 2, or
# subtract 1 from the number on display.
# Given two integers startValue and target, ret... |
4248f8174b618d2ed62b2974c23a88b41923b9f3 | pcw263/py2-al | /Stack/stack.py | 410 | 3.546875 | 4 | #!/usr/bin/env python2
#-*- coding:utf-8 -*-
class Stack(object):
def __init__(self):
self.__items__ = []
def isEmpty(self):
return self.__items__ == []
def push(self,item):
self.__items__.append(item)
def peek(self):
return self.__items__[-1]
def pop(self):
... |
4ba6d21888573fb04c67cd61624395120e61aa40 | alineat/web-scraping | /23.navigable-string.py | 612 | 3.671875 | 4 | from bs4 import BeautifulSoup
def leia_arquivo():
'''
-> Lê um arquivo HTML.
:return: os dados do arquivo HTML.
'''
arquivo = open('20.intro-to-soup-html.html')
dado = arquivo.read()
arquivo.close()
return dado
soup = BeautifulSoup(leia_arquivo(), 'lxml')
# Navigable strings - para ... |
833e54e70d2e397fa129154678c515eda45bc769 | Virinas-code/cmprss | /decompress.py | 1,606 | 3.5625 | 4 | #!/usr/bin/env python3
#-*- coding:utf-8 -*-
"""
Projet Algorithme de Compression
Fichier decompress.py
================================
Décompresse le fichier compressé
"""
def decompress(cmprss_filename):
print("Décompression de", cmprss_filename)
print("Lecture du fichier...", end=" ")
cmprss_data = open... |
e7449eee0639b15f1a8d4aeb36f823324afbc04a | GerardProsper/Intermediate-Python-Programming-Course | /Threading vs Multiprocessing.py | 2,425 | 3.671875 | 4 |
# Prcoess : An instance of a program (eg a Python interpreter)
#
# + Takes advantage of multiple CPUs and cores
# + Separate memory space --> Memory is not shared between processes
# + Great for CPU-bound processing
# + New process is stated independently from other processes
# + Processes are interuptable/kill... |
b62cd624803039ef71e5940415a983f776838e2c | Herzen-IVT-19/comp-mod-2017 | /МНК.py | 903 | 3.8125 | 4 | # ИКНиТО, 2-ой курс, ИВТ, Лазарев Игорь
x = []
y = []
n = int(input("Введите количество элементов: "))
for i in range(n):
x.append(float(input("Введите " + str(i + 1) + " элемент Х: ")))
y.append(float(input("Введите " + str(i + 1) + " элемент Y: ")))
print(x)
print(y)
x_sr = sum(x) / n
y_sr = sum(y) / n
x_kv... |
17353fc0e38c9945525034fd916723f071fe29be | kishoreKunisetty/python | /inheritance_clothing.py | 2,621 | 4.15625 | 4 | class Clothing:
def __init__(self, color, size, style, price):
self.color = color
self.size = size
self.style = style
self.price = price
def change_price(self, price):
self.price = price
def calculate_discount(self, discount):
return self.pr... |
5ce771168e148fbc5a71a298e73a55fc73313924 | michael-gif/Python | /Message encrypter, decrypter.py | 2,477 | 4.34375 | 4 | # Coded in Python
'''
This message encrypter and decrypter can encrypt and decrypt messages, even if they have a space in them. It uses a changeable cipher.
The decrypter just has the cipher and alphabet swapped around. So the already encrypted message gets encrypted into the regular alphabet
using the cipher as ... |
47410201494fe1d1cbe443950aa85cbbded7ae8b | ishank296/Python-Data-Structures-Algorithms | /searching and sorting/python-counter.py | 507 | 3.703125 | 4 | from collections import Counter
'''
dict subclass for counting hashable objects.Elements are counted from an iterable or initialized from another mapping
Counter objects have dictionary interface except that they return a zero count from missing items insted of raising a KeyError
'''
c = Counter()
c1 = Counter('thi... |
5f9598b42d73e68da5f95ce11961cdde434e6c06 | YiseBoge/CompetitiveProgramming | /LeetCode/__Contest__/Day8/loud_and_rich.py | 1,033 | 3.515625 | 4 | class Solution:
def loudAndRich(self, richer: list, quiet: list) -> list:
rich_friends = {}
for i in range(len(quiet)):
rich_friends[i] = []
for i in richer:
rich_friends[i[1]].append(i[0])
result = list(range(len(quiet)))
for i in range(len(quiet)):
... |
10f886d1a0ac9cade6e8604b8a6e923951d8bc47 | Cukerman/repos | /1/55сортировкаобмен.py | 471 | 3.609375 | 4 | n=int(input("Введите размер массива "))
import random
a=[]
found =False
for i in range (0,n):
a.append(random.randint(1,10))
print(a[i],"",end="")
print()
#for j in range (0,len(a)) :
found = True
while found:
found = False
for i in range (0,len(a)-1):
if a[i]>a[i+1]:
c=a[i]
... |
4d9a44c6a184d13e97c59796a8fcbb338602dfec | skymemoryGit/HackRank_interview_tools_and_Solution | /palindormeIndex.py | 1,067 | 3.984375 | 4 |
def palindromeIndex(s):
index= -1
length=len(s)
for i in range(0,int(length/2)):
if (s[i]!=s[length-1-i]): #trovato dis-matching
print("dismaching")
if( i+1<length):
substring= s[i+1:length-i]
p... |
ae891db893e3ec746486404035c4093c5d6f4690 | youssefhoummad/Labyrinth | /src/readmap.py | 314 | 3.671875 | 4 | # ========== some func ================
def maze_from_file(map_file):
"read map file and remove \\n; return list of string"
maze = []
with open(map_file, 'r') as file:
# remove char /n from end of string
for line in file.readlines():
maze.append(line[:-1])
return maze
|
8fbbe7783888cae4a647a3295087d3b04f32b68b | Michael78912/SMNW | /game/class_/damagenumbers.py | 815 | 3.65625 | 4 | """damagenumbers- an enemy will have a list of damage numbers.
it will display them all over time.
"""
import os
import random
import pygame as pg
GRAY = (220, 220, 220)
class DamageNumber:
"""display as a number coming from the enemy"""
lifespan = 60
dead = False
font = pg.font.Font(os.path.join('data', 'Roboto-... |
fd1aaed929164fc35d146816b1ec558d1a4aa987 | ladroff/python_hw_3 | /1.py | 201 | 4.03125 | 4 | x = int(input("Введите отрицательное число :"))
if x < 0:
print("Всё верно,число - отрицательное")
else:
print("Не верное число") |
9ee12e7f5a84977ee45f32c136ffa2180fcb7810 | tusharsadhwani/daily_byte | /p136_partners.py | 941 | 4.21875 | 4 | """
Given an integer array, nums, return the total number of “partners” in
the array.
Note: Two numbers in our array are partners if they reside at different
indices and both contain the same value.
Ex: Given the following array nums...
nums = [5, 5, 3, 1, 1, 3, 3], return 5.
5 (index 0) and 5 (index 1) are partners... |
f1bf832b83748cb4d5c7c9fde6bf4d86236d5ddd | JuanAmaya14/saga_py_platzi | /Intermedio/Listas y diccionarios/list_comprehensions.py | 337 | 3.796875 | 4 | def run():
# squares = []
# for i in range(1, 101):
# if i % 3 != 0:
# squares.append(i**2)
squares = [i**2 for i in range(1, 10) if i % 3 != 0]
print(squares)
my_list = [1, 2, 3, 4, 5, 6, 7]
elevate = [i for i in my_list if i != 5]
print(elevate)
if __name__=='__m... |
0a8d337aa61e72ffabae4c435ad2d4c8e481aa09 | YSQC/PythonCode | /H_Model/卷积神经网络/手工实现/Activations.py | 965 | 3.90625 | 4 | import numpy as np
class Relu:
"""Relu层"""
def __init__(self):
self.mask = None
def forward(self, x):
self.mask = (x <= 0)
out = x.copy()
out[self.mask] = 0
return out
def backward(self, dout):
dout[self.mask] = 0
dx = dout
return dx
... |
20ee555ab84990ecb7041d541195213e402f3dc2 | CharmSun/FuckingOffer | /python/38_StringPermutation.py | 3,965 | 3.734375 | 4 | # 题目:字符串的排列
# 输入一个字符串,打印出该字符串中字符的所有排列。
# 你可以以任意顺序返回这个字符串数组,但里面不能有重复元素。
from typing import List
class Solution:
# 1、固定第一位所有可能值,后面的递归全排列
# 2、处理当前位时,注意去重,做剪枝
def permutation(self, s: str) -> List[str]:
if not s:
return []
s_list = list(s)
res = []
def dfs(i):
... |
94361d00c361b649fcc7c16c4d2bc7d267a9d087 | vanderson-henrique/trybe-exercises | /COMPUTER-SCIENCE/BLOCO_37/37_2/conteudo/recursao.py | 220 | 3.828125 | 4 | def countdown(n): # nome da função e parâmetro
if n == 0: # condição de parada
print('FIM!')
else:
print(n)
countdown(n - 1) # chamada de si mesma com um novo valor
countdown(5)
|
9e9c40c0e1ee0ef49ff70c82bf8bc3fde39ac8b5 | christianparker512/HelloWorld | /operators.py | 210 | 3.671875 | 4 | a = 12
b = 3
print(a + b)
print(a - b)
print(a * b)
print(a/b)
print(a//b)
print(a % b)
print ()
print(a + b / 3-4 *12)
print ((((a + b)/3)-4)*12)
c = a + b
d = c/3
e = d-4
print (e *12)
print (a/(b *a)/b) |
724c160bbe1fd4396071339973fb29f2c38ec188 | WISDEM/FLORIS | /floris/types.py | 4,084 | 3.65625 | 4 | #
# Copyright 2019 NREL
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use
# this file except in compliance with the License. You may obtain a copy of the
# License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software dist... |
521d17256ead010e719b89bd5d71ecf1c1355ec2 | TheFuzzStone/hello_python_world | /chapter_9/9_5.py | 2,266 | 4.15625 | 4 | # 9-5. Login Attempts: Add an attribute called login_attempts
# to your User class from Exercise 9-3 (page 166). Write a
# method called increment_ login_attempts() that increments
# the value of login_attempts by 1. Write another method
# called reset_login_attempts() that resets the value
# of login_attempts to 0. Ma... |
457f63e2e067720e0a73c60249f7337f6c6e777c | jicahoo/pythonalgr | /leetcode/241_DifferentWaysToAddParentheses.py | 1,833 | 3.765625 | 4 | import unittest
class Solution(object):
def diffWaysToCompute(self, input):
"""
:type input: str
:rtype: List[int]
"""
for c in input:
print c
def compute(self, input):
'''
Compute next step.
:param input: [input]
:return: In... |
b5680268ac924e92caf160f5886d5a0f121f608f | durmus-pala/IsItArmstrong | /is_it_armstrong.py | 456 | 4 | 4 | number = input("Please Enter a positive integer number: ")
number_list = []
if number.isdigit() == True:
for i in range(len(number)):
number_list.append(int(number[i]) ** len(number))
if sum(number_list) == int(number):
print(number, "is an Armstrong number")
else:
print(number, "i... |
a25ce55bbe56bdb48943821f618c5870de56ebe2 | davidmello/python-fundamentals | /Aula 02/host_connect.py | 284 | 3.90625 | 4 | #!/usr/bin/python
# modulo que nao mostra o que esta sendo digitado
import getpass
hostname = raw_input('Insira o IP do host: ')
user = raw_input('Entre com o Usuario: ')
password = getpass.getpass('... e agora a senha: ')
print "Acessando host %s:%s@%s" % (user,password,hostname) |
0c3e37ef6e1dc82985dd99b5ddc59e37b676bb70 | EzgiDurmazpinar/CrackingTheCodingInterview-6thEdition-Python-Solutions | /Chapter2/2.2.py | 1,650 | 4.25 | 4 | #2.2
#Return Kth to Last: Implement an algorithm to find the kth to last element of a singly linked list.
#This part is just the implementation of Linked list not solution to this problem
class Node():
def __init__(self,value = None ):
self.value = value
self.next = None
def set_next(self,next_... |
bea9c7d7c093e18017edd78fd235f4c0fcb78821 | fibeep/zoo | /platypus.py | 1,119 | 3.578125 | 4 | from mammal import Mammal
from random import randint
from oviparous import Oviparous
class Platypus(Mammal, Oviparous):
natures_mix_and_match = True
__perry_the_platypus = True
def __init__(self, animal_name, sound="Perry the platypus!"):
super().__init__(animal_name, sound)
''' ... |
5a72e58db658cc9e46211eb412742e4a141d075f | kiranganesh-s/python | /day 2 work.py | 2,101 | 3.65625 | 4 | Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> hours="thirty"
>>> print(hours)
thirty
>>> days="thirty days"
>>> print(days[0])
t
>>> challenge="i will win"
>>> print(challenge[7:10])
w... |
164a7ee0a4ebe60c72dbaadd7d6be61b139c4229 | jamescarson3/tmp | /python_intro/python_examples/6_compare.py | 946 | 4.28125 | 4 | print ""
print "Comparisons"
print ""
print "4 > 3 is " + str( 4 > 3 ) # 4 greater than 3
print "4 < 3 is " + str( 4 < 3 ) # 4 less than 3
print "4 == 3 is " + str( 4 == 3 ) # 4 equal to 3
print "4 >= 3 is " + str( 4 >= 3 ) # 4 greater than or equal to 3
print "4 <= 3 is " + str( 4 <= 3 ) # 4 less than... |
1fd420f5bc29b991d1a6dc51d664442f4dede8b4 | caiqinxiong/python | /web前端/day59/day59/05pymysql增操作.py | 590 | 3.546875 | 4 | """
pymysql增操作
"""
import pymysql
conn = pymysql.connect(
host="localhost",
port=3306,
database="userinfo",
user="root",
password="123456",
charset="utf8"
)
cursor = conn.cursor()
# 拼接语句
sql = "insert into info (username, password)VALUES (%s, %s)"
# 执行
try:
cursor.execute(sql, ["大旭",])
... |
e31e67bce72757ff2fe58982420614afbea0f304 | Carlesgr88/Primer_Programa | /contador de letras mayusculas.py | 371 | 3.828125 | 4 |
frase_usuario= input("Introduce una frase: ")
mayusculas=["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"]
n_mayusculas= 0
for letra in frase_usuario:
if letra in mayusculas:
n_mayusculas += 1
else:
n_mayusculas += 0
print("En tu ... |
e9c32ac538b91612b0c5eb1b2bc907b3730738f9 | maizijun/study | /leetcode/#208 trie_pre_tree.py | 1,612 | 4.0625 | 4 | class Trie:
### good question ###
def __init__(self):
"""
Initialize your data structure here.
"""
self.trie = {}
def insert(self, word: str) -> None:
"""
Inserts a word into the trie.
"""
tree = self.trie ## tree 和 self.trie 指向同一个内存地址 ##
... |
0471cc85fe19df7ee3c39085605cc2bc1f895106 | Sarthak1503/Python-Assignments | /Assignment8.py | 1,651 | 4.5 | 4 | #1. What is Time Tuple?
print("question1")
import time
print(time.gmtime(0))
print("\n")
#2nd Method
import time
print(time.localtime(0))
print("\n")
#2. Write a program to get formatted time.
print("question2")
import time
localtime = time.asctime( time.localtime(time.time()) )
print ("Local current time is", loc... |
6a8a1218bc783cf75b67da231e7223be50c10043 | itroulli/HackerRank | /Python/Date_and_Time/002-time_delta.py | 992 | 3.8125 | 4 | # Name: Time Delta
# Problem: https://www.hackerrank.com/challenges/python-time-delta/problem
# Score: 30
from datetime import datetime
for _ in range(int(input())):
dt1 = datetime.strptime(input(), '%a %d %b %Y %H:%M:%S %z')
dt2 = datetime.strptime(input(), '%a %d %b %Y %H:%M:%S %z')
print(int(abs((dt1-... |
8cca77134350cc180c6b0af73f3e267678d3c582 | Tarang1993/News-Updates | /News.py | 1,059 | 3.546875 | 4 | # Author: Tarang Patel
# Email : tarangrockr@gmail.com,
#!/usr/bin/python
import urllib
import urllib2
import xml.dom.minidom
from Tkinter import *
from xml.dom import minidom
from ScrolledText import ScrolledText
def ShowNews():
url = "http://news.prlog.org/in/rss.xml"
u = urllib2.urlopen(url)
xml ... |
2309980f03cb3bf8238617990a45ed642237a686 | Karkalash/regex_sum | /Python/errorchecks.py | 1,296 | 4.15625 | 4 |
numDict = [] #array to store number intakes
def getLargest(): #get largest number by looping through numDict
largest_number = None
for num in numDict:
if largest_number is None: #check to see if there is no largest known yet, assign it to the first value
largest_number = num
... |
2376bac30dff8d2d84e60331d622d2cd0e3d24a3 | liaxon/STAT339HW-2 | /regressionmain.py | 5,809 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 22 20:18:05 2020
@author: Liam
"""
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
# TODO: clean up
# NOTATION: Throughout these comments, the number of data points is N, while
# the number of parameters ('X values') is M
# Takes in a da... |
ab6338fbd221237bff6113a340128bab6e7063a0 | mintdouble/LeetCode | /Easy/476_数字的补数/main.py | 361 | 3.703125 | 4 | # 思路:先将数字转化成二进制形式,再交换其中的0和1的位置,再转化成十进制
class Solution:
def findComplement(self, num: int) -> int:
bin_num = bin(num)[2:]
bin_num = bin_num.replace('0','2')
bin_num = bin_num.replace('1','0')
bin_num = bin_num.replace('2','1')
return int(bin_num, 2)
|
bb27d62252000540074df6b7a9fcaaf3ca27ebfb | joemulray/260 | /2/problem3.py | 1,370 | 3.546875 | 4 | #!/usr/bin/env python
"""
Joseph Mulray
1/20/17
CS 260 HW2: Implimentation
problem3: Run your concatenation functions on lists of
lengths 1,000 through 15,000 and measure how long it takes to run
"""
from cell import Cell
import timeit
from problem1 import list_concat
from problem2 import list_concat_... |
64ab60142f8e33752312be299546dd1b93f5b7d2 | stevenonthegit/coding-challenges | /foobar/bomb_baby.py | 3,084 | 3.96875 | 4 | #bomb_baby
#First, the bombs self-replicate via one of two distinct processes:
#Every Mach bomb retrieves a sync unit from a Facula bomb; for every Mach bomb, a Facula bomb is created;
#Every Facula bomb spontaneously creates a Mach bomb.
#For example, if you had 3 Mach bombs and 2 Facula bombs, they could either prod... |
ae60a906fce4229e215ab72f554860679ac2436f | LCarnovale/Orbits | /loadSystem.py | 11,219 | 3.765625 | 4 | # Author : Leo Carnovale
# Last Updated : 30/09/2017
#
# LoadFile - loads data from a .txt file that is laid out as a table
#
# In the text file:
# - Lines *BEGINNING* with '#' will be ignored
# - Lines beginning with '$' will be parsed in as variables to the data dictionary.
# The variables will be stored a... |
a2d3f3991a4deb86b1945d259d164d53a0faa3b6 | coldmanck/leetcode-python | /0002_Add_Two_Numbers.py | 1,387 | 3.78125 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
# iterative solution in 2020
'''
carry = 0
dummy_head = ListNode(-1)
... |
46500e06310a7c56f312a32b1272edbd5ce08c71 | qingnianmeng/Image-processing-app | /image_processing/basic_processing.py | 4,949 | 3.671875 | 4 | """
Module contains functions that perform some basic image operations
"""
import cv2
import numpy as np
import matplotlib.pyplot as plt
def scale(img, factor):
"""
scale the image based on factor.
:param img: target image to scale
:param factor: scale factor
:return: rescaled image
"""
if... |
f09898f97d47f3028095673c1a0f9c72d8592754 | Hellofafar/Leetcode | /Easy/383.py | 1,281 | 3.921875 | 4 | # ------------------------------
# 383. Ransom Note
#
# Description:
# Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.
# Each letter in ... |
19ff2ceb51b5e1be3ac4bba453ffe1bf840fe61b | shunchuan/BullfightingAnalysis | /Card.py | 2,026 | 3.90625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
import math
class Card(object):
def __init__(self, people_num, per_people_card_number):
self.Card_Pair = math.ceil(people_num * per_people_card_number / 52) # 多少副牌
self.Original_Cards = ('A', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K') #... |
acad6abca39c18fbdf77bae0c0ba2d784ddfffe6 | ajuna/project-euler | /project-euler/problem20.py | 169 | 3.75 | 4 | #find the sum of the digits in the number 100!
n=100
s=1
a=0
b=0
while(n>0):
s=s*n
n=n-1
while(s>0):
a=s%10
b=b+a
s=s/10
print "sum of the digits in 100!=",b
|
bbc98d6060fc8793ac6d3027a8f63e2b06d6b827 | chaseleasy/python_patterns | /工厂模式/工厂模式.py | 1,590 | 4 | 4 | '''
工厂模式的实现
'''
from abc import ABCMeta, abstractmethod
# 产品抽象类
class Product(object):
__metaclass__ = ABCMeta
def __init__(self, factory, type):
self.factory = factory
self.type = type
@abstractmethod
def get_factory_name(self):
pass
@abstractmethod
def get_fac... |
9f24535062c7b6bd39fd8dc24c8fb5d20b4cae95 | Savirman/Python_Lesson02 | /Example04.py | 1,138 | 4.125 | 4 | """"
Пользователь вводит строку из нескольких слов, разделённых пробелами.
Вывести каждое слово с новой строки. Строки необходимо пронумеровать.
Если слово длинное, выводить только первые 10 букв в слове.
"""
# Создание строки из слов, вводимых пользователем
user_phrase = []
for word in input("Напечатайте не... |
8a6d62215c390835d41f7adca4598b6976824079 | andrew-webb07/petting_zoo | /swimming/swimming_animals.py | 1,839 | 3.859375 | 4 | from datetime import date
from animals import Animal
class Catfish(Animal):
def __init__(self, name, species, food, chip_num):
super().__init__(name, species, food, chip_num)
self.swimming = True
def feed(self):
print(f'{self.name} was fed {self.food} on {date.today().strftime("%m/%d/%... |
b53b1b767ce1549ff64703f0d776cc63ca4abf68 | D-Vaillant/euler_problems | /python/problem088.py | 1,005 | 4.0625 | 4 | """ problem088.py:
A natural number N that can be written as the sum and product of a
given set of at least two natural numbers, {a_0, a_1, ..., a_k-1}
is called a product-sum number:
N= sum(a_i : i < k) = product(a_i : i < k)
For example, 6 = 1*2*3 = 1+2+3.
For a g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.