blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
b7229311ac79d2bc3ee7d580f8b63b05306a2c61 | Aayush2424/Python-Projects | /Calculator.py | 781 | 4 | 4 | print("Welcome to the Calculator")
print("1.Addition\n", "2.Subtraction\n", "3.Multiplication\n", "4.Division\n")
a = int(input("Choose the operation: "))
if a == 1:
n1 = int(input("Enter the first no.: "))
n2 = int(input("Enter the second no.: "))
sum = n1 + n2
print("Result: ", sum)
elif a... |
ef7221fffee777d40e5a5a8f4a5c8283874681b4 | xoroxchalise/python-hangman | /main.py | 1,111 | 4.09375 | 4 | import random
from words import words
import string
def valid_words(words):
word = random.choice(words)
while '-' in word or ' ' in word:
word = random.choice(words)
return word.upper()
def hangman():
word = valid_words(words)
word_letters = set(word)
alphabet = set(... |
bde4037813350ce40c954d6c4b34b67cfa619976 | Keshav1506/competitive_programming | /Dynamic_Programming/020_geeksforgeeks_Optimal_Strategy_For_A_Game/Solution.py | 5,735 | 3.609375 | 4 | #
# Time :
# Space :
#
# @tag : Dynamic Programming
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# Geeks For Geeks : Optimal Strategy For A Game
#
# Description:
#
# You are given an array A of size N. The array contains integers and is of... |
b89e16585be9d5a208e0711271a22f5d6e201515 | Keshav1506/competitive_programming | /Stack_and_Queue/002_geeksforgeeks_Next_Larger_Element/Solution.py | 2,458 | 3.765625 | 4 | #
# Time : O(N); Space: O(1)
# @tag : Stack and Queue
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# Description:
#
# Given an array A of size N having distinct elements, the task is to find the next greater element for each element of the ... |
4b2eb7f54b2898ce241dddfc0cc7966971ac4589 | Keshav1506/competitive_programming | /Hashing/006_geeksforgeeks_Swapping_Pairs_Make_Sum_Equal/Solution.py | 3,297 | 4.03125 | 4 | #
# Time : O(N^3); Space: O(N)
# @tag : Hashing
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# GeeksForGeeks - Swapping pairs make sum equal
#
# Description:
#
# Given two arrays of integers A[] and B[] of size N and M, the task is to check... |
9cdde6db7f932ea5315516f7cbb82afbb800330b | Keshav1506/competitive_programming | /Tree_and_BST/017_leetcode_P_250_CountUnivalueSubtrees/Solution.py | 2,872 | 3.6875 | 4 | #
# Time : O(N) [ N = Number of nodes in the Binary Tree ] ; Space: O(1)
# @tag : Tree and BST ; Recursion ; Divide and Conquer
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
#
# LeetCode - Problem - 250: Longest Univalue Path
#
# Description... |
2b815979e2e71cd6f711daff474e15968de9951a | Keshav1506/competitive_programming | /Arrays/012_geeksforgeeks_Minimum_Platforms/Solution.py | 5,085 | 3.71875 | 4 | #
# Time : O(NlogN); Space: O(1)
# @tag : Arrays
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
#
# Given arrival and departure times of all trains that reach a railway station.
# Your task is to find the minimum number of platforms required ... |
aa2e42c78db54ca867c25ce2113b7914bcc666ee | Keshav1506/competitive_programming | /Bit_Magic/004_geeksforgeeks_Toggle_Bits_Given_Range/Solution.py | 2,703 | 4.15625 | 4 | #
# Time :
# Space :
#
# @tag : Bit Magic
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# GeeksForGeeks: Toggle bits given range
#
# Description:
#
# Given a non-negative number N and two values L and R.
# The problem is to toggle the bits ... |
3a9517c16fbd0277f41ee23fe2a317d21db22820 | Keshav1506/competitive_programming | /Dynamic_Programming/026_leetcode_P_312_BurstBalloons_AKA_MatrixChainMultiplication/Solution.py | 5,862 | 3.5625 | 4 | #
# Time :
# Space :
#
# @tag : Dynamic Programming
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# LeetCode - Problem 312: Burst Balloons
#
# Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented ... |
df176eb522150a951e366339738246cbeff0351a | Keshav1506/competitive_programming | /Graph/033_leetcode_P_953_VerifyingAlienDictionary/Solution.py | 3,805 | 3.796875 | 4 | #
# Time : O(NS)
# Space : O(1)
# @tag : Graph
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# LeetCode - Problem 953: Verifying an Alien Dictionary
#
# Description:
#
# In an alien language, surprisingly they also use english lowercase let... |
20c79bd9cea2a5cfaa52d8534b54a86d8c78a309 | Keshav1506/competitive_programming | /Heap/003_geeksforgeeks_Binary_Heap_Operations/Solution.py | 5,313 | 3.84375 | 4 | #
# Time : O(Q*Log(size of Heap)); Space: O(1)
# @tag : Heap
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# GeeksForGeeks - Binary Heap Operations
#
# Description:
#
# A binary heap is a Binary Tree with the following properties:
# 1) It’s ... |
77e156448f444e3cfa24f526287a71cd1ed731f5 | Keshav1506/competitive_programming | /Graph/032_geeksforgeeks_Alien_Dictionary/Solution.py | 3,971 | 3.796875 | 4 | #
# Time : O(N + K)
# Space : O(K)
# @tag : Graph ; DFS
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# GeeksForGeeks - Alien Dictionary
#
# Description:
#
# Given a sorted dictionary of an alien language having N words and k starting alpha... |
6d6afc2704e60ffac15b51d3f5dd532674fa0c03 | Keshav1506/competitive_programming | /Greedy/005_geeksforgeeks_Coin_Piles/Solution.py | 4,100 | 3.5 | 4 | #
# Time :
# Space :
#
# @tag : Greedy
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# GeeksForGeeks - Coin Piles
#
# Description:
#
# There are N piles of coins each containing Ai (1<=i<=N) coins. Now, you have to adjust the number of co... |
f6d9475610c329f7053bb1b6ddc05fc930eb31c6 | Keshav1506/competitive_programming | /Backtracking/002_leetcode_P_052_N-Queens-II/Solution.py | 1,597 | 3.625 | 4 | #
# Time :
# Space :
#
# @tag : Backtracking
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# LeetCode - Problem 52: N-Queens II
#
# Description:
#
# Refer to LeetCode_Problem_Description.md
#
# **********************************************... |
8b5f51e61e3f007a01846092cccd9c35bad0fc42 | Keshav1506/competitive_programming | /Graph/016_geeksforgeeks_Strongly_Connected_Components_Kosaraju_Algorithm/Solution.py | 5,404 | 3.734375 | 4 | #
# Time : O(V+E); Space: O(E)
# where, V = number of vertices
# E = number of edges
# @tag : Graph ; Kosaraju's Algorithm
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# GeeksForGeeks: Strongly Connected Components (Kosaraju's Algo)
... |
60a897047725a40918526acfefc6620d165dff80 | Keshav1506/competitive_programming | /Hashing/013_amazon_OA_2019_FindPairWithGivenSum/Solution.py | 2,109 | 3.703125 | 4 | # Amazon | OA 2019 | Interview Question | Find Pair With Given Sum
#
# Time : O(N); Space: O(N)
# @tag : Graph
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
#
#
# Given a list of positive integers nums and an int target, return indices of t... |
31f5a45e28ccb77adff1f5f3761e9297a121f0cd | Keshav1506/competitive_programming | /Tree_and_BST/021_leetcode_P_366_FindLeavesOfBinaryTree/Solution.py | 2,439 | 4.25 | 4 | #
# Time : O(N) [ We traverse all elements of the tree once so total time complexity is O(n) ] ; Space: O(1)
# @tag : Tree and BST ; Recursion
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
#
# LeetCode - Problem - 366: Find Leaves of Binary ... |
b24a906a52604be764d20ca18b47ea6e5d1d98fd | Keshav1506/competitive_programming | /Linked_List/001_leetcode_P_876_MiddleOfTheLinkedList/Solution.py | 5,335 | 3.625 | 4 | #
# Time : O(N); Space: O(1)
# @tag : Linked List
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# LeetCode - Problem - 876: Middle of the Linked List
#
# Description:
#
# Given a non-empty, singly linked list with head node head, return a mi... |
2aa05e61e802095c803983275634abd91e756bc6 | Keshav1506/competitive_programming | /Divide_and_Conquer/004_geeksforgeeks_Sum_Of_Middle_Elements_Of_Two_Sorted_Arrays/Solution.py | 2,368 | 3.5625 | 4 | #
# Time :
# Space :
#
# @tag : Divide And Conquer
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# GeeksForGeeks: Sum of Middle Elements of two sorted arrays
#
# Description:
#
# Given 2 sorted arrays A and B of size N each. Print sum of mi... |
8b836abab0a4c3bb8932b83c9e0ed8217056fb15 | Keshav1506/competitive_programming | /Arrays/005_leetcode_P_088_MergeSortedArray/Solution.py | 2,520 | 3.953125 | 4 | #
# Time : O(N); Space: O(1)
# @tag : Arrays
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# 88. Merge Sorted Array
#
# Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
#
# Note:
#
# The number of ... |
b4884d86b3317d4183ee4a72cd147d6fbf371f6e | Keshav1506/competitive_programming | /Dynamic_Programming/014_leetcode_P_354_RussianDollEnvelopes/Solution.py | 6,301 | 3.625 | 4 | #
# Time :
# Space :
#
# @tag : Dynamic Programming
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# LeetCode - Problem 354: Russian Doll Envelopes
#
# Description:
#
# You have a number of envelopes with widths and heights given as a pair o... |
3a422f5d0800cdf022df5aebdc57b4d83653a301 | Keshav1506/competitive_programming | /Linked_List/008_leetcode_P_142_Variant_DetectLoopAndRemoveLoop_In_LinkedList/Solution.py | 10,852 | 3.609375 | 4 | #
# Time : O(N) ; Only one traversal of the loop is needed.
# Space: O(1) ; There is no space required.
# @tag : Linked List, Floyd's Cycle Detection Algorithm
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# LeetCode - Problem 142: Linke... |
bf094efcc9f720263b5407e297124dc1e8caf1b6 | Keshav1506/competitive_programming | /Dynamic_Programming/011_leetcode_P_072_EditDistance/Solution.py | 8,674 | 3.5 | 4 | #
# Time :
# Space :
#
# @tag : Dynamic Programming
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# LeetCode - Problem 72: Edit Distance
#
# Description:
#
# Given two words word1 and word2, find the minimum number of operations required to... |
d79b8ee45d1083f13d2070b4ac7c2cb759b14dab | Keshav1506/competitive_programming | /Arrays/015_leetcode_P_215_Kth_LargestElementInAnArray/Solution.py | 5,664 | 3.875 | 4 | #
# Time : O(N); Space: O(1)
# @tag : Arrays
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# Kth smallest element
# **************************************************************************
# Find the kth largest element in an unsorted arra... |
814ddd96d4a6dabdb3f5e173c316291425c3d889 | Keshav1506/competitive_programming | /Arrays/022_geeksforgeeks_Last_Index_Of_1/Solution.py | 1,825 | 3.546875 | 4 | #
# Time : O(N); Space: O(1)
# @tag : Arrays
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# Last index of One
#
# Given a string S consisting only '0's and '1's, print the last index of the '1' present in it.
#
# Example 1:
#
# Input: "000... |
b0f168408474d2a3e002d33a96ca175bbab6114e | Keshav1506/competitive_programming | /Arrays/030_geeksforgeeks_Nuts_and_Bolts_Problem/Solution.py | 8,172 | 3.65625 | 4 | #
# Time : O(N); Space: O(1)
# @tag : Arrays, Two Pointer
# @by : Shaikat Majumdar
# @date: Aug 27, 2020
# **************************************************************************
# GeeksForGeeks - Nuts and Bolts Problem
#
# Given a set of N nuts of different sizes and N bolts of different sizes. There is a one-one ... |
cd17da90463d57a284058b78e278addb834373b9 | hakepg/operations | /String/sort_characters_num_of_string.py | 486 | 3.53125 | 4 | # inp = 'prat12ima3'
# output = ''
# num = ''
#
# for item in inp:
# if item.isalpha():
# output+= item
# else:
# num += item
# opt = ''.join(sorted(num) + sorted(output))
# print(opt)
# s1 ='AghPgh123'
# alphabet = []
# digits = []
#
# for item in s1:
# if item.isalpha():
# alphabe... |
0fff29228279abcae6d9fa67f111602e0423db66 | hakepg/operations | /python_sample-master/python_sample-master/basics/deepcloning.py | 757 | 4.15625 | 4 | import copy
listOfElements = ["A", "B", 10, 20, [100, 200, 300]]
# newList= listOfElements.copy() -- list method- performs shallow copy
newList = copy.deepcopy(listOfElements) # Deep copy -- method provided by copy module
newList1 = copy.copy(listOfElements) # Shallow copy -- method provided by copy module
pr... |
10841b4db43d984e677eec6a8dcd00415bc8c098 | hakepg/operations | /python_sample-master/python_sample-master/basics/listExample.py | 525 | 4.15625 | 4 | # Sort in the list
# Two ways: list method -- sort and built in function -- sorted
listOfElements = [10,20,30,45,1,5,23,223,44552,34,53,2]
# Difference between sort and sorted
print(sorted(listOfElements)) # Creates new sorted list
print(listOfElements) # original list remains same
print(listOfElements.... |
9ea24a4b0c0cfb5b7f38d6fe2b92fcc05d56ee60 | s21611-pj/asd | /zadanie_dodatkowe.py | 1,027 | 3.96875 | 4 | # FIRST METHOD O(n^2)
def sort_max(array):
size = len(array)
for i in range(size - 1, -1, -1):
biggestIdx = 0
for j in range(0, i + 1, 1):
if array[j] > array[biggestIdx]:
biggestIdx = j
temp = array[i]
array[i] = array[biggestIdx]
ar... |
73e45e6dbe6c6e9a6b022d390caa772addf899ab | rajatmishra3108/Daily-Flash-PYTHON | /18 aug 2020/prog3.py | 477 | 4.09375 | 4 | '''
Question :
You have been given a list.
cricketers = ['Kapil', 'Kohli', 'Raina', 'Chahal', 'Dhoni', 'Pant', 'Dravid', 'Bumrah', 'Harbhajan']
Iterate over the list in reverse order, such that only retired players name should be printed.
(Players retired from international cricket)
'''
cricketers = ['Kapil', 'Kohli',... |
fc4a26d27d69572269e18e198da22bac7182caf1 | rajatmishra3108/Daily-Flash-PYTHON | /Assignment/24 aug 2020/sol.py | 691 | 3.84375 | 4 | start = int(input())
end = int(input())
if(start == end):
print("INVALID RANGE")
else:
even_sum = 0
odd_sum = 0
even = list()
odd = list()
for i in range(start, end + 1):
if(i % 2 == 0):
even_sum += i
even.append(i)
else:
odd_sum += i
... |
b6c2ab37074be1587dd53185c93632471dbf213a | rajatmishra3108/Daily-Flash-PYTHON | /17 aug 2020/prog5.py | 253 | 4.21875 | 4 | """
Question : Write a Python program which accepts your name,
like("Rajat Mishra") and print output as
My--name--is--Rajat--Mishra.
"""
name = input("Enter Your Name : ")
output = "--".join(f"My name is {name}".split())
print(output)
|
008c9ec438ab1d9514f270e8632fbf723133798e | rajatmishra3108/Daily-Flash-PYTHON | /27 aug 2020/prog5.py | 419 | 4.09375 | 4 | '''
Question:
Write a program to check whether the entered number is Emirp number or not
'''
def isprime(num):
for i in range(2, num):
if(num % i == 0):
return 0
return 1
num = int(input("Enter the number : "))
rev_num = str(num)
rev_num = int(rev_num[::-1])
if(isprime(num) and ispri... |
cba84e9e17675ae6886166de617c206eff6eea92 | arzanpathan/Python | /Assignment 2.py | 312 | 4.09375 | 4 | #WAP to Print 10 to 1 using While
print('\nProgram to Print 10 to 1 using While')
a=10
while(a>=1):
print(a)
a=a-1
#WAP to print "n" natural numbers (Take input from the user)
print('\nProgram to print "n" natural numbers')
x=int(input('\nEnter a Number: '))
y=1
while(y<=x):
print(y)
y=y+1
|
0225550bcfb665a428f0a4b5d0044d17541dce10 | arzanpathan/Python | /Assignment No 08/Assignment 8.2(To Combine two dictionary by adding common keys).py | 2,854 | 4.09375 | 4 | #WAP to combine two dictionary by adding common keys.
'''
Example: D1={'a':10,'b':20,'c':30,'d':40}
D2={'c':12,'e':15,'f':18}
OUTPUT: D={'a':10,'b':20,'c':42,'d':40,'e':15,'f':18}
'''
Dictionary_Output,First_Dictionary,Second_Dictionary={},{},{}
First_Dictionary.setdefault(input('Enter a Word in First_Dictio... |
79600230399e7375232eb108a0df5e85bea58380 | chevon12/bootcamp-2020.1 | /week-4/Python/caitlynnjourney1.py | 450 | 3.828125 | 4 | counts = [ int(x) for x in input().split(' ') ]
stones = [ int(x) for x in input().split(' ') ]
queries = [ int(x) for x in input().split(' ') ]
#Prompt 1:
def find_day(query):
total_stones = 0
for stone in stones:
total_stones += stone
if total_stones >= query:
current_days = stone... |
1f1d583c90d7c94888d641b8d7ce4c8aa82b70d7 | Mastermeint/DIGS | /dataStrucDIG/dig.py | 16,796 | 3.59375 | 4 | #!/usr/bin/env python3
#
# author: Meinte
"""
This module represents graphs as Dotted Interval Graphs.
It is combined with module networkX
Classes:
DIGd
Functions:
dig_cycle
dig_complete_bipartite
plot_bipartite_graph
create_random_dig
reduce_dig
"""
import networkx as nx
import matplotl... |
a0e39e73b419d7c8868034391010cb187753f962 | mcy0605/sqlite-3-and-tkinter- | /update_delete.py | 3,237 | 3.75 | 4 | import tkinter as tk
import tkinter.ttk as ttk
from tkinter import StringVar
from tkinter import messagebox
import sqlite3
import os.path
def initDataBase():
conn=sqlite3.connect('moviedata.db')
sql ="create table movies(name Text primary key, category Text, description Text, price Real)"
conn.... |
78b59a099e58b4b104f30396bb9fb64dfe657de3 | joshua2352-cmis/joshua2352-cmis-cs2 | /GuessyGAME.py | 695 | 4 | 4 |
import random
guesses = 0
number = random.randint(1, 100)
print(' i am thinking of a number between 1 and 100.')
while guesses < 6:
print('whats your first guess')
guess = input()
guess = int(guess)
guesses = guesses + 1
if guess < number:
print('Your guess is too low.')
... |
05ec45e001930636b34e6b4ad5c3617146911be6 | joshua2352-cmis/joshua2352-cmis-cs2 | /countDOWN.py | 330 | 3.984375 | 4 | def countdown(n):
def countdown_from_to(start,stop)
if start <= stop:
print 'Blastoff!'
else:
print n
countdown(n-1)
countdown_from_to(10,1)
def main():
start = raw_input("put a number to count down from:")
stop = raw_input("put the number you want it to stop at:")
mai... |
30efa4198bf4c7740e6141097af07d5ce21ba700 | akjadon/HH | /Python/Python_Exercise/Python_Exercise1/ex40.py | 1,701 | 3.828125 | 4 | """An anagram is a type of word play, the result of rearranging the letters
of a word or phrase to produce a new word or phrase, using all the original
letters exactly once; e.g., orchestra = carthorse, A decimal point = I'm
a dot in place. Write a Python program that, when started 1) randomly
picks a word w from gi... |
e1db88f5c88a18ff71613ef998378ca164fb4018 | akjadon/HH | /Python/Python_Exercise/Python_Exercise1/ex37.py | 722 | 4.09375 | 4 | """Write a program that given a text file will create a new text file in
which all the lines from the original file are numbered from 1 to n
(where n is the number of lines in the file)."""
import re
# I couldn't think of a better name for this :P
def numberize(file_name):
# Get basename and extension of provided ... |
5e49178aa33566d2e953913f919101f8a2bc1e93 | akjadon/HH | /Python/Python_Exercise/Python_Exercise1/ex38.py | 569 | 4.28125 | 4 | """Write a program that will calculate the average word length of a text
stored in a file (i.e the sum of all the lengths of the word tokens in the
text, divided by the number of word tokens)."""
from string import punctuation
def average_word_length(file_name):
with open(file_name, 'r') as f:
for line in f:
... |
f50269a35eb4da827425795badc0ba7eab421a92 | akjadon/HH | /Python/Python_Exercise/Python_Exercise1/ex46.py | 2,938 | 4.4375 | 4 | """An alternade is a word in which its letters, taken alternatively in a
strict sequence, and used in the same order as the original word, make up at
least two other words. All letters must be used, but the smaller words are not
necessarily of the same length. For example, a word with seven letters where
every seco... |
832246967f1e789425b37d6bb9972568007d10a2 | gmastorg/CSC121 | /M4A2_FileAnalysis_GabrielaCanjura.py | 1,489 | 3.609375 | 4 | # Gabriela Canjura
# CSC 121_M4A2_FileAnalysis
# 04/06/2018
# Compares words in two files using sets
def main():
set1 = set ()
set2 = set()
set3 = set()
firstList = []
secondList = []
filesList = []
with open ('first_file.txt','r') as firstfile:
fo... |
33c944dacbea84c4d9dda2de4df77280ce2eda10 | gmastorg/CSC121 | /CanjuraMenuExemptions.py | 1,259 | 4.03125 | 4 | # creates a shell that calls funtions and runs a loop
# 02/05/2018
# CSC-121 In Class
# Gabriela Canjura
import functions
def main():
keepGoing = "Y"
while keepGoing == "Y":
mainMenu()
keepGoing = input("Would you like to keep going? (Y/N) \n")
keepG... |
2a5f3f611ca53f2e173c3ec12fba914a98480d6f | gmastorg/CSC121 | /M2HW1_NumberAnalysis_GabrielaCanjura(longer).py | 1,275 | 4.1875 | 4 | # gathers numbers puts them in a list
# determines correct number for each category
# 02/12/2018
# CSC-121 M2HW1 - NumberAnalysis
# Gabriela Canjura
def main():
total = float(0)
numOfNumbers = int(20) # decides loop count and used for average
total,numbers = get_values(numOfNumbers)
... |
1f9f2c05bffaf755d40164b3704909532d50243a | motaz-hejaze/lavaloon-problem-solving-test | /problem2.py | 1,451 | 4.1875 | 4 | print("***************** Welcome ********************")
print("heaviest word function")
print("python version 3.6+")
print("run this script to test the function by yourself")
print("or run test_problem2 for unittest script ")
# all alphabets
alphabet_dict = {
"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "g": 7,... |
5e66473232a48ae56ca61e9a46d3797876baab7c | tjonac/Proyecto_jrh | /EzMath/Graficador.py | 1,090 | 4.03125 | 4 | """
Este programa grafica curvas descritas por ecuaciones parametricas.
"""
import numpy as np
import matplotlib.pyplot as plt
#<---------------------------Funciones---------------------------->
def f(t,x_eq):
f = eval(x_eq)
return f
def g(t,y_eq):
g = eval(y_eq)
return g
def h(x,eq):
h = eval(e... |
e7ebe1c532285dc0111ecf465ab66ea7c008a207 | yiqiufeng/pylearn | /004_list.py | 1,244 | 4.0625 | 4 | """
coding:utf-8
文件名称:004_list.py
功能:
"""
# 使用list函数定义空列表
l= list()
#使用中括号定义空列表
l=[]
#使用中括号定义带初始值的列表
l =[1,2,3]
#使用list函数把可迭代对象转换为列表
l=list(range(1,10))
print(l)
help(list.index)
help(list.count)
help(list.append)
help(list.insert)
help(list.extend)
new_l.insert(i,e)
new_l.insert(1,2)
new_l.insert(0,'e')
new_l.in... |
585d69c3a22f98cba52b7474f9589d818dfe7bc3 | FloncDev/RandomProjects | /Fizbop2.py | 318 | 4.09375 | 4 | loop = 1
num1 = 3
num2 = 5
loopn = int(input("How many numbers down?")) + 1
while loop < loopn:
if loop % num1 == 0 and loop % num2 == 0:
print("Fizbop")
elif loop % num1 == 0:
print("Fiz")
elif loop % num2 == 0:
print("Bop")
else:
print(loop)
loop += 1 |
8b647cd6904615072267a198cf2a769da1a26c17 | tango69/Stamp | /StampClassify/SeparteTrainTest.py | 669 | 3.546875 | 4 | #随机分训练和测试图片
import random,os
import shutil
SourceFolder = "/Users/applezhj/workspace/pycharm/deepLearing/StampDB/Data/1"
TrainFolder = "/Users/applezhj/workspace/pycharm/deepLearing/StampDB/Data/train/1"
TestFolder = "/Users/applezhj/workspace/pycharm/deepLearing/StampDB/Data/test/1"
thre = 1
filelist = os.listdir(So... |
deb0c86369488f5996c5365ea5b85a97380f1a1b | tirodkar79/data-structures | /queue_list.py | 879 | 3.890625 | 4 | from linked_list import SinglyLinkedList
class Queue:
def __init__(self):
self.s = SinglyLinkedList()
def enqueue(self, value):
self.s.insert_last(value)
def dequeue(self):
return self.s.delete_start()
def print_queue(self):
self.s.print_linklist()
def is_empty(s... |
d319b50fbee8efc7c8269fa6fc850a666586116b | tirodkar79/data-structures | /linked_list.py | 2,939 | 3.875 | 4 | class Node:
def __init__(self, value):
self.data = value
self.next = None
class SinglyLinkedList:
def __init__(self):
self.head = None
self.size = 0
def insert_start(self, value):
if self.head is None:
self.head = Node(value)
self.size += 1
... |
2eddbd088c8390c54213e66ab31d093f07991d9e | silasfelinus/PythonProjects | /8_8_user_albums.py | 394 | 3.90625 | 4 | def make_album(name, title, tracks = ""):
album = {'name' : name.title(), 'title' : title.title()}
if tracks:
album['tracks'] = tracks
return album
while True:
print("Please tell me the band name:")
print("(Enter 'q' at any time to quit)")
band = input("Band Name: ")
if band == 'q':
break
album = input("... |
e78997ec31b258f44532ee3066938f4aa3e2826b | silasfelinus/PythonProjects | /9_8_privileges.py | 1,189 | 4.28125 | 4 | class User():
"""A basic user to explore Classes"""
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
self.full_name = self.first_name.title() + " " + self.last_name.title()
def describe_user(self):
print("User's name is " + self.full_name)
def greet_use... |
5e727dfead901603bd7972ae63c92bdc68467516 | silasfelinus/PythonProjects | /9_7_admin.py | 732 | 4.15625 | 4 | class User():
"""A basic user to explore Classes"""
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
self.full_name = self.first_name.title() + " " + self.last_name.title()
def describe_user(self):
print("User's name is " + self.full_name)
def greet_use... |
01fe36b52dc3a5d9f74cdc883d92d8e53ba4d008 | silasfelinus/PythonProjects | /9_1_restaurant.py | 425 | 4.09375 | 4 | class Restaurant():
"""A basic restaurant to explore Classes"""
def __init__(self, name, cuisine):
self.name = name
self.cuisine = cuisine
def describe_restaurant(self):
print(self.name.title() + ": " + self.cuisine)
def open_restaurant(self):
print(self.name.title() + " is open!")
my_restaurant = Res... |
c86115e76fc305660d014f1579e65ecffa2b4c33 | silasfelinus/PythonProjects | /9_5_login_attemps.py | 787 | 4.21875 | 4 | class Restaurant():
"""A basic restaurant to explore Classes"""
def __init__(self, name, cuisine):
self.name = name
self.cuisine = cuisine
self.number_served = 0
def describe_restaurant(self):
print(self.name.title() + ": " + self.cuisine)
def set_number_served(self, number):
self.number_served = numbe... |
95cf69ffd5206764041e705dc7ccf197bba5b006 | silasfelinus/PythonProjects | /8_4_large_shirts.py | 200 | 3.625 | 4 | def make_shirt(size = "L", text = "I love python"):
print('The shirt will be size ' + size + ' and say: "' + text + '".')
make_shirt()
make_shirt(size="M")
make_shirt (text='Hot Stuff', size="SM") |
bb1f1d4f350ad04e5e9b34aeb71ac464bc3c516a | silasfelinus/PythonProjects | /9_13_ordereddict_rewrite.py | 536 | 3.859375 | 4 | """Rewritten dictionary to use OrderedDict"""
from collections import OrderedDict
glossary = OrderedDict()
glossary['if'] = "conditional returning true or false"
glossary['elif'] = "The best thing since sliced bread."
glossary['dictionary'] = "What this is, even though we are also calling it a 'glossary'"
glossary['p... |
89071b1ccf6d0832cc2d85d32cb494a2625b084d | armotes/API | /com/lsx/storage/csv_storage.py | 468 | 3.59375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : cvs_storage.py
# @Author: Armote
# @Date : 2018/10/29 0029
# @Desc :使用CSV存储下:类似于excel
import csv
csvFile = open('D:\\file\\csv\\test.csv','w+')
try:
write = csv.writer(csvFile)
#首行设置列名
write.writerow(('number','number plus 2','number times 2'))
... |
20b4c6acd99f2f04545798ae6e6219b4140e176b | MarcoNasc/URI-Online-Judge | /1098 (Sequence IJ 4).py | 306 | 3.71875 | 4 | from decimal import Decimal
i = 0
while i <= 2:
j = 1
for m in range(3):
if i == 1 or i == 2:
i = int(i)
print('I={} J={}'.format(i, j + i))
j += 1
else:
print('I={} J={}'.format(i, j + i))
j += 1
i += Decimal('0.2')
|
9061824affd0b29c7de57a18668ca1c7155ae0c6 | MarcoNasc/URI-Online-Judge | /1019 (Time Conversion).py | 266 | 3.609375 | 4 | valor = int(input())
horas = minutos = segundos = 0
while (valor >= 3600):
valor -= 3600
horas += 1
while (valor >= 60):
valor -= 60
minutos += 1
while (valor >= 1):
valor -= 1
segundos += 1
print('{}:{}:{}'.format(horas, minutos, segundos))
|
ce11027a05cf9b8185509b51b954cc8007327ad6 | MarcoNasc/URI-Online-Judge | /1022 (TDA Rational).py | 675 | 3.65625 | 4 | from math import gcd
'''def gcd(x, y):
while y != 0:
(x, y) = (y, x % y)
return x'''
n = int(input())
for i in range(n):
n1, barra1, d1, op, n2, barra2, d2 = input().split()
n1 = int(n1)
d1 = int(d1)
n2 = int(n2)
d2 = int(d2)
if (op == '+'):
num = (n1*d2 + n2*d1)
... |
e36298debfd2819dc21e40ddfeab61842f8ac239 | reyesmarcy/projects | /movie_catalog.py | 3,116 | 4.15625 | 4 | #! /usr/bin/env python3
def display_menu():
print("The Movie Catalog Program")
print()
print("Menu")
print("actor - List Movies for Actor")
print("list - Show All Movie by Title")
print("show - Show Movie Info")
print("add - Add Movie")
print("edit - Edit Movie Info")
print("de... |
d9f5919dee56c212c76140c3795a038435ecc66d | luxaobohit/python | /mergepics.py | 732 | 3.59375 | 4 | #!usr/bin/env python
#-*- coding: utf-8 -*-
# merge pictures
import PIL.Image as Image
import os
num = 10
picpxl = 110
#create a new blank image
toImg = Image.new('RGBA', (num * picpxl, num * picpxl), color = 255)
imgpath = r'C:/Users/lu/Desktop/tieba/'
#get the list of image's name
imglist = os.listdir(imgpath)
fo... |
d9c29eea38b0de441984aef55709c20d8e4aa94f | Lyoug/sticky-nim | /sticky_nim_console.py | 16,767 | 3.5625 | 4 | """Sticky-Nim - Console interface"""
import random
from mechanics import Move, Settings, Player, Game
import ai
# Console window width
SCREEN_WIDTH = 80
# Default settings
DEFAULT_BOARD_SIZE = 20
DEFAULT_MAX_TAKE = 3
# Using a board this size and up will trigger a warning about the AI taking a
# possibly long time... |
134545e3f9f0ae034d22b4336ffeedfa14bb5e39 | clementled/blackjack | /BJV3.8.py | 26,146 | 3.65625 | 4 | import random
import time
import os
os.system("cls")
print (' ')
print ("BLACK JACK MADE BY CLEMENT AND CYRIL ")
print ('si vous voulez nous aider, vous pouvez faire un don en cliquant sue le lien suivant : ')
print ("https://paypal.me/pools/c/8wIOjZl6W7")
print ('donateurs : Thibaut (1€) ')
time.sleep(5)
p... |
6fbcd8deb56d9b67ea05e3c0ae738f3ceaadb817 | NilanjanTarafder/SimplePrograms-2 | /python programs/easy programs/swap_without_third_variable.py | 135 | 3.828125 | 4 | n1 = input('enter 1st number : ')
n2 = input('enter 2nd number: ')
n1, n2 = n2, n1
print('first number : ',n1,' second number : ', n2) |
0ac87f15fa7826bae4c1265c6ab220c42599af9e | NilanjanTarafder/SimplePrograms-2 | /python programs/easy programs/lcm_of_2_numbers.py | 237 | 3.953125 | 4 | print('enter 2 numbers : ')
n1 = int(input())
n2 = int(input())
lcm = 0
if n1 > n2:
lcm = n1
else:
lcm = n2
while(True):
if lcm % n1 == 0 and lcm % n2 == 0:
print('lcm is {}'.format(lcm))
break
lcm += 1
|
31efa608b16eaa82298846ed5785d6946db1145c | DanielWayn/begining | /DanielProject/reserve_word_in_sentence.py | 352 | 3.890625 | 4 | def split_conect(sentence):
sentence_2 = sentence.split()
print(sentence_2)
sentence_3 = []
for a in reversed(sentence_2):
sentence_3.append(a)
print(sentence_3)
sentence_3 = ' '.join(str(b) for b in sentence_3)
print(sentence_3)
sentence = str(input("Enter a sentence with spacin... |
38a8abf142d21406bbf1c87280f4eaf2d821f5a5 | Orctonk/ai-grunder | /ann/loss.py | 1,627 | 3.953125 | 4 | import numpy as np
def mean_square_error(output,target):
"""Calculates the mean square error loss of the output and target.
Parameters
----------
output: The output of the neural network.
target: The expected output of the neural network.
Return
------
The mean square error loss of th... |
9ab2a05989b3cf409677aeffbbcabff2e393c960 | stumped2/school | /CS325/hw1/hw1.py | 2,797 | 3.96875 | 4 | #!/usr/bin/env python
import math
import time
import sys
import random
# This function takes a list of numbers and goes through each value
# with each value it goes through another loop to add each of the subsequent
# members of the list. This total is then compared with the running minimum to
# find the sm... |
01d2dfd95736e7d04ee725f2bd748020057be517 | stumped2/school | /CS325/hw1/New Folder/CS325_Proj1_timmerme_coreyg_isons.py | 3,804 | 3.78125 | 4 | #!/usr/bin/env python
# Project 1 code for CS325
# Group Mmebers: Eric Timmerman, Stephanie Ison, Geoffrey Corey
import math
import time
import sys
import random
# This function takes a list of numbers and goes through each value
# with each value it goes through another loop to add each of the subsequent... |
480d03fbddf8a89724fb4e78ff90ea84b50c623a | tobigue/tobitools | /tobitools/printing.py | 1,267 | 3.59375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import codecs
import locale
import math
import sys
def bar_chart(data, maxbarlen=30):
"""
Prints a bar chart over the given data. The data is expected
to be a iterable of tuples, where th... |
efb2b54f806c937b29f4faf026e36997c42d44e8 | umerjamil16/Search-and-Sample-Return | /test01.py | 1,675 | 3.84375 | 4 | #!/usr/bin/env python3
# Import some packages from matplotlib
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
# Uncomment the next line for use in a Jupyter notebook
#%matplotlib inline
# Define the filename, read and plot the image
filename = 'sample.jpg'
image = mpimg.imread(filename)
plt.imshow(ima... |
4ae6340524c73b97d71e88d54e78f1457a542612 | eunice-ogboye/my-app | /main/index.py | 1,292 | 3.71875 | 4 | print("to calculate the prices of some goods")
qm1 = input("Enter the qmtn100 quantity: ")
m1 = 970 * float(qm1)
qm2 = input("Enter the qmtn200 quantity: ")
m2 = 1940 * float(qm2)
qm4 = input("Enter the qmtn400 quantity: ")
m4 = 3880 * float(qm4)
qm5 = input("Enter the qmtn500 quantity: ")
m5 = 4850 * float(qm5)
qm10 ... |
0b4d0e51d7d146e8121a8ca2e8e6f31797840572 | ChezzOr/codeFightsSolves | /reverseParenthesis.py | 614 | 3.75 | 4 | def reverseParentheses(s):
return recursiveParenthesis(s)
def innerRecursion(input):
while input.find('(') != -1:
input = input[:input.find('(')] + innerRecursion(input[input.find('(') + 1:])
shifts = input[:input.find(')')]
shifts = shifts[::-1]
return shifts + input[input.find(')') + 1:]
def recursive... |
0c62ff7ab5bf7afeb43db3d74580deb06abe89a2 | rohit2219/python | /decorators.py | 1,068 | 4.1875 | 4 | '''
decorator are basically functions which alter the behaviour/wrap the origonal functions and use the original functions
output to add other behavious to it
'''
def add20ToaddFn(inp):
def addval(a,b):
return inp(a,b) + 20
addval.unwrap=inp # this is how you unwrap
return addval
@add20ToaddFn
def... |
e87a73f1ccfa32f18c6f5ed4b03b245512df48b3 | rohit2219/python | /paranth.py | 1,373 | 3.515625 | 4 |
def isMatchParan(paranStr):
paranMap={
']':'[',
')': '(',
'}': '{',
}
stack=[]
unmatchFlag=True
for i in paranStr:
#print('stack:',stack,'i:',i)
if i in paranMap.values():
stack.append(i)
print('append:',i)
elif stack == [] or... |
34aafc97432efbe7bf69aaefd82758edc3277b69 | rohit2219/python | /binaryAdd.py | 1,416 | 3.671875 | 4 | def binAddHelp(num1, num2):
sum = 0
carry = 0
#print('hits helper',num1, num2,type(num1),type(num2))
if num1 == '1' and num2 == '1':
return sum, carry+1
elif num1 == '1' and num2 == '0':
#print('return from helper',sum+1, carry)
return sum+1, carry
elif num1 == '0' and nu... |
eb61cdeb16af7a5b30c6d88c7ca8c3db2b64b708 | rohit2219/python | /fibonacci.py | 1,948 | 3.953125 | 4 |
class fiboClass:
def __init__(self):
self.fiboList = []
self.fiboDict = {0:0, 1:1}
self.fiboNumDict = {0:0, 1:1}
### below are all counts to show how many times recursion has happened.
self.retcount = 0
self.notrecount = 0
self.loopcount = 0
self.fibo... |
29edb0ac500e0c35e8c1f4bab36a8c33e3406adf | rohit2219/python | /longestPalinSubstr.py | 781 | 3.578125 | 4 | #https://leetcode.com/problems/longest-palindromic-substring/
class Solution:
def longestPalindrome(self, inpStr: str):
longSubstr=""
maxLen=0
prevMaxlen=0
for i in range(len(inpStr)):
palStr1=self.lenPalinAtPoint(inpStr,i,i)
palStr2=self.lenPalinAtPoint(inp... |
7ebc7b6f18d3beaca8ec58b486f78ac661f46ec0 | Methuselah96/aoc-2019-python | /02_1/solve.py | 778 | 3.59375 | 4 | def add(state, index):
state[state[index + 3]] = state[state[index + 1]] + state[state[index + 2]]
def multiply(state, index):
state[state[index + 3]] = state[state[index + 1]] * state[state[index + 2]]
def solve(state):
index = 0
op_code = state[0]
while op_code != 99:
if op_code == 1:
... |
0b5527d78650550885257545072770ab14f2bb34 | 9mean/MyAlgorithm | /김태원 탐색시뮬레이션/회문문자열검사(김태원).py | 177 | 3.640625 | 4 | #회문 문자열 검사
n=int(input())
for i in range(n):
s=input()
s=s.upper()
size=len(s)
if s==s[::-1]:
print("#%d YES"%(i+1))
else:
print("#%d NO"%(i+1))
|
beedf3656e6f1a98318501c8ec29cafac3dff8f2 | ajdelave/TeamPython---Final-Project | /spotify.py | 3,684 | 3.609375 | 4 | import os
import sys
import json
import spotipy
import spotipy.util as util
from json.decoder import JSONDecodeError
import spotify_info
import sqlite3
# Import Spotify API info from spotify_info.py
username = spotify_info.username
scope = 'user-top-read'
client_id = spotify_info.client_id
client_secret... |
757816838f2ef2700ba3e02933bf3f89e26b87f1 | Gingervvm/JetBrains_Hangman | /Problems/Copysign function/task.py | 221 | 3.609375 | 4 | import math
def copysign_y_to_x(first, second):
return math.copysign(first, second)
# don't modify this code or the variables may not be available
x, y = map(float, input().split(' '))
print(copysign_y_to_x(x, y)) |
d547bfece42f25c65ea43ed2553ab849d2032614 | Gingervvm/JetBrains_Hangman | /Problems/The farm/task.py | 712 | 3.890625 | 4 | money_sum = int(input())
sheep_cost = 6769
cow_cost = 3848
pig_cost = 1296
goat_cost = 678
chicken_cost = 23
if money_sum >= sheep_cost:
print(str(money_sum // sheep_cost) + " sheep")
elif money_sum >= cow_cost:
print(str(money_sum // cow_cost) + " cows" if money_sum // cow_cost != 1 else "1 cow")
elif money_su... |
6e02c05b5d799c270656c0615cb6d33d6e0d11c2 | Gingervvm/JetBrains_Hangman | /Problems/snake_case/task.py | 162 | 4.34375 | 4 | string_input = input()
for char in string_input:
if char.isupper():
string_input = string_input.replace(char, "_" + char.lower())
print(string_input) |
1714e762362a0eab5f2ebc39bda6667d83c144b7 | kpranjal2047/Deep-Learning-Assignment | /MNIST Detection Models/build_dataset.py | 1,453 | 3.515625 | 4 | # Import Libraries
import numpy as np
import pandas as pd
from tensorflow.keras.datasets import mnist
from tensorflow.python.keras.utils.np_utils import to_categorical
# Preprocesses the images
def int2float_grey(x):
x = x / 255
return x
# Builds the dataset locally
def build_dataset():
# Any results you... |
abfb843b0c322c94b28aa0320f80a46bf0d0a320 | errord/weld | /weld-python/weld/types.py | 7,043 | 3.703125 | 4 | """
Types available in Weld.
"""
from abc import ABC, abstractmethod
import ctypes
import sys
class WeldType(ABC):
"""
A Weld representation of a Python type.
Other types should subclass this and provide an implementation of
`ctype_class`, which describes what the Python type looks like in Weld.
... |
fd635e1daa8dcc6bb3f71308dc99b0a0c8a0d6f5 | lileekoi/video-store-cli | /main.py | 4,147 | 3.59375 | 4 | import requests
from customer import Customer
from video import Video
from rental import Rental
URL = "https://retro-video-store-api.herokuapp.com"
def main():
print("WELCOME TO RETRO VIDEO STORE")
print("Please choose from the following menu options:")
options = {
"1": "add a video",
... |
069de02a13505fa4c356308b8ed189446807612c | BondiAnalytics/Python-Course-Labs | /13_list_comprehensions/13_04_fish.py | 333 | 4.25 | 4 | '''
Using a listcomp, create a list from the following tuple that includes
only words ending with *fish.
Tip: Use an if statement in the listcomp
'''
fish_tuple = ('blowfish', 'clownfish', 'catfish', 'octopus')
fish_list = list(fish_tuple)
print([i for i in fish_list if i[-4:] == "fish"])
# fishy = []
# for i in ... |
cd318be0b06227fc766e910ea786fb792c02fced | BondiAnalytics/Python-Course-Labs | /14_generators/14_01_generators.py | 245 | 4.375 | 4 | '''
Demonstrate how to create a generator object. Print the object to the console to see what you get.
Then iterate over the generator object and print out each item.
'''
gen = (x**2 for x in range(1,6))
for i in gen:
print(i)
print(gen) |
1a1719ea5ea41b3e5642ab05ff2a4036347de0d4 | BondiAnalytics/Python-Course-Labs | /02_basic_datatypes/trip_cost_calculator.py | 191 | 4.125 | 4 | km = int(input("KMs to drive ", ))
liters = int(input("Liters-per-km usage of the car ", ))
price = float(input("Price of petrol per liter ", ))
print("Cost of trip ", km / liters * price) |
2d9d4d1f8d3df2fb1bdfe7d04bb91f94ea6744b3 | BondiAnalytics/Python-Course-Labs | /12_packages_modules/12_env/12_01_math.py | 129 | 3.765625 | 4 | '''
Demonstrate how to access and print the value of pi to the console.
'''
import math
print("The value of pi is: ", math.pi) |
f943d2c3ba02916ac74eed6189534a388ce0b893 | Tavial/cursophyton | /ALFcondicionales/ejercicio10.py | 3,119 | 4.5625 | 5 | '''
La pizzería Bella Napoli ofrece pizzas vegetarianas y no vegetarianas a sus
clientes. Los ingredientes para cada tipo de pizza aparecen a continuación.
Ingredientes vegetarianos: Pimiento y tofu.
Ingredientes no vegetarianos: Peperoni, Jamón y Salmón.
Escribir un programa que pregunte al usuario si quiere... |
4d6ba2966eb4baf7366dd3017c2bdffcd10522ec | Tavial/cursophyton | /masterMind/main.py | 3,604 | 3.984375 | 4 | '''
Escribe un programa que te permita jugar a una versión simplificada del juego
Master Mind. El juego consistirá en adivinar una cadena de números distintos.
Al principio, el programa debe pedir la longitud de la cadena (de 2 a 9 cifras).
Después el programa debe ir pidiendo que intentes adivinar la cadena de ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.