blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
6b96e98d60e5296a041e9934295f93735c2c088d | paras-bhavnani/Python | /Python/DataTypeAndCoversions/Q1.py | 255 | 3.703125 | 4 | word1 = 'w3resource'
word2 = 'w3'
word3 = 'w'
def task1(word):
answer = word[0:2] + word[len(word) - 2:len(word)]
if len(answer) < 4:
print('Empty String')
else:
print(answer)
task1(word1)
task1(word2)
task1(word3) |
6687375e1a810388c09f8bc297a61afd404f92d5 | zhanghognbo/aaaa | /three_chuan.py | 181 | 3.671875 | 4 | import random
list=[]
for i in range(20):
list.append(random.choice(range(100)))
print(list)
for i in range(len(list)):
list[::2]=sorted(list[::2],reverse=True)
print(list)
|
9fed6970d496128ce9141b462bed06d178d16fa0 | aikozijlemans/intellij-plugin | /test-data/python/documentation/detailedRenderer/hover/type/counter/code.py | 323 | 3.828125 | 4 | class Counter(object):
"""This is a counter"""
def __init__(self, n=0, name="counter"):
self.n = n
self.name = name
def increment(self, n):
return self.n
def foo(bar) -> int | str | bool:
return bar;
# Caret between . and increment
Counter.increment
x = True
x = 1
x = 2
print... |
774363fdf61b4660b2d04e1fcb1dff3dfeafa8bd | cmanny/expert-octo-garbanzo | /project_euler/2.py | 301 | 4.0625 | 4 | import sys
def even_fib(N):
a, b = 0, 1
even_sum = 0
if N < 2:
return N
else:
while b < N:
if b % 2 == 0:
even_sum += b
a, b = b, a + b
return even_sum
t = int(input())
for _ in range(t):
print(even_fib(int(input())))
|
6fdd9941403730504345b6de516ae9eda03601c4 | etangreal/compiler | /test/tests/05class/test_class-polymorphism_001.py | 292 | 3.734375 | 4 | class A( object ):
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def func( self ):
return a.x + a.y + a.z
if True:
a = A(7, 70, 700)
else:
a = "abc"
print a.func()
if False:
a = A(7, 70, 700)
else:
a = "abc"
print a
|
073da41d71e62466af8f0943c66d3c830e89416d | zhb1207/Practice | /EulerProj/P7.py | 230 | 3.859375 | 4 | from math import sqrt
i = 2
step = 0
def isprime(n):
for i in range(2, int(sqrt(n)) + 1):
if n % i == 0:
return False
return True
while step != 10001:
if isprime(i):
step += 1
i += 1
print(i - 1)
|
571f8473c8269609738cd829a5a0108d94df9975 | gsketefian/regional_workflow | /ush/python_utils/misc.py | 1,764 | 4.34375 | 4 | #!/usr/bin/env python3
import re
def uppercase(str):
""" Function to convert a given string to uppercase
Args:
str: the string
Return:
Uppercased str
"""
return str.upper()
def lowercase(str):
""" Function to convert a given string to lowercase
Args:
str: t... |
5054646d2d41d1464a53eca9f11b342970b48f5a | SSD-2021/backend-study | /Problem Solving/DONGHAK/[boj]/[boj]10947.py | 173 | 3.703125 | 4 | import random
arr = []
while len(arr) < 6:
temp = random.randrange(1,46)
if temp in arr:
continue
else:
arr.append(temp)
arr.sort()
print(arr) |
5b955eddec266f3e066901938749480cbe4c6ea9 | mehulthakral/logic_detector | /backend/dataset/inorderTraversal/inorder_22.py | 746 | 3.5625 | 4 | class Solution:
def inorderTraversal(self, root: TreeNode) -> List[int]:
## RC ##
## APPROACH : STACK ##
## (question demands iterative solution)
## TIME COMPLEXITY : O(N) ##
## SPACE COMPLEXITY : O(N) ##
res = []
stack = []
currNode = r... |
bc727f0d6c28aa0050711f4d5eeed36e9cfdbe0a | dpalatynski/colony_of_flies | /colony_of_flies.py | 5,448 | 3.875 | 4 | import pygame
import random
import math
import numpy as np
import sys
import matplotlib.pyplot as plt
WHITE = (255,255,255)
GREEN = (0,255,0)
DARK_GREEN = (50,205,50)
RED = (255,0,0)
BLACK =(0,0,0)
class fly():
def __init__(self, x, y):
"""
(x,y) - coordinates of fly
"""
... |
1815c61ba168c96b9407093fdd29e7e32ba88d03 | sufi-yan/URI-Beginner-Solution | /URI-1011.py | 153 | 3.671875 | 4 | #URI-1011
pi = 3.14159
R = float(input(""))
res = (4/3.0)*pi*(R*R*R)
print("VOLUME = {:.3f}".format(res))
#Solved by https://github.com/sufiyanism |
845496c350c442a9e7649a8dc016e3c9df4f14c3 | emmacamille/Hackbright | /billCalculator.py~ | 1,334 | 4.21875 | 4 | # This is a comment and it not read by the interpreter
# These are useful for describing difficult code or adding reminders.
# TODO - fix this code :D
# (Part 1): Instead of using the hard coded ".18",
# Ask the user to input the percentage of tip they want to give.
# Save the input to a variable.
# Use the variable ... |
b4295448f751c3a3c729dbc577135cebd09a7a0d | vecin2/em_automation | /sqltask/sqltask_jinja/globals.py | 154 | 3.734375 | 4 |
def camelcase(st):
if not st:
return ""
output = "".join(x for x in st.title() if x.isalnum())
return output[0].lower() + output[1:]
|
316ae5ad340667448e4f64bbf4201d7ebe44bb2a | lhd0320/AID2003 | /official courses/month01/day12/exercise04.py | 388 | 3.859375 | 4 | class Car:
def __init__(self,brand,speed):
self.brand=brand
self.speed=speed
class Electrocar(Car):
def __init__(self,brand,speed,battery_capacity,charging_power):
super().__init__(brand,speed)
self.battery_capacity=battery_capacity
self.charging_power=charging_power
e0... |
29980e64908dfc61a7cef920f4f2a4f1c8a1dda4 | unnat5/Data-Structures-and-Algorithms-Specialization | /Coursera Algorithm/Algorithmic Toolbox/week4_divide_and_conquer/1_binary_search/binary_search.py | 1,288 | 4.03125 | 4 | # Uses python3
import sys
def binary_search(a, x,high,low):
#left, right = 0, len(a)-1
# write your code here
if high<low:
return -1
mid = low + (high-low)//2
if a[mid]==x:
return mid
elif a[mid] < x:
return binary_search(a,x,high,mid+1)
else :
return binary_... |
404855d29b2c7b00e488fd11b0cece282c6f22c0 | Nyapy/TIL | /04_algorithm/05day/3.py | 112 | 3.78125 | 4 | print(repr('123'))
print(str('123'))
print(eval(str("12*3")))
print(eval(repr("12*3")))
a = repr(123)
print(a) |
2157bf8917509d098df2bac3e16be104915d2781 | dipeshdd/PYTHON | /replacecharacter.py | 680 | 4.28125 | 4 | def ReplaceChar(string,replaceby):
output=""
replace=string[:1]
string=string[1:]
index=string.find(replace)
output+=replace
while(index!=-1):
output+=string[:index]
string=string[index+len(replace):]
index=string.find(replace)
output+=replaceby
output+=string[index+len(replace):]
return output
if... |
6402595387f5044279dcb6343336b8fdbd45cbaa | kspommer/FHCC_Python_II_CS21B | /susanPommerBank.py | 1,931 | 4.375 | 4 | ###########################################################
# Course: CS21B Python Programming: Lab #3
# Name: Susan Pommer
# Description: This program creates a class
# which models a simple bank account and has features
# spanning deposits, withdrawals, interest and
# penalties.
# Driven by test file susanPommerLa... |
3883edc2bbed66be119d9be1993d580e99e00aef | HarshKohli/leetcode_practice | /google/interview_process/licence_key.py | 744 | 3.5 | 4 | # Author: Harsh Kohli
# Date created: 7/24/2020
def licenseKeyFormatting(S, K):
reversed = ""
n = len(S)
for index in range(n - 1, -1, -1):
if S[index] != '-':
reversed = reversed + S[index]
temp, output = "", ""
n = len(reversed)
for index, c in enumerate(reversed):
... |
fa1eec4689b0dce06ce6db24b81163896388d273 | khaled-hossain-code/python-tutor | /regex.py | 235 | 4.21875 | 4 | import re
pattern = ["term1","term2"]
text = "This is a text with term1, not with is the another term around"
print re.search("Hello",text)
#when no pattern is found None is returned
match = re.findall("is",text)
print match.start() |
5578d43de2d5e51e01725682d4e5fd9bf42315dd | Exacte/CP104 | /coop8200_a4/src/q3.py | 692 | 3.96875 | 4 | """
-------------------------------------------------------
-------------------------------------------------------
Author: Mason Cooper
ID: 140328200
Email: coop8200@mylaurier.ca
Version: 2014-09-19
------------
"""
amountData = float(input("How much data will be transmitted(GB)? "))
fastestSpeed = float(inp... |
405d43622e63ec8d1ddc6986872f20ee4dd7739e | nfredrich/Network-Project | /networkinformationfunctions.py | 3,277 | 3.90625 | 4 | import subprocess
import platform
hostname = ""
def getHostName(): # defines the function that gets the hostname from the user
global hostname # declares hostname as a global variable and allows you to change it within the function
hostname = input("\nEnter the target hostname: ") # prints a user request to t... |
11b1aa4b3eb5156f08c947809f12e2508e0796d9 | nikl1425/Snake | /player.py | 1,567 | 3.625 | 4 | import pygame
# Game config
WIDTH = 600
HEIGHT = 600
FPS = 1
SCORE = 0
clock = pygame.time.Clock()
red = (161, 40, 48)
lime = (0, 255, 0)
snake_body = []
x_back = 30
y_back = 30
intro_screen = False
class Player:
def __init__(self, x, y, width, height, direction):
self.x = x
self.y = y
sel... |
61e13505bf99a93d2fbb825959a5b79223937e18 | 4daJKong/Leetcode_by_Python | /026_rmDupli.py | 997 | 3.609375 | 4 | def removeDuplicates(nums):
n = len(nums)
i = n - 1
while (i > 0) and (n > 1):
if nums[i] == nums[i - 1]:
del nums[i]
n = n - 1
i = n - 1
else:
i = i - 1
return nums
def removeDuplicates_demo(nums):
n = len(nums)... |
e2e571532a9da8b6be5f8caaa17d1b438d5ba452 | kotano/brain-games | /brain_games/game_engine.py | 1,786 | 3.828125 | 4 | from brain_games.cli import welcome_user
import prompt
DIFFICULTY = {'easy': 3, 'normal': 5, 'hard': 15, 'infinite': 1000}
def engine(game_module, rounds=None):
'''Main algorithm for building games. Takes as a required argument game_module
with function named generate, use second argument to enable difficu... |
4af1787ac3b1899f7f5b12b4aaca84c622b63d5b | Srajan011/capgemini | /Python Programs Capgemini/Python Programs Capgemini/day1/programs/program1.py | 126 | 3.890625 | 4 | #Input your name into a variable called name and then print "Hello,
#<your name here>"
name = 'Hiren'
print("Hello",name)
|
6b379da1094fd28998410b29dbb35a6c4397c01c | juanksRuiz/Utilidades | /Estadistica.py | 609 | 3.5 | 4 | def promedio(valores):
#Retorna el promedio de los valores ingresados
suma = 0
for v in valores:
suma = suma + float(v)
return suma/(len(valores))
def varianza(valores):
#Retorna la varianza de los valores ingresados
mean = promedio(valores)
sumDist = 0
for v in valores:
... |
22c07ecbd4b70880b38d4b414075b4e9ad0f36a3 | Doomsday46/python_course | /venv/python_course/lab2.py | 929 | 3.703125 | 4 | import math as m
def task1():
print("task 1")
print("---- Float -----")
print(firstExpression(1.25, 1))
print(secondExpression(4, 1))
print(thirdExpression(5, 6))
print("---- Integer -----")
print(int(firstExpression(1.25, 1)))
print(int(secondExpression(4, 1)))
print(int(thirdExpr... |
1aeb33a70f36746c21fd174b867805f53486425a | WongWai95/LeetCodeSolution | /25. K 个一组翻转链表/Solution.py | 789 | 3.625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def reverseKGroup(self, head: ListNode, k: int) -> ListNode:
p_head = head
for _ in range(k):
if p_head == None:
... |
20f35c3afb011f4d3528ba4b4ba7035a5d0beec0 | amitks815/Old_programs | /argv/commandlinearg.py | 231 | 3.5625 | 4 | from sys import argv
print ("value1",argv[0])
print ("value1",argv[1])
print ("value1",argv[2])
print ("value1",argv[3])
print ("value1",argv[4])
list=[argv[1],argv[2],argv[3],argv[4]]
print (list)
for i in list:
print(int(i)) |
e1752f0195e19a5005b5819ac7f1f02bd20db903 | edimaudo/Project-Euler | /ProjectEuler007.py | 381 | 3.65625 | 4 | def is_prime(n):
n = abs(int(n))
if n < 2:
return False
if n==2:
return True
if not n & 1:
return False
for x in range(3,int(n**0.5)+1,2):
if n % x == 0:
return False
return True
count = 0
for i in range (1,20000000):
if is_prime(i) == True:
... |
46cc2971b7ec747d22c41deb0d30ae7c639fd82a | KFurudate/Atcoder_SHOJIN | /Atcoder/猪突猛進_貪欲法/辞書式順序/ABC_007_B_辞書式順序.py | 660 | 3.609375 | 4 | #https://atcoder.jp/contests/abc007/tasks/abc007_2
"""
それぞれの文字列の同じ位置同士を先頭から比較していって、初めて不一致になったら、
その文字同士の(アルファベットでの)比較結果が文字列の全体の比較結果である。
例えば、 " a b c d " と " a x " を比較すると、 2 文字目で、 ′ b ′ < ′ x ′ となるので、
" a b c d "<" a x " である。
もし、比較している途中で片方の文字列が尽きてしまったら、文字列の長さが短い方が小さい。
例えば " a b "<" a b c " である。
"""
A = input()
if len... |
3a199fe9062eb986896d2178d8b1e34d0a85a3a8 | ivan-sepulveda/algorithms | /sort/selection_sort.py | 1,717 | 3.59375 | 4 | import sys
test_array = [20, 21, 12, 11, 13, 5, 6]
sorted_test_array = sorted(test_array)
def selection_helper(sorted_array, index_min_unsorted_elem, index_next_unsorted_elem):
return index_next_unsorted_elem \
if sorted_array[index_min_unsorted_elem] > sorted_array[index_next_unsorted_elem]\
els... |
e3fe1f8a9ff986ca4b788b5fdd87719dd13e9417 | curande5786/python-challenge | /PyBank/main.py | 1,904 | 3.578125 | 4 | #PyBank Challenge
#import dependencies
import csv, os
#import file as variable
csv_file = os.path.join("Resources", "budget_data.csv")
#set path for output file
my_report = open("analysis/myreport.txt","w")
#access file and set variable
with open(csv_file) as profLoss:
#read file, set variable for f... |
621048af5fb08e24a18b8c536ea2d8f46b3945b2 | athirarajan23/luminarpython | /data collections/common elements in a string.py | 75 | 3.65625 | 4 | s1={1,2,3,4,5}
s2={1,5,4,7,8}
for i in s1:
if i in s2:
print(i) |
6fcef2d7d20013f4d4f851622e7019287bbd6ad1 | ChiSha2019/USACO_Solution_Python | /Bronze/wordProcessor/word_bronze_jan20/word_processor_class_demo.py | 988 | 3.625 | 4 | '''
strategy:
for each line
keep looping
if current_length + length of next word > K, change line,
update current_length to be length of next word
else current_length = current_length+ length of next word
'''
with open("word.in", "r") as input_file:
line1 = input_file.readline().split()
word_num = int(line... |
2a60bb2c6fea506003224803c00be3feea364f56 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_207/392.py | 1,369 | 3.625 | 4 | # raw_input() reads a string with a line of input, stripping the '\n' (newline) at the end.
# This is all you need for most Google Code Jam problems.
possibles = ['R', 'O', 'Y', 'G', 'B', 'V']
t = int(raw_input()) # read a line with a single integer
for i in xrange(1, t + 1):
params = [int(s) for s in raw_input(... |
b085620eafa668f1b311db5748926d31f45969dc | shuowenwei/LeetCodePython | /Easy/LC70ClimbingStairs.py | 431 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Wei, Shuowen
https://leetcode.com/problems/climbing-stairs/
"""
class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
results = []
for i in range(n+1):
if i < 3 :
results.... |
e9f475711fef9e5b9e71e15656932bea76fd47f3 | nacho1415/Toy_Blockchain | /OneDrive/바탕 화면/알고리즘/9000~10000/9226.py | 475 | 3.875 | 4 | while(True):
item = list(input())
if(item[0] == "#"):
break
else:
while(True):
if(item[0] == "A" or item[0] == "E" or item[0] == "I" or item[0] == "O" or item[0] == "U" or item[0] == "a" or item[0] == "e" or item[0] == "i" or item[0] == "o" or item[0] == "u"):
pri... |
7933043bc5906632faa1fee7a8bc662df39b14d7 | jeongwoohong/iot_python2019 | /01_Jump_to_python/3_control/4_exer/diamond.py | 311 | 3.703125 | 4 | start = 1
while True:
diamond = int(input("홀수를 출력하세요(0 <-종료)"))
if diamond==0:
break
elif diamond%2==0:
continue
else:
while diamond > start:
print(" "*((diamond-start)//2-1)+('*'* start)+" "*((diamond-start)//2-1))
start += 2
|
e27460aa16022bdf0c0cdffd82f09719265d4f7e | vsharmanyc/cse337 | /minor-hw1/burger.py | 1,607 | 4.0625 | 4 | # Vasu Sharma
# 110493783
# vvsharma
#
# CSE 337 (Fall 2019)
# Minor Homework 1, Problem 1
def burger(order):
if type(order) == type("") and order != "":
protiens = 0
toppings = 0
condiments = 0
for x in order:
if x in "BTV":
protiens += 1
elif x in "ltopjcbsmf":
toppi... |
17930a1f3446aa3c6e0e0110d60c32641a3cd3f4 | JairZhu/CODE | /python/tutorial/8_7_7.py | 291 | 3.59375 | 4 | import csv
import sqlite3
db = sqlite3.connect('books.db')
curs = db.cursor()
ins = 'insert into book values(?,?,?)'
with open('article.csv', 'rt') as fin:
books = csv.DictReader(fin)
for row in books:
curs.execute(ins, (row['title'], row['author'], row['year']))
db.commit() |
c8702c326bd11ce0ae6de200840e515f7eefe7cf | mvrramos/python | /curso-em-video/aprovando_emprestimo.py | 449 | 3.890625 | 4 | valorcasa = int(input('Digite o valor da casa '))
salario = int(input('Qual o seu salario '))
anos = int(input('Em quantos anos deseja pagar '))
parcela = anos * 12
valortotal = valorcasa/parcela
porcento = salario * 0.30
print(f'Voce deverá pagar {valortotal} reais todo mês')
if valortotal > porcento or valortotal ... |
4bc2421c92a5b3b3db99f3f95cbff7c90abadce7 | raffivar/SelfPy | /unit_3_strings/palindrome.py | 159 | 3.96875 | 4 | s = input("is palindrome: ")
s = s.lower()
s = s.replace(' ', '')
print(s + " == " + s[::-1] + " ? ")
if s == s[::-1]:
print('OK')
else:
print('NOT')
|
028b5542bf58f27b0607b86349ecdecb254918bd | davidebarcelli/4A_SIS_2018_19 | /pythonBasics.py | 1,253 | 4.125 | 4 | # Questo e' un commento in python
# In python le variabili non hanno un tipo escliito, quindi non necessitano dichiarazione
a = 1
# per stamapre una variabile bast usare print
print(a)
# e' possbile fare stampe piu' complesse, ma tenedo conto dei tipi
print("a = "+str(a)+" !!")
# in python non eistono {}, la dipende... |
9254499cea5fcdaa4a6872741b1b0e38601caa9e | Jugveer-Sandher/PythonProjects | /Dictionaries/main.py | 3,867 | 3.84375 | 4 | import utilities_set
import utilities_dict
def main():
""" Main Program """
# PART A
set1 = {'apple', 'banana', 'orange', 'peach'}
set2 = {'banana', 'pineapple', 'peach', 'watermelon'}
set1_count = utilities_set.get_total_items(set1)
print("The total number of items in set1 is:", set1_count... |
95af104578e282750440cf79f9b4db1a1fbd4d0b | PSohini/python-challenge | /PyBank/Main.py | 2,236 | 3.78125 | 4 | # import the os module
import os
#Module for reading csv files
import csv
#Declare Global Variables
TotalMonths = 0
month_of_change=[]
net_change_list=[]
greatest_increase = ["", 0]
greatest_decrease = ["", 9999999999999999999]
total_net = 0
#Files to load
file_to_load = os.path.join('budget_data.csv')
print(file_to... |
7ca684e1d409382010ea582508d1b6f4d4bd1521 | Kechkin/PythonNiitCourse | /8/count_symbol.py | 183 | 3.875 | 4 | def count_symbol(str, symb):
arr = str.split(" ")
count = 0
for i in range(len(arr)):
if symb in arr[i]:
count+=1
return count
print(count_symbol("Hi Elvis, I am here", "i")) |
c519825eab506b4f074201901eb1f3267fc7ef3f | mpettersson/PythonReview | /questions/data_structure/graph/shortest_snakes_and_ladders_path.py | 3,001 | 4.15625 | 4 | """
SHORTEST SNAKES AND LADDERS PATH
Design an algorithm, which when given two list of tuples representing the start and end of the Snakes and Ladders
on the board, will return the shortest path (i.e., least number of rolls) to the end.
You can assume that the board consists of positions 1 to 100, whe... |
1501710c29e42ebf545a926fcb67ddf344b27f59 | gabriellaec/desoft-analise-exercicios | /backup/user_190/ch23_2020_03_25_17_31_26_355690.py | 149 | 3.828125 | 4 | v=float(input("velocidade?: "))
if v>80:
multa=5*(v-80)
print('Multado em R${0:.2f}'.format(multa))
else:
print ("Não foi multado")
|
6f81518250e625dd14d6287b779e3d46368892d4 | amogchandrashekar/Leetcode | /Easy/Minimum Value to Get Positive Step by Step Sum.py | 1,512 | 4.1875 | 4 | """
Given an array of integers nums, you start with an initial positive value startValue.
In each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).
Return the minimum positive value of startValue such that the step by step sum is never less than 1.
Example 1:
Inpu... |
aff1b6b2088848f50a5e87a514a18f133bca9cc4 | thhsu116/LeetCode | /025_ReverseNodesink-Group.py | 1,719 | 3.703125 | 4 | # https://leetcode.com/problems/reverse-nodes-in-k-group/description/
# 95% 56ms, traverse nodes and use stack to reverse nodes every k steps, time complexity O(n), space complexity O(k)
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = No... |
a66306f1cf870c025229bee8f8e42fe2a670517b | aflyk/hello | /pystart/lesson4/l4t6_2.py | 661 | 3.953125 | 4 | """
Реализовать два небольших скрипта:
а) бесконечный итератор, генерирующий целые числа, начиная с указанного,
б) бесконечный итератор, повторяющий элементы некоторого списка, определенного заранее.
Подсказка: использовать функцию count() и cycle() модуля itertools.
"""
from itertools import cycle
def cyciter(lst):... |
c0a21f04f162653d964754052e554de0c3d02cd2 | Homap/ZtoA_Heterozygosity | /intergenic.py | 385 | 3.578125 | 4 | #!/usr/bin/python
import sys
# Function to read an intergenic coordinate file into a dictionary
def intergenicCoord(intergenic):
intergenicDict= {}
for line in intergenic:
line = line.strip().split("\t")
key, value = line[0], line[1:]
if line[0] in intergenicDict.keys():
intergenicDict[key].append(value)... |
3b4c4d2212e6e44262daca1af0f6d69676dc36fc | YuchinP/TTA-Python | /simple_script.py | 139 | 3.84375 | 4 | x=10
y=2
#Print x+y
'''prints x+y
to the shell'''
print (x+y)
if x == 10:
print ('x = 10')
#Still in statement
#not in statement
|
b3e9f717a8159880033a01ac1a706bb9c2638d0b | sbz786002/MERC | /sndmail.py | 1,433 | 3.5 | 4 | import smtplib, ssl
import requests
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
port = 587 # For starttls
smtp_server = "smtp.gmail.com"
sender_email = "mis3@virolaindia.com"
receiver_email = "mis@albertotorresi.com"
cc = "sbz786005@gmail.com,eavs@virolaindia.com,custo... |
2811d995cab97374495b20bb7eb5e0d0b951d934 | andy5874/python | /classQ2.py | 447 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 30 13:55:08 2020
@author: cjdgh
"""
'''
Question 2
Create a circle class that will take the value of a radius and
return the area of the circle
'''
import math
class CircleArea (object):
def __init__ (self, radius):
self.radius = radius... |
25d6f56295ca62866bcdb7f54801dc5a6561b960 | cwpachecol/022021_SIS420 | /busqueda_no_informada/Busqueda_Coste_Uniforme/Freeway.py | 2,933 | 3.640625 | 4 | # Búsqueda con Coste Uniforme - Uniform Cost Search
from Tree import Node
def Compare(node):
return node.get_cost()
def search_solution_UCS(connections, init_state, solution):
solved = False
visited_nodes = []
frontier_nodes = []
init_node = Node(init_state)
init_node.set_cost(0)
frontie... |
25fdba874f5d2961701952cd56fd1494399144ff | mrhoanglinh23/tranhoanglinh-fundamentals-c4t4 | /Session02/mrlinhAssignment2/seriousexercise3b2.py | 148 | 3.8125 | 4 | number = int(input("enter a number of 1’s and 0’s: "))
for i in range(19):
for i in range(1):
print("0","1","0","1", end=" ")
|
385dfeb4e5339c31ffcf9f8e1c08444ad06bf0c3 | Suhaiz/first | /test/primee.py | 359 | 3.765625 | 4 | upplim=int(input("enter the upper limit\t"))
lowlim=int(input("enter the lower limit\t"))
sum=0
while lowlim<upplim+1:
i=2
flag=True
while i<upplim:
if upplim%i==0:
flag=False
break
i+=1
if flag:
sum=sum+upplim
print("\n",upplim)
upplim-=1
pr... |
fd12957ace2ea082eb8f7f662bbe9f71ba622a62 | liAmirali/lifeSimulator | /conf/config.py | 1,901 | 3.984375 | 4 | # Developed by liamirali: some day on Dec 2020; version idk
# How long should each day be? (in seconds)
dayLength = 1
# Number of people to start the life
peopleC = 10
# Amount of food and money that people will start the world with.
foodinit = 200
moneyinit = 200
# How much money should each person pay for 1 food?... |
472aa753f6737e8cd6e1f4e745cd25f9ee253887 | Huido1/Hackerrank | /Python/06 - Itertools/05 - Compress the String!.py | 235 | 3.8125 | 4 | #url: https://www.hackerrank.com/challenges/compress-the-string/problem
# Enter your code here. Read input from STDIN. Print output to STDOUT
from itertools import groupby
print(*[(len(list(c)), int(k)) for k, c in groupby(input())])
|
d036476016ecc3aa26a04e2a43de1af443c96d8b | nejstastnejsistene/DotBot | /generate_cycle_literals_h.py | 1,614 | 3.5 | 4 | #!/usr/bin/env python
import sys
import itertools
def num_bits(x):
count = 0
while x:
x ^= x & -x
count += 1
return count
# Read the output of ./compute_cycles as pairs of integers.
def read_input():
for line in sys.stdin:
yield map(int, line.split())
# Sort the cycles first ... |
cf57274027adec7baaa811db08f86d508623281e | b73201020/codeingInterview | /Convert_Sorted_List_to_Binary_Search_Tree.py | 1,186 | 3.875 | 4 | # Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
#
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
#... |
b99702f0903579ed555d88735483e101da922e97 | jlikes/randomApps | /fitnessApp.py | 2,473 | 3.5 | 4 | import math
#setter functions
def setGender():
global gender
while True:
print('\nAre you a (1) male or a (2) female?')
gender = input()
print(gender)
if(gender == '1'):
break
if(gender == '2'):
break
return gender
def setWeigh... |
b1345c1881f0581633359e0f8f6548e69ec68a41 | 7ossam39/Simple-calculator- | /calculator.py | 330 | 4.21875 | 4 | num1 = int(input(' Enter your num1 :'))
ope = input('Enter your ope :')
num2 = int(input(' Enter your num2 :'))
if ope == '+':
print(num1 + num2 )
elif ope == '-':
print(num1 - num2 )
elif ope == '*':
print(num1 * num2 )
elif ope == '/':
print(num1 / num2 )
input('Press enter to exi... |
0b9270332b75b16a3a4e00b3e102f34edc03439f | janvanboesschoten/Python3 | /h10_e1_count_emails.py | 700 | 3.65625 | 4 | fname = input("Enter file name: ")
try:
fhandle = open(fname)
except:
print('Cannot open file')
exit()
# putting the senders in a dictionary together with the number of meials they sent
counts = dict()
for line in (fhandle):
line = line.rstrip()
if not line.startswith('From:') :
... |
75454feda00f4aa144244055100820de8cbf635e | bencourtneighhh/AdventOfCode2020 | /day3/main.py | 839 | 3.90625 | 4 | def readFile(): # Reads the input as stores into an array
file = open("input.txt","r")
slope = []
for i in file.readlines():
slope.append(i[0:-1])
return slope
def main(addPos):
slope = readFile()
currentPos = [0,0]
treeCount = 0
while currentPos[0] < len(slope) - 1 :
... |
ddb456019614d8c96f82d05046e04267d4dcb220 | xenonyu/leetcode | /topKFrequent.py | 1,435 | 3.515625 | 4 | import collections
from typing import List
class Solution:
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
stats = list(collections.Counter(nums).items())
heap = [(0, 0)]
def sift_up(heap, i):
val = heap[i]
while i >> 1 > 0 and val[1] < heap[i >> 1][1... |
fc8e8365cc918367d5c383a765e9335e8905e633 | lansatiankong/neural_kbqa | /code/movieqa/clean_entities.py | 1,154 | 3.734375 | 4 | #!/usr/bin/python
"""
Cleans up the entities file.
- Removes commas
- Deduplication of entities
- Converts everything to lowercase
- Sorts entities lexicographically
"""
import argparse
from sortedcontainers import SortedSet
from text_util import clean_word
def main(args):
NEWLINE = "\n"
entities_set = Sort... |
5fb722562cb1200cdb89c907e8ceec98a1fa848e | alart27/ege_2020 | /python_files/informatics_mccme/problem_arrays_R.py | 1,266 | 3.828125 | 4 | """
Дан список целых чисел, число k и значение C.
Необходимо вставить в список на позицию с индексом k элемент,
равный C, сдвинув все элементы имевшие индекс не менее k вправо.
Посколько при этом количество элементов в списке увеличивается,
после считывания списка в его конец нужно будет добавить новый элемент... |
782bde919732f4b13a6615ed4f9a3e55dc893426 | zjf201811/LeetCode__exercises | /小练习/螺旋矩阵.py | 422 | 3.640625 | 4 | # Author:ZJF
class Solution:
def spiralOrder(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: List[int]
"""
the_list=[]
while len(matrix)!=0:
n = matrix.pop(0)
the_list+=n
matrix = list(map(list,zip(*matrix)))
ma... |
9fbfcc1b501aab14aa61c488153585f446d855db | letoshelby/coursera-diving-in-python | /week 3/week 03_01.py | 2,345 | 3.53125 | 4 | # Задание по программированию: Классы и наследование
import csv
import os.path
TYPE_CAR = 'car'
TYPE_TRUCK = 'truck'
TYPE_SPEC_MACHINE = 'spec_machine'
class BaseCar:
def __init__(self, car_type):
self.car_type = car_type
self.photo_file_name = ''
self.brand = ''
self.carrying = 0.0
de... |
5e094d437a29f79c36a72ebecdeb897d18dfb386 | hitochan777/kata | /leetcode/python/group-anagrams.py | 472 | 3.578125 | 4 | from collections import defaultdict, Counter
from typing import List
class Solution:
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
groups = defaultdict(list)
for s in strs:
key = tuple(sorted(list(Counter(s).items())))
groups[key].append(s)
retur... |
86960aaec888c88b37607ce7d652feba0d3324a6 | Unstopab/temp_c_to_f | /temp_c_to_f.py | 155 | 3.5 | 4 | degree_cels = input("請輸入攝氏溫度")
degree_cels = float(degree_cels)
degree_fahr = degree_cels * 9 / 5 + 32
print("華氏溫度為:", degree_fahr) |
a94cec00255f5040df4c55fb1849dca6fed62f52 | rafaelperazzo/programacao-web | /moodledata/vpl_data/423/usersdata/310/90249/submittedfiles/mdc.py | 228 | 3.96875 | 4 | # -*- coding: utf-8 -*-
import math
n1 = int(input('Digite n1: '))
n2 = int(input('Digite n2: '))
i = 1
while true:
i+=1
(n1%i)== (n2%i)==0
if i == n1 or i==n2:
break
print (i)
|
57d3c5b6670ba1b84e8c2c83200a9a4364b1e522 | piyushsingariya/code-practice | /python/learnthehardway/Ex40.py | 435 | 3.609375 | 4 | class Song(object):
def __init__(self, lyrics):
self.lyrics = lyrics
def sing_me_a_song(self):
for line in self.lyrics:
print line
happ_bday = Song(["Happy birthday to you",
"Happy Birthday to you",
"Happy Birthday to you",
... |
432ca418a17f99eb3c27bdd640cabe9770f4ac54 | subhamaharjan13/IW-pythonassignment | /Datatypes/Question3.py | 249 | 4.15625 | 4 | # Write a python program to get a string from a given string where all occurences of its first char have been changed to '$',
# except the first char itself.
string = 'restart'
print("Result string: ",string[0]+ string[1:].replace(string[0], "$")) |
fbfc54fafd1b04e67e625156e640bc7606707790 | weissab/coursera_genomics | /Reading_frames_and_repeasts/check_dna.py | 448 | 3.921875 | 4 | #!/c/Users/Andrea/Anaconda3/python
"""
add annotation here
have to write into command window: 'chmod a+x FILENAME'
adding this line makes the program executable
to run from command window: python FILENAME
"""
# add annotation here:
dna = input('Enter DNA sequence:')
if 'n' in or 'N' in dna:
nbases=dna.count('n')... |
dac9c1b6be52ef0fe30fba708b2783d4436d78aa | learnpython101/PythonFundamentals | /Module 03/Code snippets/Python Dictionary Methods/11 values().py | 1,044 | 4.5 | 4 | """"""
"""
The values() method returns a view object that displays a list of all the values in the dictionary.
The syntax of values() is:
dictionary.values()
values() Parameters
values() method doesn't take any parameters.
Return value from values()
values() method returns a view object that displays a list of all v... |
1421699ac02298e6cbbc0526cdfc37d57fd60d81 | vitocuccovillo/DataScienceBook | /Chapter4/SomeMath.py | 637 | 3.578125 | 4 |
def jaccard(u1, u2):
in_common = len(u1 & u2)
union = len(u1 | u2)
return in_common/float(union)
if __name__ == '__main__':
'''
NOTAZIONE:
- liste: lista = ["a","a","b"]
- insieme: set = {"a","b"} senza ripetizioni
- no_duplic = set(lista) trasforma da lista a set
'''
... |
112be294f9fa5ed7af3ba49f39d2264c2757c4c2 | bonnemai/MyPortfolio | /iress4.py | 1,766 | 3.734375 | 4 | import math
def delete(S, T):
for letter in S:
new_word=S.replace(letter, '', 1)
if new_word==T:
return letter
return None
def swap(S, T):
''' TODO: Check i>1... '''
for i in range(len(S)):
for j in range(i+1,len(S)):
new_word=list(S)
letter... |
e1c0270e392b490074aa8b6e73871c169c0eee61 | rosariovi/curso_python1 | /ciclo_for.py | 85 | 3.65625 | 4 | print("TABLA DEL 5")
for i in range (1,11):
a=i*5
print("5 * ", i, " = ", a)
|
6b7a817d61240ec4913404e9aa790428cb55a5b4 | Helbros72/24-10-21 | /Min_from_3_11_quest.py | 323 | 4.125 | 4 |
def _min_from_3 (x,y,z):
if x < y and x < z :
return (x)
elif y < x and y <z :
return (y)
else :
return (z)
x = int(input(' Enter first number :'))
y = int(input(' Enter second number :'))
z = int(input('Enter third number :'))
print (f' Your minimum number : {_min_from_3(x,y,z)}'... |
15c86dbea3792dcb8b3a33c8c4a8dd1a46fa06c0 | SnehaShree2501/HackerRankPythonPractice | /ListComprehensions.py | 360 | 3.921875 | 4 | x = int(input("Enter 1st co-ordinate"))
y = int(input("Enter 2nd co-ordinate"))
z = int(input("Enter 3rd ordinate"))
n = int(input("Enter the limit"))
ListOfNumbers =[]
ListOfNumbers = [[i,j,k] #list for the loop control variables
for i in range(0,x+1) #multiple loops running here
for j in range(0,y+1)
for k in range(0... |
d9afd4712eec7939651528303d49d996c4c2deb8 | maximdorko/Python | /Program2.py | 3,066 | 4.03125 | 4 | '''
# Loops
for i in [2,4,8,10]:
print("i = ",i)
# Using range
# range(10) means from 0 to 9
for i in range(10):
print("i = ",i)
# range (2,10) will start from 2 and goes up to 9
for i in range(2,10):
print("i = ", i)
# Print the odd numbers from 0 to 20
for num1 in range(1, 20):
if (num1 % 2) != 0:
... |
c2b84076f1ca0b3ac9620c89dcd04f4aaa0156b0 | HandsomeLuoyang/Algorithm-books | /剑指offer/面试题59 - II. 队列的最大值.py | 866 | 3.921875 | 4 | import queue
class MaxQueue:
def __init__(self):
self.queue = queue.Queue()
self.dequeue = queue.deque()
def max_value(self) -> int:
return self.dequeue[0] if self.dequeue else -1
def push_back(self, value: int) -> None:
while self.dequeue and self.dequeue[-1] < v... |
d5bea976843c81e9d703237054c209d71c23c1e9 | Adityasidher/LookingMass | /drivepath.py | 3,181 | 3.9375 | 4 | """ Return the drive names in the system
This file contains the methods used to grab the different drives using kivy's file explorer. Most of this code is original, however it was created using Kivy's documentation listed on their website, as well as reading into python's drive exploring capabilities. The code handle... |
304b405eb84e694feecb69a0b678ad655fd5f147 | thepaul/noodle | /Noodle/dispatcher.py | 7,516 | 3.828125 | 4 | # dispatcher
#
# paul cannon <pcannon@novell.com>
# mar 2005
"""A way to make generic functions -- functions with different versions
depending on the types of the incoming arguments. Used with decorators.
The best way to explain is probably by example, so:
#!/usr/bin/env python2.4
from dispatcher import *
... |
bc6f2014e01eda6010242b3dd1e5cd2aa239e778 | kim-seoyoon/study-python | /sample_canvas_simplegui.py | 339 | 3.5 | 4 | # example of drawing on the canvas
import simplegui
#define draw handler
def draw(canvas):
canvas.draw_text("Hello!",[100,100],24,"White")
canvas.draw_circle([100,100],2,2,"Blue")
# create frame
frame=simplegui.create_frame("test",300,200)
# register draw handler
frame.set_draw_handler(draw)
#start f... |
42c8e4a90399f13740fb735dfb6eb82de4f7b7ce | JasonLinden/FlaskAPI_DataStructures | /linked_list.py | 2,006 | 3.96875 | 4 | class Node:
def __init__(self, data=None, next_node=None):
self.data = data
self.next_node = next_node
class LinkedList:
def __init__(self):
self.head = None
self.last_node = None
def print_self(self):
ll_string = ""
node = self.head
if node is Non... |
709fceb003c5c214fe96df2cba1fa348c30cb4b7 | Borleonid/Conversor | /conversor.py | 2,105 | 4 | 4 | def convierte():
print()
numero=input("Introduce un número:\n")
sistema=input("Introduce un sistema:\n1-Binario a decimal.\n2-Octal a decimal\n3-Hexadecimal a decimal.\n4-Base 32 a decimal.\n5-Salir.\n\n")
if sistema == "1":
sistema=2
final = int(numero,sistema)
print ("El... |
1a34b83bf081ea56b61cb3896349d8f80a36be97 | SiaN07/Algorithms | /countvowels.py | 288 | 4.25 | 4 | '''
Count number of vowels in a string
'''
def countvowels(string):
vowels = set('aeiouAEIOU')
count = 0
for char in string:
if char in vowels:
count = count + 1
print("The number of vowels is", count)
string = "The red pie"
countvowels(string)
|
410d343198a94692272297c5a9b257fe79395e60 | cs1531/learn-python | /v02/repeated_digit_addition_adv.py | 1,362 | 4.1875 | 4 | '''
Write a program that accepts a single digit `a` from the user and
computes the value of a + aa + aaa
E.g. if a = 7, then the output should be 861, which is equal to 7 + 77 + 777
You may assume that user input is always a single digit
HINT: There are many different ways to solve this problem. Try...
1. ... |
1063438ebb7bf1b41bf7beb53b7a2622f2a13eef | JoaozinhoProgramation/Exercios_LP_1B | /Exerc11.py | 148 | 3.640625 | 4 | produto = float(input("Preço do produto:"))
produto = (((produto * 5)/100) - produto)
print("Seu produto com 5% de desconto é {}".format(produto)) |
a2c5e65259e50b0daa084c568bedefbe10b6c224 | yojimbo88/ICTPRG-Python | /w4q1.py | 171 | 3.625 | 4 | x = 0
while x < 26: # while loop that will only stop once variable x reaches 25
print(x)
x = x + 1
# Tomas Franco 101399521
# for x in range(26):
# print(x)
|
5193f2334468101c9c954fe3fea131dfa15908a8 | pingrunhuang/fluent-python | /07-closure-deco/running_average_closure.py | 1,310 | 3.5 | 4 | """
>>> avg = make_averager()
>>> avg(10)
10.0
>>> avg(11)
10.5
>>> avg(12)
11.0
>>> avg.__code__.co_varnames
('new_value', 'total')
>>> avg.__code__.co_freevars
('series',)
>>> avg.__closure__ # doctest: +ELLIPSIS
(<cell at 0x...: list object at 0x...>,)
>>> avg.__closure__[0].cell_contents
[10, 11, 12]
"""
DEMO = "... |
36cfd696405eb7db04fac6f62915a6efbbc4375c | tabinda-s/assignments | /superheropowers.py | 415 | 3.53125 | 4 | import json
# read file
with open('superheroes.json', 'r') as f:
superheroes = json.load(f)
data = []
# define members
members = superheroes['members']
# loop through members and list powers
for member in members:
powers = member['powers']
# loop through powers and print
for power in powers:
data.append(power... |
ef83e5d1e8df9faba407c6b8febeadde0bea9de6 | jhyang12345/algorithm-problems | /problems/queue_two_stacks.py | 565 | 3.90625 | 4 | class Queue:
def __init__(self):
self.stack_in = []
self.stack_out = []
def enqueue(self, val):
self.stack_in.append(val)
def dequeue(self):
if self.stack_out:
return self.stack_out.pop()
while self.stack_in:
self.stack_out.append(self.stack_in.pop())
return self.stack_ou... |
bda5042b4e1e3548c810fd9498eaf840354e0510 | AlejoGomezV/Principios-SOLID | /0001A.py | 403 | 3.84375 | 4 | class Duck:
def __init__(self, name):
self.name = name
def fly(self):
print(f"{self.name} is flying not very high")
def swim(self):
print(f"{self.name} swims in the lake and quacks")
def do_sound(self) -> str:
return "Quack"
def greet(self, duck2: Duc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.