blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
0b48be2de52b543d189741a5c5300f995adf84f2 | EssamQabel/Problem-Solving | /Codeforces/A/41A.py | 200 | 3.71875 | 4 | s = input()
t = input()
result_list = []
for i in range(len(s)):
result_list.append(s[i])
result_list.reverse()
s = ''.join(result_list)
if s == t:
print('YES')
else:
print('NO') |
6d3af464bbf9f8e9cf52f751bb66d9fde3cfbace | manankhaneja/hep-da | /programs/main.py | 2,607 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Mar 23 18:50:07 2018 - constantly improving ever since
@author: Manan Khaneja
"""
# Master program for data extraction without damaging file format
# takes in input the directory in which all the files have to be analysed ( eg. a directory from which neutron data is ex... |
b36872d55259a67b9b0ad8ef8ce8e26e30b75cc0 | benkerns09/digital-crafts-lessons | /files/March8/phonebook.py | 2,012 | 4.0625 | 4 | class PhoneBook(object):
def __init__(self, name, phone):#in it we have the name and phone number
self.name = name
self.phone = phone
self.peopleList = []#I'm not sure what this is
def phoneBookEmpty(self):
if len(self.peopleList) == 0:#if the length of people list is zero...its... |
c6a3dc37f5d97438c3a9a3894cc82f65ec9ff35b | benkerns09/digital-crafts-lessons | /files/March6/mar307.py | 666 | 3.828125 | 4 | def drawtriangle(height, base):
for row in range(1, height + 1):
spaces = height - row
print " " * spaces + "*" * (row * 2 - 1)
drawtriangle(6, 4)
def box(height, width):
for row in range(height):
if row in[0] or row in[(height-1)]:
print("* " * (width))
else:
... |
6c51492aa5005099401d48ce50e6d84e41b59657 | KhalidOmer/Exercises | /Work_Directory/Python/lottery.py | 617 | 3.890625 | 4 | import numpy as np
"""This is a simple common game that asks you to guess a number
if you are lucky your number will match the computer's number"""
def luck_game():
print("Hello, let's check if you're lucky!'")
print("You are asked to guess a number between 0 and 10'")
luck_number = int(np.random.uniform(0,11))
... |
86773d8aa5d642f444192ecc1336560c86d718ca | siddu1998/sem6_labs | /Cloud Computing/Assignment 1/question9.py | 218 | 4.40625 | 4 | # Write a Python program to find whether a given number (accept from the user)
# is even or odd, print out an appropriate message to the user.
n=int(input("please enter the number"))
print("even" if n%2==0 else "odd") |
180256985bff15f54e150f1ff7a6cc4d86a1b365 | siddu1998/sem6_labs | /Cloud Computing/Assignment 1/question10.py | 250 | 3.984375 | 4 | # Write a Python program to count the number 4 in a given list.
length=int(input("Please enter the length"))
list_with_fours=[]
for i in range(0,length):
list_with_fours.append(int(input()))
print("number of 4's")
print(list_with_fours.count(4)) |
f0501f677535546d870b4e28283048c78fb87771 | zhh007/LearnPython | /2.List.py | 619 | 4.0625 | 4 |
x = list('Hello')
print(x)
y = "".join(x)
print(y)
x = [1, 1, 1]
x[1] = 2
print(x)
names = ['Void', 'Alice', 'Jack']
del names[1]
print(names)
name = list('Perl')
name[2:] = list('ar')
print(name)
list1 = [1, 2, 3]
list1.append(4)
print(list1)
x = [1, 2, 1, 3]
print(x.count(1))
a = [1, 2, 3]
b = [4, 5]
a.ex... |
891d590fe33896826dd3c5ce6c6e1bea06e5b980 | pink-floyd-in-venice/pink-floyd-in-venice.github.io | /resources/functions/CsvTripleCreator/main.py | 722 | 3.890625 | 4 | import csv
if __name__== "__main__":
csv_name=input("Inserire nome file csv: ")
if csv_name[-4:] !=".csv":
csv_name += ".csv"
with open(csv_name, "w", newline="") as csv_file:
writer=csv.writer(csv_file, delimiter=' ', quotechar='|')
writer.writerow(["Subject", "Predicate", "Object"... |
c03b3059a659730e6db51364c5dd5144bc5f64a6 | SandeeraDS/FYP-Codes | /After 2019-08-25/python_string/stringTest.py | 563 | 3.734375 | 4 | import re
name = " sande er " \
"dddsds sds sds sdd dsdsd ddsd dsds "
name2 = " sande er " \
"dddsds sds sds sdd dsdsd ddsd dsdsa"
name3 = " BCVFE | sande er " \
"dddsds sds sds sdd 2 .. 3 dsdsd ddsd ? dsdsA1"
newString1... |
f0d2eef82b83a98f36f2a759f585c8cf03ad0327 | SandeeraDS/FYP-Codes | /After 2019-08-25/encoding_test/test.py | 1,093 | 3.53125 | 4 | import re
import nltk
# to install contractions - pip install contractions
from contractions import contractions_dict
def expand_contractions(text, contractions_dict):
contractions_pattern = re.compile('({})'.format('|'.join(contractions_dict.keys())))
def expand_match(contraction):
# print(contracti... |
d3a2e416b3bd15607d71317808f17751667c9e0b | Jeremyreiner/DI_Bootcamp | /week5/Day4/exercise/exerciseXP.py | 3,256 | 4.46875 | 4 | # Exercise 1 – Random Sentence Generator
# Instructions
# Description: In this exercise we will create a random sentence generator. We will do this by asking the user how long the sentence should be and then printing the generated sentence.
# Hint : The generated sentences do not have to make sense.
# Download this wor... |
316aa2bdc7e255944d154ce075592a157274c9bc | Jeremyreiner/DI_Bootcamp | /week5/Day3/daily_challenges/daily_challenge.py | 2,874 | 4.28125 | 4 | # Instructions :
# The goal is to create a class that represents a simple circle.
# A Circle can be defined by either specifying the radius or the diameter.
# The user can query the circle for either its radius or diameter.
# Other abilities of a Circle instance:
# Compute the circle’s area
# Print the circle and get ... |
0cdc78355fca028bb19c771c343ae845b702f555 | Jeremyreiner/DI_Bootcamp | /week5/Day1/Daily_challenge/daily_challenge.py | 2,265 | 4.40625 | 4 | # Instructions : Old MacDonald’s Farm
# Take a look at the following code and output!
# File: market.py
# Create the code that is needed to recreate the code provided above. Below are a few questions to assist you with your code:
# 1. Create a class called Farm. How should this be implemented?
# 2. Does the Farm class ... |
7a7c944b90acd5e775968c985c9f2b58789ed4a7 | christopher-henderson/thesis | /writing.py | 1,896 | 3.53125 | 4 | '''
Wikipedia sucks...unless it doesn't. This is the N-Queens problem implemented
using the following general-form pseudocode.
https://en.wikipedia.org/wiki/Backtracking#Pseudocode
It is getting correct answers, although I am doing something wrong and also
getting duplicates.
'''
N = 8
def backtrack(P, root, accep... |
69005c262433db7d85e18bf3b770ca093533c99f | christopher-henderson/thesis | /backtrack/01knapsack.py | 1,681 | 3.8125 | 4 | from backtrack import backtrack
class KnapSack(object):
WEIGHT = 50
ITEMS = ((10, 60), (20, 100), (30, 120))
MEMO = {}
def __init__(self, item_number):
self.item_number = item_number
def first(self):
return KnapSack(0)
def next(self):
if self.item_number >= len(self.ITEMS) - 1:
return None
ret... |
9c03b56ac31edf5d0163ec4cf3a9cab915a789a4 | christopher-henderson/thesis | /nQueen0.py | 2,178 | 3.75 | 4 | import copy
N = 8
NUM_FOUND = 0
derp = list()
def backtrack(P, C, R):
if reject(P, C, R):
return
# Not a part of the general form. Should it be in 'reject'?
# That would be kinda odd, but it must appended before a call to output.
P.append([C, R])
if accept(P):
output(P)
s = fi... |
7ce103ab49574b9dcb251574c06934c9fb2b00e1 | SvenLC/CESI-Algorithmique | /listes/triParSelection.py | 439 | 3.828125 | 4 | # Ecrire la procédure qui reçoit un tableau de taille N en entrée et qui réalise un tri par sélection
exemple = [1, 3, 5, 6, 3, 2, 4, 5, 6]
def triParSelection(tableau, n):
for i in range(0, n):
for j in range(i, n):
if(tableau[i] > tableau[j]):
min = tableau[j]
... |
9693d52cc708aca038148b57c23f45976ef7ef01 | SvenLC/CESI-Algorithmique | /boucles/exercice6.py | 331 | 3.5625 | 4 | # Écrire un algorithme qui demande un nombre de départ, et qui calcule la somme des entiers jusqu’à ce nombre,
# par exemple, si on entre 5, on devrait afficher 1 + 2 + 3 + 4 + 5.
def somme(nombre):
total = 0
for i in range(0, nombre):
total = total + i
print(i)
return total
print(somme... |
6438fc05212750bb32b2ca3aecbfb970f7568071 | cran/excerptr | /inst/excerpts/excerpts/main.py | 5,131 | 3.5625 | 4 | #!/usr/bin/env python3
"""
@file
module functions
"""
from __future__ import print_function
import re
import os
def extract(lines, comment_character, magic_character, allow_pep8=True):
"""
Extract Matching Lines
Extract all itmes starting with a combination of comment_character and
magic_character... |
3bd68486e51753134cef0461c41bc1f01fa9d68c | NicholasTancredi/python_examples | /examples/simple.py | 6,812 | 3.703125 | 4 | """
File with simple examples of most common use cases for:
- unittest
- pytypes
- pydantic
- typing
- enum
"""
from unittest import TextTestRunner, TestLoader, TestCase
from argparse import ArgumentParser
from typing import NamedTuple, Tuple, Union
from enum import Enum
from math import hypot
... |
d8eea6878b92a31589a7b58cc6a3cdbc5a7299db | Bawya1098/python-Beginner | /day_2_assignment/list_sum.py | 263 | 4.09375 | 4 | number = input("enter elements")
my_array = list()
sum = 0
print("Enter numbers in array: ")
for i in range(int(number)):
n = input("num :")
my_array.append(int(n))
print("ARRAY: ", my_array)
for num in my_array:
sum = sum + num
print("sum is:", sum)
|
44971d0672295eea12f2d5f3ad8dad4faea2c47f | Bawya1098/python-Beginner | /Day3/Day3_Assignments/hypen_separated_sequence.py | 273 | 4.15625 | 4 | word = str(input("words to be separated by hypen:"))
separated_word = word.split('-')
sorted_separated_word = ('-'.join(sorted(separated_word)))
print("word is: ", word)
print("separated_word is:", separated_word)
print("sorted_separated_word is: ", sorted_separated_word)
|
67a947661af531ea618cb15951041076cfaab19b | Bawya1098/python-Beginner | /Week2_day1/Multi_level_inheritance.py | 873 | 3.734375 | 4 | class Micro_Computers():
def __init__(self, size):
self.size = size
def display(self):
print("size is:", self.size)
class Desktop(Micro_Computers):
def __init__(self, size, cost):
Micro_Computers.__init__(self, size)
self.cost = cost
def display_desktop(self):
... |
af0200ae519c67895fbb02c24de47233935b9b0b | Bawya1098/python-Beginner | /Day_1_Assignments/mystery_n.py | 762 | 3.8125 | 4 | def mystery(numbers):
sum = 1
for i in range(0, numbers):
if i < 6:
for k in range(1, numbers): #num1 to 5: sum=2^(numbers**2)
sum *= 2
print(sum)
else: #number6: sum=2^(5*number)*5
if i < 10: ... |
abde32d028db53073878822c4ab038eda0b5a507 | ranellegomez/Object-oriented-Python-calculator | /test/CalculatorTest.py | 3,317 | 3.5 | 4 | import unittest
import ModularCalculator
import RecursiveExponentCalculator
class MyTestCase(unittest.TestCase):
def test_add(self):
for a in range(-100, 100):
for b in range(-100, 100):
for c in range(-100, 100):
print(
'add_test', a... |
fcd96d8a74d9a565277a2ee8b44e9056943a3f30 | tonyfg/project_euler | /python/p04.py | 473 | 3.875 | 4 | #Q: Find the largest palindrome made from the product of two 3-digit numbers.
#A: 906609
def is_palindrome(t):
a = list(str(t))
b = list(a)
a.reverse()
if b == a:
return True
return False
a = 0
last_j = 0
for i in xrange(999, 99, -1):
if i == last_j:
break
for j in xrange(9... |
35d047c6d9377e87680dcc98b62182b49bf89a3e | tonyfg/project_euler | /python/p21.py | 424 | 3.546875 | 4 | #Q: Evaluate the sum of all the amicable numbers under 10000.
#A: 31626
def divisor_sum(n):
return sum([i for i in xrange (1, n//2+1) if not n%i])
def sum_amicable(start, end):
sum = 0
for i in xrange(start, end):
tmp = divisor_sum(i)
if i == divisor_sum(tmp) and i != tmp:
... |
8ea1a9399f7b7325159494391e648245e0e76179 | Danielkaas94/Any-Colour-You-Like | /code/python/PythonApplication1.py | 2,115 | 4.1875 | 4 | def NameFunction():
name = input("What is your name? ")
print("Aloha mahalo " + name)
return name
def Sum_func():
print("Just Testing")
x = input("First: ")
y = input("Second: ")
sum = float(x) + float(y)
print("Sum: " + str(sum))
def Weight_func():
weight = int(input("Weight: ... |
7b1c346f4ef2097de68fbd0b2a4430765ee1d13e | TeknikhogskolanGothenburg/Docker_MySQL_Alembic_SQLAlchemy | /app/UI/customers_menu.py | 2,117 | 3.578125 | 4 | from Controllers.customers_controller import get_all_customers, get_customer_by_id, get_customer_by_name, store_changes, \
store_new_first_name
def customers_menu():
while True:
print("Customers Menu")
print("==============")
print("1. View All Customers")
print("2. View Custom... |
b8d583b681f9579475e30829ac3a596c41406e94 | lsiddd/ml | /NeuralNets/ELM.py | 1,882 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
verbose = False
erro = lambda y, d: 1/2 * sum([np.sum (i **2) for i in np.nditer(y - d)])
def output(x, d, w1, w2=[]):
sh = list(x.shape)
sh[1] = sh[1] + 1
Xa = np.ones(sh)
Xa[:,:-1] = x
#ati... |
f2540cf61a8935116b8ed9153e693541e3c91706 | fear-the-lord/Structural-Balance-Identificator | /manual_network.py | 4,432 | 3.625 | 4 | # Import all the necessary dependencies
import networkx as nx
import matplotlib.pyplot as plt
import random
import itertools
def checkStability(tris_list, G):
stable = []
unstable = []
for i in range(len(tris_list)):
temp = []
temp.append(G[tris_list[i][0]][tris_list[i][1]]['sign... |
18f50b38f9ef8dfc927c8850927d6739bba3dac7 | Philthy-Phil/practice-python | /ex3-ListLessThanTen.py | 541 | 3.765625 | 4 | __author__ = 'phil.ezb'
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
x = []
ui = "\n*************************"
print("Given list of numbers: ", a)
print(ui)
for num in a:
if (num < 5):
print(num, end=", ")
print(ui)
for num in a:
if (num < 5):
x.append(num)
print("here are all the numbers < 5:... |
b698727d6dfa278ead4845b0b150dde2e8439b6e | stawary/LeetCode | /LeetCode/Median_of_Two_Sorted_Arrays.py | 796 | 3.96875 | 4 | #There are two sorted arrays nums1 and nums2 of size m and n respectively.
#两个排好序的数组,求这两个数组的中位数。
#Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
#Example 1:
#nums1 = [1, 3]
#nums2 = [2]
#The median is 2.0
#Example 2:
#nums1 = [1, 2]
#nums2 = [3, 4]
#The median is (2... |
692a0421d4258a93f1a16759976a4a98c5f1af41 | Ejas12/pythoncursobasicoEstebanArtavia | /dia7/tarea6.py | 936 | 3.5 | 4 | import csv
input_file = csv.DictReader(open("C:\\Users\\Esteban Artavia\\Documents\\scripts\\\Pythoncourse\\dia7\\serverdatabase.csv"))
outputfile = open('C:\\Users\\Esteban Artavia\\Documents\\scripts\\\Pythoncourse\\dia7\\output.txt', 'w+')
outputfile.write('NEW RUN\n')
outputfile.close
outputfile = open('C:\\Users\... |
26b5cff2b5c9a9eca56befae9956bc895690c60e | sundusaijaz/pythonpractise | /calculator.py | 681 | 4.125 | 4 | num1 = int(input("Enter 1st number: "))
num2 = int(input("Enter 2nd number: "))
op = input("Enter operator to perform operation: ")
if op == '+':
print("The sum of " + str(num1) + " and " + str(num2) + " = " +str(num1+num2))
elif op == '-':
print("The subtraction of " + str(num1) + " and " + str(num2) + " = " +... |
1a301b5f2b834fb833f81fcb8060853474736c87 | pjjefferies/python_practice | /huffman_encoding.py | 6,229 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 13 21:10:34 2019
@author: PaulJ
"""
# import unittest
# takes: str; returns: [ (str, int) ] (Strings in return value are single
# characters)
def frequencies(s):
return [(char, s.count(char)) for char in set(s)]
# takes: [ (str, int) ], str; returns: String (with... |
10c1c00ec710a8a6e32c4e0f6f73df375f5a72d5 | pjjefferies/python_practice | /find_anagrams.py | 824 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jan 28 21:59:44 2019
@author: PaulJ
"""
def anagrams(word, words):
anagrams_found = []
for a_word in words:
a_word_remain = a_word
poss_anagram = True
for a_letter in word:
print('1: a_word_remain:', a_word_remain)
firs... |
e7eb877dfa1edc9e2f3e0c59c71338453ff9b964 | pjjefferies/python_practice | /censor_test.py | 545 | 3.75 | 4 | def censor(text, word):
word_replace = "*" * len(word)
for i in range(len(text)):
print (i, text[i], word[0])
if text[i] == word[0]:
for j in range(len(word)):
print (i, j, text[i+j], word[j])
if text[i+j] != word[j]:
break
... |
07a627b0e4ab6bb12ec51db84fb72f56032649c4 | Skyorca/deeplearning_practice_code | /FC_tf.py | 3,607 | 4.03125 | 4 | import tensorflow as tf
import numpy as np
from numpy.random import RandomState
#Here is a built-in 3-layer FC with tf as practice
"""
how tf works?
1. create constant tensor(e.g.: use for hparam)
tensor looks like this: [[]](1D) [[],[]](2D)...
tf.constant(self-defined fixed tensor, and type(eg. tf.int16, should be def... |
26d288b468e8cf62b3d27a5ab20513e6889373bf | Wigrovski/Python3 | /SandwichApp/sandwich.py | 399 | 3.625 | 4 | import sys
if sys.version_info < (3, 0):
# Python 2
import Tkinter as tk
else:
# Python 3
import tkinter as tk
def eat(event):
print("Вкуснятина")
def make(event):
print ("Бутер с колбасой готов")
root = tk.Tk()
root.title("Sandwich")
tk.Button(root, text="Make me a Sandwich").pack()
tk.Button(r... |
9c013a6131b469a6d40a294243ec6b6f1c0da02d | JenniferHhj/UcBerkeley-IndustryEng135 | /Neural_Network/NN.py | 4,743 | 3.671875 | 4 |
import tensorflow as tf
import tensorflow_datasets as tfds
tfds.disable_progress_bar()
import math
import numpy as np
import matplotlib.pyplot as plt
import logging
logger = tf.get_logger()
logger.setLevel(logging.ERROR)
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Flatten
... |
ac62e611bd36e4117f7705720bf39692148835f5 | elvirich04/myOOP | /OOP/OOP2.PY | 724 | 3.796875 | 4 | class Person:
def __init__(self, Name, Sex, Age):
self.Name=Name
self.Sex=Sex
self.Age=Age
def Show(self):
if self.Sex=="Male":
pronoun="Mr."
else:
pronoun="Ms."
print("%s %s is %i years old."%(pronoun, self.Name, self.Age))
Person1=Perso... |
ac79e5ed6bfa7b1d928aa2d6eb07f9fcab72d39f | elvirich04/myOOP | /OOP/OOP.PY | 473 | 3.8125 | 4 | class Person:
def __init__(self):
self.Name=""
self.Sex=""
self.Age=0
def Show(self):
if self.Sex=="Male":
pronoun="Mr."
else:
pronoun="Ms."
print("%s %s is %i years old."%(pronoun, self.Name, self.Age))
Person1=Person()
Person1.Name="Joh... |
4f2f5eb803fee7c8ba6e73a1a142864f6ae91660 | dmnjzl/jupyter | /class-and-object/maxHeap.py | 2,471 | 3.921875 | 4 | #MaxHeap class from Lab 3
class MaxHeap(object):
def __init__(self,data=[]):
# constructor - empty array
self.data = data
def isEmpty(self):
# return true if maxheaph has zero elements
return(len(self.data)==0)
def getSize(self):
# return number of elements in maxhe... |
8d048eb12a10e55edafe9d0e56ac4c4313eb0137 | srawlani22/LSystems-Genetic-Algorithms-with-Python3 | /Intro-to-L-Systems/recursionexamples/tutorial.py | 1,104 | 3.984375 | 4 | import turtle
import time
import math
#from turtleLS import randint
draw = turtle.Turtle()
# # drawing a square
# draw.forward(100)
# draw.right(90)
# draw.forward(100)
# draw.right(90)
# draw.forward(100)
# draw.right(90)
# draw.forward(100)
# # time.sleep(3)
# # draw.reset()
# draw.penup()
# draw.forward(100)
# ... |
20821b277bb38285010d11b0bace9a4da4d539b5 | shreo-adh/Python | /PDF_rotator.py | 485 | 3.890625 | 4 | import PyPDF2
file_path = input("Input file path: ")
rotate = 0
with open(file_path, mode='rb') as my_file:
reader = PyPDF2.PdfFileReader(my_file)
page = reader.getPage(0)
rotate = int(input("Enter the degree of rotation(Clockwise): "))
page.rotateClockwise(rotate)
writer = PyPDF2.PdfFileWriter()... |
c03f949e619ad6bdec690bd942043a3bfca7d816 | acstibi02/4.ora | /hf4_4.py | 403 | 3.625 | 4 | bekert_szöveg = input("Írjon be egy szöveget: ")
i = 0
j = 1
lista=[]
a = 'False'
while i < (len(bekert_szöveg)//2):
if bekert_szöveg[i] == bekert_szöveg[len(bekert_szöveg)-j]:
lista.append('True')
i+=1
j+=1
else:
lista.append('False')
i+=1
j+=1
if a in lista:
... |
c0a4b3de94544033bfa95b7a208f58f2b5c0eedc | NBALAJI95/Python-programming | /inClass/Class - 2/inClass-charac-freq.py | 471 | 3.984375 | 4 | def findCharFreq(s, c):
if c not in s:
return 'Letter not in string'
else:
count = s.count(c)
return count
def main():
inp_str = input('Enter the string:')
distinct_letters = []
for i in inp_str:
if i not in distinct_letters:
distinct_letters.append(i)
... |
8a869f9cc02943a51c4d0ce03dafe50c15740dc3 | NBALAJI95/Python-programming | /inClass/Class - 4/inClass.py | 729 | 3.703125 | 4 | import requests
from bs4 import BeautifulSoup
import os
def main():
url = "https://en.wikipedia.org/wiki/Android_(operating_system)"
source_code = requests.get(url)
plain_text = source_code.text
# Parsing the html file
soup = BeautifulSoup(plain_text, "html.parser")
# Finding all div tags
r... |
10becb5b4a704625c66e56c5a66b975ab3c1628e | NBALAJI95/Python-programming | /inClass/Class - 3/inClass-1.py | 905 | 3.859375 | 4 |
def print_horiz_line():
return '---'
def print_vert_line():
return '|'
def main():
inp = input('Enter dimensions of the board separated by "x":')
inp = inp.split('x')
inp = list(map(lambda a: int(a), inp))
print(inp)
op =''
t = 0
case = ''
it = 0
if (inp[0] + inp[1]) % 2 ... |
fb213cb12399aa1b08a15d4040ef3ce15457e9e9 | NBALAJI95/Python-programming | /Assignments/Week - 3/Task-3.py | 1,624 | 3.953125 | 4 | # Getting input co-ordinates from the user
def getCoordinates(turn, tt):
player = ''
while True:
if turn % 2 == 0:
inp = input("Player 1, enter your move in r,c format:")
player = 'X'
else:
inp = input("Player 2, enter your move in r,c format:")
pl... |
9154ab03fa537db195606670fe318a1240ca20ba | djd1283/UndiagnosedDiseaseClassifier | /get_random_submissions.py | 2,058 | 3.5 | 4 | """Get random submissions from Reddit as negative examples for classifier."""
import os
import csv
import praw
from filter_reddit_data import load_credentials
from tqdm import tqdm
data_dir = 'data/'
negative_submissions_file = 'negative_submissions.tsv'
accepted_submissions_file = 'accepted_submissions.tsv'
def ge... |
775bc457736c4a7dd6c98a389e63432c814cd1a4 | custu2000/curs_python | /lab1/lab1.py | 843 | 3.8125 | 4 | #ex 1
for i in range(100):
print ("hello world")
# ex 2
s="hello world"*100
print (s)
#ex 3
#fizz %3, buzz %5, fizz buzz cu 3 si 5
#rest numarul
for i in range(100):
if i % 3 ==0 and i % 5 ==0:
print "fizz buzz for: ",i
if i % 3 ==0 :
print "fizz for: ",i
if i % 5 ==0 :
pr... |
3da597b2bcdcdaf16bfa50bc86a060fa56173667 | ND13/zelle_python | /chapter_2/futval.py | 792 | 4.15625 | 4 | #!/usr/bin/python3.6
# File: futval.py
# A program that computes an investment carried 10 years into future
# 2.8 Exercises: 5, 9
def main():
print("This program calculates the future value of a 10-year investment.")
principal = float(input("Enter the principal amount: "))
apr = float(input("Enter the ann... |
7482b65b788259f74c8719944618f9d856417780 | ND13/zelle_python | /chapter_3/pizza.py | 450 | 4.3125 | 4 | # sphere_2.py
# calculates the price per square inch of circular pizza using price and diameter
def main():
price = float(input("Enter the price for your pizza: $"))
diameter = float(input("Enter the diameter of the pizza: "))
radius = diameter / 2
area = 3.14159 * radius ** 2
price_per_sq_inch = ... |
bd85de544ae4984bddacf4f091f186fec0b8e3f4 | AmarJ/ieeeCodingChallenge | /2018-Fall/solutions/Q1.py | 484 | 3.671875 | 4 | def rot_1(A, d):
output_list = []
# Will add values from n to the new list
for item in range(len(A) - d, len(A)):
output_list.append(A[item])
# Will add the values before
# n to the end of new list
for item in range(0, len(A) - d):
output_list.append(A[... |
4e58aa912b1e41bf3fb42cfc8917909137174ea6 | jsy2906/Portfolio | /프로그래머스/실력 테스트/Q2.py | 198 | 3.53125 | 4 | # Q2) 입력된 숫자만큼 문자 밀기
def solution(s, n):
string = ''
for i in s:
result = ord(i) + n
string += chr(result)
return string
solution('eFg', 10)
|
f1a0cde50de74b36ff22705364f41fb62a26f56a | jsy2906/Portfolio | /파이썬/동명이인 찾기.py | 193 | 3.53125 | 4 | def find_same_name(a):
n = len(a)
result = set()
for i in range(n-1):
for j in range(i+1,n):
if a[i] == a[j]:
result.add(a[i])
return result
|
1e284588df9d0a43fde6af4e7358c1d1691c82c7 | nikdavis/poker_hand | /poker_hand/parsers/card_parser.py | 559 | 3.6875 | 4 | class CardParser(object):
RANK = {
"2": 2,
"3": 3,
"4": 4,
"5": 5,
"6": 6,
"7": 7,
"8": 8,
"9": 9,
"T": 10,
"J": 11,
"Q": 12,
"K": 13,
"A": 14
}
SUIT = {
"H": "heart",
"D": "diamond",
"C": "club",
"S": "spade"
}
def __init__(self, card_str)... |
6cf792b36892e4c8372d95eb9857034bf939e378 | leogao/examples | /hackerrank/isFib.py | 763 | 3.734375 | 4 | #!/usr/bin/env python
# https://www.hackerrank.com/challenges/is-fibo
import sys
T = int(raw_input())
assert 1<=T<=10**5
def fib(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fib(n-1) + fib(n-2)
X = 10
fibs = []
for i in xrange(X):
fibs.append(fib(i))
for i in xr... |
415ceea1e04a46bbab094f7abe18de80e487e0b5 | heartthrob227/kenstoolbox | /convfilecheckerV0.1.py | 2,049 | 3.5625 | 4 | import csv, re, pandas
from collections import defualtdict
print('=================================')
print('Welcome to the Conversion File Checker')
#Ask for file to parse
rawfile = input('What file do you want to test (without extension; must be csv)? ')
firstfile = rawfile + '.csv'
#Open file
fout=open(out... |
d95ad94be6d99173fbab10e23b772a94d8ed0cd8 | mclearning2/Algorithm_Practice | /math/204_Count_Primes.py | 508 | 3.953125 | 4 | '''
Count the number of prime numbers less than a non-negative number, n.
Example:
Input: 10
Output: 4
Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.
'''
class Solution:
def countPrimes(self, n: int) -> int:
answer = 0
memory = list(range(n))
memory[:2] = None, ... |
61b71063cf7828bbb2806a7992b43da37d41a9a2 | Cathelion/Numerical-Approximation-Course | /Assignment4_Remez_algo.py | 3,736 | 3.75 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 3 20:16:53 2021
@author: florian
A short demonstration of the Remez algorithm to obtain the best
approximation of a function in the supremum norm on a compact interval.
The test function used is f(x) = x*sin(x) and we use 7 points
We also plot t... |
5a8aef01cc4e4dd1ec33a423b4b7fe01134371be | kcarson097/Beginner-Projects | /Text-editor.py | 560 | 4.03125 | 4 | def read_text_file(file):
#file name is entered as 'file.txt'
with open(file) as f:
contents = f.read()
return contents
def edit_text_file(file, new_text):
#this function will overwrite the current txt file
with open(file, mode = 'w') as f:
#opens file as read and write o... |
c41a32b3bc188f45b33e89d1d4f9f8ada85abe84 | RikaIljina/PythonLearning | /word_count_script/count_words.py | 4,264 | 4.0625 | 4 | import os
import sys
from pathlib import Path
# Add your file name here
file_path = r"counttext.txt"
result_path = r"result.csv"
# Remember names of source and target files
f_name = Path(file_path)
r_name = Path(result_path)
print("#" * 86)
print(f"This script will read the file {f_name} that must be placed in the s... |
99add258003c36dcd2023264fd4af8c2e7045333 | RikaIljina/PythonLearning | /cypher_1/cypher_template.py | 6,030 | 4.5 | 4 | ##############################################
# This code is a template for encoding and
# decoding a string using a custom key that is
# layered on top of the string with ord() and
# chr(). The key can be any sequence of symbols,
# e.g. "This is my $uper-$ecret k3y!!"
# Optimally, this code would ask users to
# choos... |
f75081ff4aa02c2d226247c160a69e941149c980 | zhaokaiju/fluent_python | /c07_closure_deco/p05_closure.py | 728 | 4.34375 | 4 | """
闭包:
闭包指延伸了作用域的函数,其中包含函数定义体中引用、但是不在定义体中定义的非全局变量。
函数是不是匿名的没关系,关键是它能访问定义体之外定义的非全局变量。
"""
def make_averager():
"""
闭包
"""
# 局部变量(非全局变量)(自由变量)
series = []
def averager(new_value):
series.append(new_value)
total = sum(series)
return total / len(series)
retu... |
77d5735d02e893939063d955f7e32ca4b64a1f48 | kescott027/PythonHacker | /ransomnote.py | 1,365 | 3.578125 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
def checkMagazine(magazine, note):
d = {}
result = 'Yes'
for word in magazine:
d.setdefault(word, 0)
d[word] +=1
for word in note:
if word in d and d[word] -1 >= 0:
d[word] -=1
else:
... |
feb5d900ebb46fd80cfa86d8346b12c17e94ce0b | kescott027/PythonHacker | /maxmin.py | 2,527 | 4 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the maxMin function below.
def maxMin(k, arr):
"""
given a list of integers arr, and a single integer k, create an array of length k from elements arr such
as its unfairness is minimized. Call that array subarr. unfairnes... |
162e451ee6116712ba11c38246234fd1ea324138 | suhyeok24/Programmers-For-Coding-Test | /Programmers Lv.1/lv1. 최소직사각형.py | 1,037 | 3.5 | 4 | # 내 풀이
import numpy as np
def solution(sizes):
sizes=np.array(sizes).T.tolist()
print(sizes) #[[가로],[세로]]
width=sizes[0]
height=sizes[1]
big=max(max(width),max(height))
#가장 big을 찾는다. > 나머지 가로(세로)를 최소화시켜야 함.
# index끼리 대소비교해서 smaller를 나머지 선분으로 몰빵
if big in width:
... |
ce89c9d119563e15bdf426ae3d6d18800802ffe0 | suhyeok24/Programmers-For-Coding-Test | /Programmers Lv.1/프로그래머스 lv1. 나누어 떨어지는 숫자 배열.py | 858 | 3.53125 | 4 | # 가장 흔한 for문
def solution(arr, divisor):
answer = []
for n in arr:
if n % divisor == 0:
answer.append(n)
if not answer:
return [-1]
else:
return sorted(answer)
# lIST COMPRHENSION 이용
def solution(arr, divisor):
return sorted([ num for num in arr ... |
3895cae859876b54b659f2b8a8b4edec12fddee3 | corneliag08/Rezolvarea-problemelor-IF-WHILE-FOR | /problema 9.py | 250 | 3.6875 | 4 | n=int(input("Dati un numar: "))
suma=0
if(n!=0) and (n!=1):
for i in range (1,n):
if n%i==0:
suma+=i
if suma==n:
print("Numarul", n,"este perfect.")
else:
print("Numarul", n,"nu este perfect.") |
eb8542490893d3b99e9a8cfd416e0f363182de13 | codeking-hub/Coding-Problems | /AlgoExpert/balanceBrackets.py | 585 | 3.90625 | 4 | def balancedBrackets(string):
# Write your code here.
stack = []
opening_brackets = "([{"
closing_brackets = "}])"
matching_brackets = {
")": "(",
"}": "{",
"]": "["
}
for char in string:
peek = len(stack)-1
if char in opening_brackets:
sta... |
8401b89e555a10d530a528355193b0207ac6be6c | codeking-hub/Coding-Problems | /AlgoExpert/moveElementToEnd/spacealsoopt.py | 321 | 3.578125 | 4 | def moveElementToEnd(array, toMove):
# Write your code here.
left = 0
right = len(array)-1
while left < right:
while left < right and array[right] == toMove:
right -= 1
if array[left] == toMove:
array[left], array[right] = array[right], array[left]
left += 1
return array
# time O(n)
# space O(n)... |
171042e8da302efa359e350feaf92915e9d33b8b | codeking-hub/Coding-Problems | /AlgoExpert/find3LargestNums.py | 711 | 4.125 | 4 | def findThreeLargestNumbers(array):
# Write your code here.
three_largest = [None, None, None]
for num in array:
updateThreeLargest(num, three_largest)
return three_largest
def updateThreeLargest(num, three_largest):
if three_largest[2] == None or num > three_largest[2]:
shiftValu... |
e328b1b43b04ea504d88dc37e936a0c3925cea60 | codeking-hub/Coding-Problems | /AlgoExpert/2Sum/s2.py | 257 | 3.875 | 4 | def twoNumberSum(array, targetSum):
# Write your code here.
nums = {}
for num in array:
complement = targetSum-num
if complement in nums:
return [complement, num]
else:
nums[num] = True
return []
# time complexity O(n)
|
e2519f0ca1c42f5cb04287a8d63bd563e136a2de | codeking-hub/Coding-Problems | /AlgoExpert/branchSums.py | 601 | 3.703125 | 4 | # This is the class of the input root. Do not edit it.
class BinaryTree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def branchSums(root):
# Write your code here.
sums = []
findbranchSums(root, 0, sums)
return sums
def findbranchSums(node,... |
49e336496e2452c7c33621dbd888c78ba43405b0 | codeking-hub/Coding-Problems | /AlgoExpert/binarySearch/recersive.py | 476 | 3.875 | 4 | def binarySearch(array, target):
# Write your code here.
return binarySearchHelper(array, target, 0, len(array)-1)
def binarySearchHelper(array, target, low, high):
if low > high:
return -1
mid = (low+high)//2
match = array[mid]
if match == target:
return mid
elif target <... |
3ddab9cd05622d64529fb633064ee8cfa0db0492 | luciano588/d30-family-api | /src/datastructures.py | 2,768 | 4.0625 | 4 |
"""
update this file to implement the following already declared methods:
- add_member: Should add a member to the self._members list
- delete_member: Should delete a member from the self._members list
- update_member: Should update a member from the self._members list
- get_member: Should return a member from the sel... |
77d7c4b29aad0ad0d7d7ab04b1f7d3231bf2d0b7 | Symas1/metaprogramming_lab1 | /meta_method.py | 1,468 | 3.703125 | 4 | import utils
class MetaMethod:
def __init__(self):
self.name = utils.input_identifier('Enter method\'s name: ')
self.arguments = []
self.add_arguments()
def add_arguments(self):
if utils.is_continue('arguments'):
while True:
name = utils.input_agru... |
48458c3ba2011e0c23112d26a5b65d7d0822c5bf | RECKLESS6321/Libaries | /BFS(queue).py | 483 | 4 | 4 | def bfs(graph, start_vertex, target_value):
path = [start_vertex]
vertex_and_path = [start_vertex, path]
bfs_queue = [vertex_and_path]
visited = set()
while bfs_queue:
current_vertex, path = bfs_queue.pop(0)
visited.add(current_vertex)
for neighbor in graph[current_vertex]:
if neighb... |
8e7e80d3e42f32e4cb414d8e90e3c4ae079d8038 | RahulNewbie/Job_REST_API | /job_insertion.py | 984 | 3.84375 | 4 | import csv
import sqlite3
import os
import constants
def job_insertion():
"""
Read the CSV file and insert records in Database
"""
con = sqlite3.connect(constants.DB_FILE)
cur = con.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS job_data_table (Id,Title,Description,Company,"
... |
6c0dc7a54d1e00bd5cb02b06bf6fa804cd665de9 | kadhirash/leetcode | /problems/happy_number/solution.py | 593 | 3.546875 | 4 | class Solution:
def isHappy(self, n: int) -> bool:
#happy =
# positive integer --- (n > 0)
# replace num by sum of square of its digits --- replace n by sum(square of digits)
# repeat until == 1
# if 1 then happy, else false
hash_set = set()
total... |
4d138ec4e0f4349b3eeb9842acc10f2a0c1ca748 | kadhirash/leetcode | /problems/minesweeper/solution.py | 1,131 | 3.6875 | 4 | class Solution:
def updateBoard(self, board: List[List[str]], click: List[int]) -> List[List[str]]:
x, y = click
surround = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, -1), (1, 1), (-1, 1), (-1, -1)]
def available(x, y):
return 0 <= x < len(board) and 0 <= y < len(board[0])
... |
374eb12b1ec6126e692a94315444e4a7bcf0621b | kadhirash/leetcode | /problems/search_suggestions_system/solution.py | 1,011 | 3.671875 | 4 | class Solution:
def suggestedProducts(self, products: List[str], searchWord: str) -> List[List[str]]:
products.sort() # time O(nlogn)
array_len = len(products)
ans = []
input_char = ""
for chr in searchWord:
tmp = []
input_char += chr
inse... |
5b27c86e6e8a8286719120abc005c3766632d7f0 | ElenaPontecchiani/Python_Projects | /0-hello/16-for.py | 306 | 4.09375 | 4 | for letter in "lol":
print(letter)
friends = ["Kim", "Tom", "Kris"]
for friend in friends:
print(friend)
#altro modo per fare la stessa cosa con range
for index in range(len(friends)):
print(friends[index])
for index in range(10):
print(index)
for index in range(3,10):
print(index) |
8467f46df1d0750c60bdd4c67ece16ef34707c48 | ElenaPontecchiani/Python_Projects | /0-hello/35-sortedAdvanced.py | 531 | 3.53125 | 4 | #format=(nome, raggio, denisità, distanza dal sole)
planets =[
("Mercury", 2440, 5.43, 0.395),
("Venus", 6052, 5.24, 0.723),
("Earth", 6378, 5.52, 1.000),
("Mars", 3396, 3.93, 1.530),
("Jupiter", 71492, 1.33, 5.210),
("Saturn", 60268, 0.69, 9.551),
("Uranus", 25559, 1.27, 19.213),
("Nept... |
a9bbd74af9b343cf940c2a7eeb6de12dbcc4bdd9 | ElenaPontecchiani/Python_Projects | /0-hello/12-calculatorV2.py | 466 | 4.1875 | 4 | n1 = float(input("First number: "))
n2 = float(input("Second number: "))
operator = input("Digit the operator: ")
def calculatorV2 (n1, n2, operator):
if operator == '+':
return n1+n2
elif operator == '-':
return n1-n2
elif operator == '*':
return n1*n2
elif operator == '/':
... |
e5d0c701272a91bb56882ffb433ead594311d5b5 | ElenaPontecchiani/Python_Projects | /0-hello/2-variable.py | 555 | 3.953125 | 4 | character_name= "Jhon"
character_age= 50.333
is_male= False
#cincionamenti con le variabili
print("His name is " +character_name)
print (character_name)
print (character_name.upper().islower())
print(len(character_name))
print(character_name[0])
print(character_name.index("J"))
print(character_name.index("ho"))
phrase... |
0eeeef457fd8543b7ba80d2645b0bac3624dffc3 | fanjiamin1/cryptocurrencies | /scratchpad/exponentiation.py | 564 | 3.703125 | 4 |
def modularpoweroftwo(number,poweroftwo,module):
#returns number**(2**poweroftwo) % module
value=number%module
currexponent=0
while currexponent<poweroftwo:
value=(value*value)%module
currexponent+=1
return value
def fastmodularexponentiation(number,exponent,modu... |
c9a49ce478ccbe1df25e3b5c0ee18932ae222f86 | mateuszkanabrocki/LMPTHW | /ex11/project/tail.py | 804 | 3.734375 | 4 | #! /usr/bin/env python3
from sys import argv, exit, stdin
# history | ./tail -25
def arguments(argv):
try:
lines_num = int(argv[1].strip('-'))
return lines_num
except IndexError:
print('Number of lines not gien.')
exit(1)
def main():
count = arguments(argv)
if len(ar... |
def2e855860ded62733aa2ddcfe4b51029a8edd2 | PSReyat/Python-Practice | /car_game.py | 784 | 4.125 | 4 | print("Available commands:\n1) help\n2) start\n3) stop\n4) quit\n")
command = input(">").lower()
started = False
while command != "quit":
if command == "help":
print("start - to start the car\nstop - to stop the car\nquit - to exit the program\n")
elif command == "start":
if started:
... |
f6b50fb2c608e9990ed1e3870fd73e2039e17b3d | ananyo141/Python3 | /uptoHundred.py | 301 | 4.3125 | 4 | #WAP to print any given no(less than 100) to 100
def uptoHundred(num):
'''(num)-->NoneType
Print from the given number upto 100. The given num should be less than equal to 100.
>>>uptoHundred(99)
>>>uptoHundred(1)
'''
while(num<=100):
print(num)
num+=1 |
004253ee0f2505f145d011e35d28ed4e9f96f36b | ananyo141/Python3 | /Automate The Boring Stuff/sandwichMaker.py | 1,484 | 4.09375 | 4 | # Make a sandwich maker and display the cost.
from ModuleImporter import module_importer
pyip = module_importer('pyinputplus', 'pyinputplus')
orderPrice = 0
print("Welcome to Python Sandwich!".center(100,'*'))
print("We'll take your order soon.\n")
breadType = pyip.inputMenu(['wheat','white','sourdough'],prompt="How... |
437c321c8a52c3ae13db3bfa5e48c7a5dac2c1eb | ananyo141/Python3 | /gradeDistribution/functions.py | 2,519 | 4.15625 | 4 | # This function reads an opened file and returns a list of grades(float).
def findGrades(grades_file):
'''(file opened for reading)-->list of float
Return a list of grades from the grades_file according to the format.
'''
# Skip over the header.
lines=grades_file.readline()
grades_list=[]... |
65c9becebedca46aed5c13c04aa0bff47460d23b | ananyo141/Python3 | /Automate The Boring Stuff/clipboardNumbering.py | 1,238 | 4 | 4 | #!python3
# WAP that takes the text in the clipboard and adds a '*' and space before each line and copies to the
# clipboard for further usage.
import sys
from ModuleImporter import module_importer
pyperclip = module_importer('pyperclip', 'pyperclip')
def textNumbering(text, mode):
'''(str,str)-->str
Returns... |
0cc53ef8c755669e55176ebad4cd5b0c0d758eef | ananyo141/Python3 | /Automate The Boring Stuff/passwordStrengthNOREGEX.py | 3,765 | 4.03125 | 4 | # Give the user option to find the passwords in the given text, or enter one manually.
# Check the password and give rating as weak, medium, strong, unbreakable and include tips to improve it.
import re, time, sys
from ModuleImporter import module_importer
pyperclip = module_importer('pyperclip', 'pyperclip')
def pass... |
67613b888eaa088a69a0fec26f1ace376f95cbbb | ananyo141/Python3 | /calListAvg.py | 624 | 4.15625 | 4 | # WAP to return a list of averages of values in each of inner list of grades.
# Subproblem: Find the average of a list of values
def calListAvg(grades):
'''(list of list of num)--list of num
Return the list of average of numbers from the list of lists of numbers in grades.
>>> calListAvg([[5,2,4,3],[... |
aba312740d42e2f175d79984bc2d3ec8042b891b | ananyo141/Python3 | /area_of_triangle.py | 184 | 4.1875 | 4 | def area(base, height):
''' (num,num)--> float
Return the area of a triangle of given base and height.
>>>area(8,12)
48.0
>>>area(9,6)
27.0
'''
return (base*height)/2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.