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 |
|---|---|---|---|---|---|---|
6942b00e0b645aaddac3c8c2e88d43c59789794d | tree9990/learning-pieces | /prime.py | 147 | 3.5625 | 4 | for i in range (100):
p=[]
for j in range (2,i):
if i%j ==0 :
p.append(j)
if len(p)==0:
print (i)
|
f383da6c6c4435d62a4befc68f55b0f77cc2c66b | RobertLitzke/interviews | /math_interview_questions.py | 396 | 3.96875 | 4 | #1. Find the digital root (sum digits until only one digit remains)
# No string conversion
def digital_root(num):
if num/10==0:
return num
iter = 0
while num>0:
iter+=num%10
num/=10
return digital_root(iter)
# With a string conversion
def digital_root_s(num):
s = str(num)... |
625de99734a1744b83633c95f1ea59b730f432e2 | Aishwarya-11/Python-learnings | /fileoperation2.py | 225 | 3.53125 | 4 | #program to create file in runtime and copy
import os
from shutil import copyfile
f = open("myfile.txt","w+")
copyfile('sample.txt',f)
print("File copied successfully!")
a = open("myfile.txt",'r')
print(a.read())
a.close()
|
45aa263197f2257470a192294cce88680e8c839d | Aishwarya-11/Python-learnings | /program2.py | 454 | 4.15625 | 4 | def list() :
print ("Creating a list and performing insertion and deletion operations\n ")
print ("Enter the length :")
length = int(input())
print("Enter the values :")
list1 = []
for i in range(length) :
value = input()
list1.append(value)
print (list1)
print ("Enter the value to insert :")
num1 = input(... |
be7e215bc2b40ae1920246fdf584fffc8d785ee4 | cleversonmuller/cleversonmuller | /atividade4.py | 1,116 | 4.25 | 4 | #Faça um programa que faça 5 perguntas para uma pessoa sobre um crime. As perguntas são:
#"Telefonou para a vítima?"
#"Esteve no local do crime?"
#"Mora perto da vítima?"
#"Devia para a vítima?"
#"Já trabalhou com a vítima?"
# O programa deve no final emitir uma classificação sobre a participação
# da pessoa no crime.S... |
8247384f1f1eb7a12f7b88b20b1c5ce54a9d619d | bian-hengwei/LeetCode | /codes/690.员工的重要性.py | 772 | 3.640625 | 4 | #
# @lc app=leetcode.cn id=690 lang=python3
#
# [690] 员工的重要性
# @lc code=start
"""
# Definition for Employee.
class Employee:
def __init__(self, id: int, importance: int, subordinates: List[int]):
self.id = id
self.importance = importance
self.subordinates = subordinates
"""
from typing impo... |
7bbc2a48ee2bd102ec2646daa2658fd316783350 | gliverm/devnet-study-group | /pcep/mod9_10.py | 147 | 3.5625 | 4 | vals = [0, 1, 2]
vals.insert(0, 1)
print ("vals after insert: ", vals)
#output: 1,0,1,2
del vals[1]
print ("vals after del: ", vals)
#output: 1,1,2 |
3d8ca1b32fa791576f5a5e2292ff8c3819389b94 | gliverm/devnet-study-group | /pcep/mod5_classexperiment.py | 303 | 3.8125 | 4 | class ExampleClass:
a = 1
def __init__(self):
self.b = 2
exampleObject = ExampleClass()
print(exampleObject.__dict__)
print(ExampleClass.__dict__)
print(hasattr(exampleObject, 'b'))
print(hasattr(exampleObject, 'a'))
print(hasattr(ExampleClass, 'b'))
print(hasattr(ExampleClass, 'a')) |
b7727648f71825ea161efec5d518420c83ae4dfe | gliverm/devnet-study-group | /pcep/mod3_9.py | 155 | 3.921875 | 4 | var = 1
while var < 10:
print("#")
var = var << 1
print("var :", var)
#Output: 4 hashes for var 1, 2, 4, 8 and stopping when var 16 is reached |
9cb21a3677c989b5f27da16bcacb273afbe07e61 | gliverm/devnet-study-group | /pcep/print_class_names.py | 298 | 3.875 | 4 | def printExcTree(thisclass, nest = 0):
if nest > 1:
print(" |" * (nest - 1), end="")
if nest > 0:
print(" +---", end="")
print(thisclass.__name__)
for subclass in thisclass.__subclasses__():
printExcTree(subclass, nest + 1)
printExcTree(BaseException) |
09706ff6581a8bfca41878c265fb6b064826a4d9 | gliverm/devnet-study-group | /pcep/mod3_18.py | 65 | 3.859375 | 4 | i = 0
while i <= 3:
i += 2
print("*")
#Output is 2 stars |
6ff1178694a58c275e1de6d954f9b918aa7df929 | gliverm/devnet-study-group | /pcep/mod3_15.py | 145 | 3.796875 | 4 | nums = [1,2,3]
vals = nums[-1:-2]
print(vals)
# Output: vals is empty because end is not greater than start
# therefore nums is longer than vals |
a3a21b7ce8cd4dc33a8d8200156dff194087294f | gliverm/devnet-study-group | /pcep/mod3_1.py | 89 | 3.6875 | 4 | for i in range(1):
print("#")
else:
print("#")
#The output is 2 hashes.
|
4e4c95281d24057d7b54329f6fb595e466d376c0 | Swetapadma94/Feature-Engineering | /Outlier_using Zscore and IQR.py | 1,220 | 3.890625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Detecting Outliers using Z score
# In[27]:
data=[10,12,3,6,5,89,67,56,110,89,507,120,45,39,54,29,18,12,178,210,365,143,100,99,156,98,48,78,125,306,450]
# In[28]:
outliers=[]
def detect_outlier(data):
threshold=3
mean=np.mean(data)
std=np.std(data)
f... |
b8ce9abe820e5e2d1640a4928f51de93ac1b30e1 | patilvikas0205/python-Exercise | /type_casting_hex_octa_bin_to_int.py | 1,104 | 4.4375 | 4 | #type casting in python convert datatypes explicitely
#this program convert binary, octal, hexadecimal object type to int
#octal to int
octal_num=0O17
print("Type of Octal_num before: ",type(octal_num))
ocatl_to_int=int(octal_num)
print("Octal to int: ",ocatl_to_int)
print("Type of Octal_num after: ",type(ocat... |
e0d5492aa7d98d9e968aacbdcb6b36d8a057d91b | patilvikas0205/python-Exercise | /Assignment_No_15.py | 568 | 4.4375 | 4 | '''
15. Define a class named Shape and its subclass Square.
The Square class has an init function which takes a length as argument.
Both classes have a area function which can print the area of the shape
where Shape's area is 0 by default.
'''
class Shape:
def area(self):
print("Area Of Shape is... |
6f6ed62f8f510fa72eaaf6120570334ceed1c78c | patilvikas0205/python-Exercise | /Assignment_No_11.py | 853 | 4.28125 | 4 | '''
11. Write a program to compute the frequency of the words from the input. The output should output after sorting the key alphanumerically.
Suppose the following input is supplied to the program:
New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3.
Then, the output should be:
2 :2... |
8fa31985dd13ea2f6607f2ed993ae71238fd254c | cassieeric/Python-Exercises_Interview_questions | /简单算法题/排序算法/选择排序/选择排序.py | 418 | 4.15625 | 4 | # -*- coding: utf-8 -*-
def selection_sort(list):
for i in range(len(list)):
min_index = i
for j in range(i + 1, len(list)):
if list[j] < list[min_index]:
min_index = j
list[i], list[min_index] = list[min_index], list[i]
if __name__ == '__main__':
... |
911db150984e9fd37cb5bb55dc722b19680eda04 | cassieeric/Python-Exercises_Interview_questions | /基础题目/数组/输出水仙花数.py | 697 | 3.96875 | 4 | # -*- coding: utf-8 -*-
# 自定义输入数值
# number = int(input('Please input your number(3 numbers): '))
# geweishu = number % 10
# # print(geweishu)
# shiweishu = number // 10 % 10
# # print(shiweishu)
# baiweishu = number // 100
# # print(baiweishu)
# a = geweishu ** 3 + shiweishu ** 3 + baiweishu ** 3
# if a == number:
# ... |
39bca21d4be272be0e36c1d6b970693b05e68aa6 | cassieeric/Python-Exercises_Interview_questions | /简单算法题/排序算法/冒泡排序/冒泡排序算法改进1.py | 1,877 | 3.875 | 4 | # -*- coding: utf-8 -*-
#---------------------------------------
# 程序:冒泡排序
# 版本:0.1
# 作者:WuChong
# 日期:2014-01-28
# 语言:Python 3.3
# 说明:冒泡排序,从小到大排序,以及加了两种优化
#---------------------------------------
def bubble_sort(ary):
n = len(ary) #获得数组的长度
for i in range(n):
for j in ... |
a1e5e6b4a3aaa181878280b1e4f8cd36cdc63b49 | gusbatista/Python_Basic_Reference | /simpleCallingFunctions.py | 1,450 | 4.03125 | 4 | #
# Funcao Simples que eleva um numero ao cubo
#
def calculateCube(number):
result = number*number*number
return result;
#
# Funcao Simples que eleva dois numeros ao cubo e retorna ambos resultados
#
def calculateTwoCubes(number1,number2):
result1 = number1*number1*number1
result2 = number2*number2*num... |
fd174f0aee0488cd3be6a50bd2da5990fe2fa0c8 | tuanphandeveloper/practicepython.org | /divisors.py | 459 | 4.3125 | 4 |
# Create a program that asks the user for a number and then prints out a list of all the divisors
# of that number. (If you don’t know what a divisor is, it is a number that divides evenly into another
# number. For example, 13 is a divisor of 26 because 26 / 13 has no remainder.)
number = int(input("Please enter a... |
c2497c1c1f430f290d1eee2c230a26abcd6ab338 | tuanphandeveloper/practicepython.org | /listEnds.py | 356 | 4.15625 | 4 |
# Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25])
# and makes a new list of only the first and last elements of the given list. For practice,
# write this code inside a function.
import random
a = [5, 10, 15, 20, 25]
b = random.sample(range(100), 20)
print(b)
c = []
c.append(b... |
bc18cbbb7647bf677780570cc3f0f03fb6a7819b | tuanphandeveloper/practicepython.org | /rockPaperScissor.py | 885 | 4 | 4 |
# Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them,
# print out a message of congratulations to the winner, and ask if the players want to start a new game)
playAgain = "Y"
while (playAgain == "Y"):
gameDict = {"rock": 1, "paper": 2, "scissor": 3}
p1 = input(... |
1d1b857d1e64febddd4287705a25f30da4c52d96 | tuanphandeveloper/practicepython.org | /fileOverlap.py | 641 | 3.671875 | 4 |
# Given two .txt files that have lists of numbers in them, find the numbers that are overlapping.
# One .txt file has a list of all prime numbers under 1000, and the other .txt file has a list of
# happy numbers up to 1000.
firstList = []
secondList = []
with open('list1.txt') as list1:
line = list1.readline()
... |
cf897751fe8edf50d8dd127dfc551b48666735ca | mruiz42/libpyflashcard | /TypingGame.py | 4,273 | 3.5 | 4 | import os
import re
from Card import Card
from Deck import Deck
from Session import Session
from Statistic import Statistic
from Database import Database
class TypingGame:
'''
The TypingGame object controls the study game loop and user interactions via command line input.
:param deck: The deck that will be ... |
d7941fca8d61f1189030a7dee470b43cb8114cef | foxof72/geoLocator356 | /aws.py | 4,827 | 3.5 | 4 | # aws.py
# Basic location data for Amazon Web Services EC2 datacenters.
#
# Run this program like this:
# python gcp.py
#
# Author: K. Walsh <kwalsh@cs.holycross.edu>
# Date: 9 February 2017
#
# Amazon does not seem to publish information about the actual physical
# locations of their AWS EC2 datacenters, even thoug... |
88416d8a6420c7158944852f0570e6ebf80ba727 | wfath/Simple-Telnet-Client | /client.py | 4,563 | 3.53125 | 4 | import socket
import select
global userInfo
#this prints all of the socket information
#print(socket.getaddrinfo("www.goatgoose.com", 12000))
#takes in the socket the host and the port
#tries connecting and then returns true or false respectively
def connectServer(sock, url, port):
try:
sock.connect((url... |
3e81239f0bee077762e4e0bdcbc6c06e6173e2e5 | RobinPetit/INFOF-308 | /source/diseasegenes.py | 2,267 | 3.5625 | 4 | #!/usr/bin/python3
from sys import argv
from os.path import isfile
from os.path import isdir
def print_usage():
"""
print usage of program to help user
"""
print("The given script is used to generate individual disease genes files " + \
"named after the diseases in a given directory (which m... |
8947c034ecc343061ad725ebf6f404723b647d7d | AguaClara/aguaclara | /aguaclara/design/ent_floc.py | 2,923 | 3.59375 | 4 | """The entrance tank/flocculator assembly of an AguaClara water treatment plant
contains the entrance tank, chemical dose controller (CDC), linear flow orifice
meter (LFOM), and flocculator. It adds the initial dose of coagulant and
chlorine to the influent water, then causes flocs (accumulated coagulant and
primary pa... |
22fdec6977480916ed8c13ba2001809d38ba5d2d | aglab2/MineSweeper | /MSField.py | 8,376 | 3.5 | 4 | """Field class for Minesweeper"""
import random
import logging
class MSField():
"""Class itself"""
def __init__(self, sizen, sizem, mines, screen):
"""Constructor of random field"""
if mines > sizen*sizem:
raise Exception('To many mines for this field size')
#Initiate fiel... |
2091d16c7858327f6c7f7ead2287fe100f13990c | sunnylam13/table_printer_020618_1 | /table_printer/table_printer_020618_1.py | 5,283 | 3.71875 | 4 | # -*- coding: utf-8 -*-
# ! /usr/local/Cellar/python3/3.6.1
# STATUS: unsolved
# Table Printer
#####################################
# TABLE DATA IMPORT
#####################################
# TODO: alter the program to take an input file that is imported with the table data
tableDataSet_1 = [
['apples','orange... |
2d469075be6254258c9e32a6c60b8403f3acafa7 | Ananya31-tkm/PROGRAMMING_LAB_PYTHON | /lab_s1/CO1-Q14.py | 418 | 3.734375 | 4 | Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> N = int(input("Enter the integers:"))
Enter the integers:5
>>> tmp = N
>>> tmp1 = tmp*tmp
>>> tmp2 = tmp*tmp*tmp
>>> print("Find N + NN + NNN\n")
Fi... |
d7bda6ee68d7db4dce73613293d8db161f2422ae | Ananya31-tkm/PROGRAMMING_LAB_PYTHON | /pkg.py | 762 | 3.703125 | 4 | from Graphics.Circle import *
from Graphics.Rectangle import *
from Graphics.Graphics3D.Cuboid import *
from Graphics.Graphics3D.Sphere import *
print("CIRCLE")
r=int(input("Enter radius of circle:"))
print("AREA OF CIRCLE:",area(r))
print("AREA OF CIRCLE:",perimeter(r))
print("\nRECTANGLE")
l=int(input("Enter length... |
df951ef9a7474d2b2ad0a29469e4dd68702e8bab | Ananya31-tkm/PROGRAMMING_LAB_PYTHON | /lab_s1/CO1-Q17,Q18.py | 291 | 4.21875 | 4 | dict ={'Swathi':67,'Anu':98,'Riya':66,'Vismaya':88,'Neema':75,'Reshma':89}
import operator
dict1=sorted(dict.items(),key=operator.itemgetter(1),reverse=True)
print("Descending order:",dict1)
dict1=sorted(dict.items(),key=operator.itemgetter(1),reverse=False)
print("Ascending order:",dict1)
|
5dea45fa7eb754e2dfe044151f207aca3b812efe | Ananya31-tkm/PROGRAMMING_LAB_PYTHON | /lab_s1/CO1-Q2.py | 368 | 4.03125 | 4 | current = int(input("Enter current year: "))
final = int(input("Enter final year: "))
if current < final:
print ("Here is a list of leap years between " + str(current) + " and " + str(final) + ":")
while current < final:
if current % 4 == 0:
print(current)
if current % 100 == 0 and current % 40... |
b5b0c77beba7aba0954a8ac1235d3d62d3e256ea | didwns7347/algotest | /알고리즘문제/4195 친구네트워크.py | 189 | 3.515625 | 4 | #친구 네트워크
n=int(input())
m=int(input())
network=[]
a={}
for x in range(m):
a,b=map(str,input().split())
st="hellen"
a[st]="kelly"
for x in a.values():
print(x)
|
03db189553e87eb807805f7cefe03c279aeadf07 | didwns7347/algotest | /Union-find/4195 친구네트워크.py | 712 | 3.5 | 4 | case=int(input())
out=[]
def union(a,b,cnt):
a=find(a)
b=find(b)
if a!=b:
friends[b]=a
cnt[a]+=cnt[b]
def find(a):
if friends[a]==a:
return a
else:
tmp=find(friends[a])
friends[a]=tmp
return tmp
def findp(a):
if friends[a]==a:return a
return f... |
c0744417c1de7b39739d995f843838f0fcc6e132 | didwns7347/algotest | /알고리즘문제/2579계단오르기.py | 232 | 3.5 | 4 | num = int(input())
a=[ int(input()) for x in range(num)]
s=[0 for x in range(num)]
s[0]=a[0]
s[1]=a[1]+a[0]
s[2]=max(a[2]+a[0],a[0]+a[1],a[1]+a[2])
for x in range(3,num):
s[x]=max(a[x]+s[x-2],a[x]+a[x-1]+s[x-3])
print(s[num-1])
|
485833bbc34a7f5260840bfee85e3cadf17b50d9 | didwns7347/algotest | /알고리즘문제/달팽이 삼각형.py | 960 | 3.515625 | 4 | def solution(n):
answer = []
board=[[0 for _ in range(n)] for _ in range(n)]
cnt=0
i,j=0,0
fin=n*(n+1)//2
op="dwon"
while True:
cnt+=1
if op=="dwon":
board[i][j]=cnt
if i==n-1 or board[i+1][j]!=0:
j+=1
op="right"
... |
9e86f03716df1bbc4db321cba16998f1e23f697f | didwns7347/algotest | /알고리즘문제/kakao test2.py | 338 | 3.515625 | 4 | def solution(expression):
op=[["+","-","*"],["+","*","-"]
["-","*","+"],["-","+","*"]
["*","-","+"],["*","+","-"]]
for x in range(6):
answer=max(answer,calc(expression,op[x]))
return answer
num=["DIA", "RUBY", "RUBY", "DIA", "DIA", "EMERALD", "SAPPHIRE", "DIA"]
... |
92c1f891ef3c72bd27fcf0853dbc04ca9cd80e2a | bwparry202/PHYS202-S14 | /SciPy/Integrators.py | 708 | 3.59375 | 4 |
import numpy as np
def trapz(func,a,b,N):
# My function will also take the arguments of the number of intervals,
# the start, and endpoint as well to make it better.
h = (b-a)/N
k = np.arange(1,N)
I = h*(0.5*func(a) + 0.5*func(b) + func(a+k*h).sum())
print "Trapezoidal rule returns:"+str(I)
... |
c4783825e477d40fd3b8791ced08ff68f437eebf | DidierPH/Portefolio | /Programming/Py3_3.py | 184 | 3.671875 | 4 | Leeftijd = eval(input('vul je leeftijd in'))
Paspoort = input('Ja of nee')
if Leeftijd >= 18 and Paspoort == 'ja':
print('je mag stemmen')
else : print('je mag niet stemmen')
|
51bcb2204eedf71f3a7cf0c7c5ec7c9612919904 | Genius98/HackerrankContestProblem | /Football Points.py | 356 | 4.28125 | 4 | #Create a program that takes the number of wins, draws and losses and calculates the number of points a football team has obtained so far.
WIN = int(input("Enter win match: "))
DRAWS = int(input("Enter draws match: "))
LOSSES = int(input("Enter losses match: "))
points = WIN * 3 + DRAWS * 1 + LOSSES * 0
print("F... |
c5aff568d37491c4ae5dcfd18ea651e6719a4e86 | chaochaocodes/leetcode | /top-interview-q/array/validSudoku.py | 2,129 | 3.796875 | 4 | # How to keep track of sub boxes?
# box_index = (row / 3) * 3 + col / 3
# Complexity Analysis
# Time complexity : O(1), one iteration over the board of 81 cells
# Space complexity : O(1)
# Solution with Dict and get()
class Solution:
def isValidSudoku(self, board: List[List[str]]) -> bool:
# initiate data... |
119f71b4a9d2cd894712bb261c4244f3b418f6cc | chaochaocodes/leetcode | /easy/majorityElement.py | 1,200 | 3.953125 | 4 | '''
Given an array nums of size n, return the majority element.
The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.
'''
nums1 = [3,2,3] #3
nums2 = [2,2,1,1,1,2,2] #2
# Approach 1: Brute force
# Time: O(n^2), 2 nested for loops... |
004b2a45d4a09f4ca2415e0d0caf2119e2bdb4c0 | chaochaocodes/leetcode | /top-interview-q/sorting-searching/isBadVersion.py | 749 | 3.921875 | 4 | # You are given an API bool isBadVersion(version) which returns whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.
n = 5
bad = 4
# Explanation:
# call isBadVersion(3) -> false
# call isBadVersion(5) -> true
# call isBadVersion(4) -> true
# Th... |
1d8b5955a12d5cad6232c13c9271aa2bcd1ed843 | chaochaocodes/leetcode | /top-interview-q/array/sortedSquares.py | 1,893 | 3.796875 | 4 | '''
Given an integer array nums sorted in non-decreasing order,
return an array of the squares of each number sorted in non-decreasing order.
Follow up: Squaring each element and sorting the new array is very trivial,
could you find an O(n) solution using a different approach?
'''
nums0 = [-4,-1,0,3,10] # squared [1... |
6f2e93a54fae4723ad19cade5ad40035a773e1af | chaochaocodes/leetcode | /hacker-rank/makeAnagram.py | 905 | 4.09375 | 4 | '''
Given two strings, a and b, that may or may not be of the same length, determine the minimum number of character deletions required to make a and b anagrams. Any characters can be deleted from either of the strings.
Example
a = 'cde'
b = 'dcf'
Delete e from a and f from b so that the remaining strings are cd and ... |
b389e0b38ede7d34c1ee9d3a69314062338bdcfd | chaochaocodes/leetcode | /top-interview-q/strings/strStr.py | 190 | 3.84375 | 4 | def strStr(haystack, needle):
if len(needle) < 1:
print(0)
else:
print(haystack.find(needle))
haystack = "hello"
needle = "ll"
# Output: 2
strStr(haystack, needle) |
e845f30caba70477cdc74e327e46cd9505577ca6 | chaochaocodes/leetcode | /top-interview-q/array/removeDuplicates.py | 930 | 3.75 | 4 |
# Two-Pointer
def removeDuplicates(nums):
i = 0
for j in range(1, len(nums)):
if nums[j] != nums[i]:
i += 1
# copy value of next unique number into position
# array size unchanged
nums[i] = nums[j]
return i + 1
# Two-Pointer variation
def removeDupl... |
7583c868d14b1e4d5957bb84955c61008dc9ed47 | gabrieloexle/mercury-ml | /mercury_ml/common/utils.py | 2,568 | 3.578125 | 4 | def singleton(TheClass):
""" decorator for a class to make a singleton out of it """
class_instances = {}
def get_instance(*args, **kwargs):
""" creating or just return the one and only class instance.
The singleton depends on the parameters used in __init__ """
key = (TheClass,... |
f28bc44abb7b5c9e7d2cea8fe635d3d1a07c12ca | SavvaShe/GBHW | /GBHW1_3.py | 158 | 3.703125 | 4 | n = int(input("Введите число n: "))
c = str(n)
a1 = c + c
a2 = c + c + c
s = n + int(a1) + int(a2)
print("Результат равен:", s) |
b1bb0b79678fe640e0e7d4fc22083df366ddb22d | XenonyxBlaze/Class-XII-hhw | /Class XII HHW Part B/q12.py | 97 | 3.75 | 4 | s = input("Enter comma seperated numbers ")
sl=s.split(',')
m=1
for i in sl:
m=m*int(i)
print(m) |
db4e5126ddcaa6a15a9dcf2ea8400b9dc8d1d9e1 | XenonyxBlaze/Class-XII-hhw | /classXII_hhw/q13.py | 219 | 4.09375 | 4 | def primeCheck(N):
isPrime = True
for i in range(2,N):
if N%i==0:
isPrime = False
return isPrime
e = int(input("Enter a digit "))
if primeCheck(e):
print("Number is prime")
else:
print("Number is not prime") |
03674fc55a3673b27488acc87a4593af1a6c7ea9 | XenonyxBlaze/Class-XII-hhw | /Class XII HHW Part B/q14.py | 275 | 4.03125 | 4 | l1 = input("Enter comma seperated values ").split(',')
l2 = input("Enter comma seperated values ").split(',')
print('''
Before Appending
L1 is {0}
L2 is {1}
'''.format(l1,l2))
for i in l2:
l1.append(i)
print('''
After Appending
L1 is {0}
L2 is {1}
'''.format(l1,l2)) |
5562c2ca36196c1b317c8fe708f92e27f028c6d0 | XenonyxBlaze/Class-XII-hhw | /Class XII HHW Part B/q21.py | 589 | 3.703125 | 4 | d1 = {}
d2 = {}
print('Input D1')
while True:
e = list(input("\nEnter a key value pair [comma-seperated] or q to continue ").split(','))
if e==['q']:
break
else:
d1[e[0]]=e[1]
print('Input D2')
while True:
e = list(input("\nEnter a key value pair [comma-seperated] or q to continue ").split(','))
if e==["q"]:... |
58259492c4b6afe2777d0d7a0864f673147119d8 | seemaacharya/Assignment-20-Random-Forest-Fraud_check | /Fraud_check.py | 1,873 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 26 15:28:09 2021
@author: DELL
"""
#Importing the libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#loading the dataset
df=pd.read_csv("Fraud_check.csv")
df.head()
#Creating dummy variable for Undergrad,Marital.Status,Urb... |
35375feccc7394f2365286cdb5a04706ab44fb02 | besenthil/search | /data_structures/linkedlist.py | 3,091 | 4.1875 | 4 |
class Node(object):
def __init__(self,data,next_node=None):
self.data=data
self.next_node = next_node
class LinkedList(object):
def __init__(self):
self.head = None
self.size = 0
self.tail=None
def append(self,data):
node = Node(data)
if self.head ... |
a2c52772ea1a82de8f95055b9a6391bde2ce2144 | besenthil/search | /data_structures/trees/dfs.py | 2,694 | 3.953125 | 4 | class Node(object):
def __init__(self,data,left_node=None,right_node=None):
self.data = data
self.left_node =left_node
self.right_node=right_node
TRAVERSAL = 'INORDER'
class BST(object):
def __init__(self,root=None):
self.root=root
def __inorder_traversal(self,root,node):
... |
43439135d05cab8a4d7bfb6b0e136c2ad5e6c30f | benjaminhechen/labfunctions | /lab_writing_programs.py | 491 | 3.96875 | 4 | def main():
print("This is a calculator.")
x = eval(input("How many calculations would you like to evaluate?"))
for i in range(x):
userInput = input("Enter a Mathematical Expression:")
evalUserInput = eval(userInput)
print(userInput + "=" + str(evalUserInput))
... |
c93d7d9629cd6086c047eadd9955a7eecab743d5 | karthikuncc/PythonPractice | /BinarySearchIterative.py | 378 | 3.953125 | 4 | def BinarySearchIterative(lst,item):
low=0
high=len(lst)-1
while low<=high:
mid=(low+high)//2
if lst[mid] == item:
return item
elif lst[mid]< item:
low = mid +1
else:
high=mid-1
return -1
test_list = [1,3,9,11,15,19,29]
test_val1 = 2... |
d15a8e7f58f64f97a90b7d7db7aacd0a10e3b8fb | karthikuncc/PythonPractice | /RobotMoveToBottom.py | 684 | 4.03125 | 4 |
def getPath(maze):
if maze == None or len(maze) == 0:
return None
path = []
if isPath(maze, len(maze)-1, len(maze[0])-1, path):
return path
return None
def isPath(maze, row, col, path):
#if out of bounds or not available, return
if col < 0 or row < 0 or not maze[row][col]:
... |
bd186d0fe82bcd22fce91ad108ac4b9849ad0f45 | mynameiszaurrr/telBotTruthOrDare | /ques_list.py | 1,423 | 3.5 | 4 | def questions(text_file):
question_list = []
with open(text_file, 'r') as file:
ques_list = list(file)
for i in ques_list:
question_list.append(i.strip())
return question_list
def questions_from_hard_list(text_file):
new = []
vul_ques_list = []
finally_ques = []
with op... |
e26fe639820d68b2ac0e5db5e517392a647d2311 | Burbon13/Leetcode-problems | /src/leetcode/remove_duplicates.py | 641 | 3.671875 | 4 | # https://leetcode.com/problems/remove-duplicates-from-sorted-list/
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def deleteDuplicates(self, head):
if head is None:
return None
last... |
172b668726c3b01455cbc5a7b96699be3550ec4c | Burbon13/Leetcode-problems | /src/leetcode/frog_jump.py | 1,024 | 3.84375 | 4 | # https://leetcode.com/problems/frog-jump/
from queue import SimpleQueue
class Solution:
def canCross(self, stones):
stone_set = set()
visited_set = set()
last_stone = stones[-1]
for stone in stones:
stone_set.add(stone)
stone_set.remove(0)
my_queue =... |
187bae11b5b68e7bbd5d678c707172465582e8d9 | Burbon13/Leetcode-problems | /src/leetcode/reversed_link_list_2.py | 1,307 | 3.953125 | 4 | # https://leetcode.com/problems/reverse-linked-list-ii/
# Definition for singly-linked list.
class ListNode:
def __init__(self, x, next):
self.val = x
self.next = next
class Solution:
def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode:
if head is None:
re... |
8c736003b6f4ab0d32850552dadb2d7cede55fb7 | Gromy4/Site | /Site/test_4.py | 506 | 3.515625 | 4 | import unittest
import re
import app
class Test_test4(unittest.TestCase):
def test_phone_True(self):
phone = ["8-931-233-49-72"]
for i in range (len(phone)):
regex=re.search(r'^([+]?\d{1,2}[-\s]?|)\d{3}[-\s]?\d{3}[-\s]?\d{2}[-\s]?\d{2}$',phone[i])
if (reg... |
0e515ef2d75a9678c2ef15a35d7e739636214efb | EiPoPoAung/python_exercises | /ex4.py | 538 | 3.796875 | 4 | cars=100
space_in_a_car =4.0
drivers =30
passengers =90
cars_not_driven=cars - drivers
cars_driven=drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car=passengers/cars_driven
print("There are",cars,"cars available.")
print("There are only",drivers,"drivers available")
print("There are well... |
3344f1f2cc8a86ae296cacfe7a9528dd3315649c | EiPoPoAung/python_exercises | /ex42.py | 628 | 3.53125 | 4 | class Animal(object):
pass
class Dog(Animal):
def __init__(self,name):
self.name=name
class Cat(Animal):
def __init__(self,name):
self.name=name
class Person(object):
def __init__(self,name):
self.name=name
self.pet=None
class Employee(Person):
def __init__(self,name,... |
7ae166319e2f527e69b0373d1eb268ba24e59869 | multiplexer/roman-numerals | /roman-nums-app/romannums/romannums/romannumerals.py | 3,884 | 3.984375 | 4 | import unittest
# Requires PEP8 checking for style -- automatically enabled in pycharm.
#
# This little library performs both the transform from roman numerals to decimals and decimals
# to roman numerals. The simpler transform is simply iterative adds and subtracts. The more difficult
# can be solved elegantly with... |
8cb2e9b16671c57c27b5a81ca15b3faab7519f2b | SalimRR/- | /10,7.py | 279 | 3.8125 | 4 |
a = "мой дядя самых честных правил, Когда не в шутку занемог, Он уважать себя заставил И лучше выдумать не мог"
print(' '.join([ word for word in a.split() if not word.startswith('м')]))
|
4479474f7ca993123329f7bbce39a12e26957d4a | SalimRR/- | /10,8.py | 348 | 3.5625 | 4 | a = str('Я хочу рабоать в следственном комитете Российской Федерации')
maximum = 0
for index, word in enumerate(a.split()):
if len(word) > maximum:
i = index
maximum = len(word)
print(f'Слово длиной {maximum} находится на позиции {i + 1}')
|
3049bb19a6bf4cc29084721a166ccd44bb2f3ffb | SalimRR/- | /9,3.py | 158 | 3.6875 | 4 | L = [3, 'hello', 7, 4, 'привет', 4, 3, -1]
print(L[0:5])
print(L[0:5:2])
print(L[:5])
print(L[4:])
print(L[::-1])
print(L[0:-3])
print(L[0::2])
|
f8e095325f58a1aa00b659cf173c623738f51014 | Gautam-MG/SL-lab | /pgm6.py | 581 | 4.5625 | 5 | #Concept: Use of del function to delete attributes of an object and an object itself
class Person:
def __init__(self,name,age):#This is the constructor of the class Person
self.name = name;
self.age = age;
p1 = Person("Suppandi",14)
print("\n Name of Person #1 is",p1.name)
print("\n age of a Person #1 is",p1.a... |
be1ca0facb53ba7344a3dc7e3e042c10e11d9b57 | shtoorman/python | /python/soket_tcp/closure.py | 248 | 3.90625 | 4 | def multiplier(n): # multiplier возвращает функцию умножения на n
def mul(k):
return n * k
return mul
mul3 = multiplier(3) # mul3 - функция, умножающая на 3
print(mul3(3), mul3(5)) |
cf8bd787c157fcda69bfc2d848c6f636298900b0 | karlabelazcos/Ejercicios-Python-Guia-de-examen- | /Ejerciocio 10 Multiplo.py | 589 | 4 | 4 | #Se almacena un numero y se convierte en entero.
numero=int(input("Dame un numero: "))
#Una variable booleana es una variable que sólo puede tomar dos posibles valores: True (verdadero) o False (falso).
#Si el residuo es 0 quiere decir que el numero es multiplo.
esMultiplo3=((numero%3)==0)
esMultiplo5=((numero%5)==0)
... |
4385af403951e9e22f579e95cd25e6b9a724287e | qj/lc | /206.py | 628 | 4.03125 | 4 | class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def __repr__(self):
to_print = ""
while self:
to_print += str(self.val)
self = self.next
return to_print
def reverseList(head: ListNode) -> ListNode:
prev =... |
c872d55efe41af30bb5f5447f9688794d3980823 | essty/Python | /movie_critic.py | 1,283 | 3.640625 | 4 | recent_movies = [('Iron Man 3', 78),
('The Great Gatsby', 48),
('Star Trek Into Darkness', 90),
('Oblivion', 56)]
movie_stars = [('Leonardo DiCaprio', 'The Great Gatsby'),
('Tom Cruise', 'Oblivion'),
('Robert Downey Jr.', 'Iron Man 3'),
... |
c644b536cbb2cfe3238100fedcd4d0cdc10f3ad0 | nitsas/codejamsolutions | /Osmos/runme.py | 2,338 | 3.5 | 4 | #!/usr/bin/env python3
"""
Osmos problem
for Google Code Jam 2013
Round 1B
Link to problem description:
https://code.google.com/codejam/contest/2434486/dashboard
author:
Chris Nitsas
(nitsas)
language:
Python 3.2.3
date:
May, 2012
usage:
$ python3 runme.py sample.in
or
$ runme.py sample.in
(where sample.in is the... |
228fe88ddb7a3ca6426e3061cd86b8cb59567b77 | nitsas/codejamsolutions | /Snapper Chain/runme.py | 2,284 | 3.578125 | 4 | #!/usr/bin/env python3
"""
Snapper Chain problem
for Google Code Jam 2010
Qualification Round
Link to problem description:
https://code.google.com/codejam/contest/433101/dashboard#s=p0
Author:
Chris Nitsas
(nitsas)
Language:
Python 3(.4)
Date:
April, 2015
Usage:
python3 runme.py input_file
"""
import ... |
d7ff8a93e519217286e9fc7d096237f2101d2485 | nitsas/codejamsolutions | /Lawnmower/runme.py | 1,859 | 3.734375 | 4 | #!/usr/bin/env python3
"""
Lawnmower problem
for Google Code Jam 2013
Qualification Round
Link to problem description:
https://code.google.com/codejam/contest/2270488/dashboard#s=p1
Author:
Chris Nitsas
(nitsas)
Language:
Python 3(.3)
Date:
May, 2012
Usage:
python3 runme.py input_file
"""
import sys
#... |
b3f875675b5e1e0f23938012c7dd95d78575f9bf | ianc12/Blokus | /src/Blockus/Piece.py | 5,508 | 3.859375 | 4 | '''
Created on Nov 20, 2020
@author: ian
'''
from enum import Enum
from copy import deepcopy
from Square import Color
'''
a piece is a list of origin based (x,y) tuples
'''
class Piece():
'''
Appends piece to list(l) if a piece with
all the same points is not already in the list
... |
dc6a9e9af7d5515a5c219b11e7b733f66f8d1985 | nummy/leetcode | /14/solution.py | 980 | 3.8125 | 4 | """
Description: Write a function to find the longest common prefix string amongst an array of strings.
Date: 2017.08-10 17:15
"""
class Solution(object):
def longestCommonPrefix(self, strs):
"""
:type strs: List[str]
:rtype: str
"""
if len(strs) == 0:
return ""
... |
eb920e9f0de524db868175ec191b9a196ff81020 | albertogcmr/data-analytics-examples-lessons-stuff | /tictactoe-javiluna/Tic_Tac_Toe__repaso_funciones_.py | 2,719 | 3.921875 | 4 | import json
CELL_EMPTY = " "
CELL_PLAYER_1 = "O"
CELL_PLAYER_2 = "X"
def initialize_game_state():
return {'turn': 0, 'board': initialize_board()}
def initialize_board():
"""
Creates a new empty board
:return: A board
"""
return [[CELL_EMPTY for _ in range(3)] for _ in range(... |
857ddac7caa21e00e3d4358e1028a0ed8c63f341 | albertogcmr/data-analytics-examples-lessons-stuff | /programacion-funcional-example/right/inputs.py | 366 | 3.65625 | 4 | MESSAGE_INPUT = '(f)orward, (r)ight, (l)eft, (q)quit: '
WRONG_INPUT = 'comando no reconocido'
def get_command():
''' returns 'l', 'r' or 'f' depending of the choice of the user '''
while True:
option = input(MESSAGE_INPUT)
if option in 'frlq':
break
else:
pri... |
833af72784c835b1c97cedf6bc5644ec2c78837b | albertogcmr/data-analytics-examples-lessons-stuff | /web-scraping/datamad0819/outputs.py | 376 | 3.71875 | 4 | def print_linea(name, lista):
dictionary = {"name": name.upper(), "subra": "-"*len(name), "paradas": "\n".join(lista)}
return "{name}\n{subra}\n{paradas}\n\n".format(**dictionary)
def print_file(dictionary):
with open("metro.txt", "w") as file:
for nombre, lista in dictionary.items():
... |
3b2a2dffcc9576f9176da56e8ffdd32e6c7f3ed9 | albertogcmr/data-analytics-examples-lessons-stuff | /programacion-funcional-example/right/classes.py | 780 | 3.59375 | 4 | from directions import turn
class Rober:
def __init__(self):
self.direction = 'N'
self.x = 0
self.y = 0
self.travelLog = [(self.x, self.y)]
def turnLeft(self):
self.direction = turn(self.direction, side='left')
def turnRight(self):
self... |
965261823bb67996dc8d9128d2fb6e4d5ba94d9b | gurpreetskairon/GHCND | /Analysis_2.py | 8,954 | 3.796875 | 4 | #################################################################################################
## Analysis Q2a : Write a Spark function that computes the geographical distance between two ##
## stations using their latitude and longitude as arguments. You can test this ##
## function... |
d50ae4e836fd15965f5afb9c88a5420b41fb75ea | Donsmith4090/final-intergration | /Final Integration.py | 14,268 | 3.84375 | 4 | # Fantasy Sports Calculator Main Project
# _Author_ Donovan Smith
print('Hello welcome to your fantasy sports calculator!')
circle = int(1)
while circle == 1:
sport = str(input("Would you like to calculate football, basketball, "
"or baseball? "))
def football():
"""
... |
b80de283611d7e537bdfee195853a3702484994b | justinb26/ProjectDocs | /Learn to Program with Python/3_Loops_and_Conditionals/3_for_loop.py | 239 | 3.984375 | 4 | ## Here, we use a 'for' loop to print a statement 100 times. But is it really doing what we want?
punishment = "I will not do repetitive work, I will let the computer do it for me"
for x in range(100):
print(str(x) + ". " + punishment) |
349d1065105defb7639526e112faf4cbb5f31e87 | rohanwayachal/coding_interviews | /stack/sortstack.py | 975 | 4.0625 | 4 | class Stack:
def __init__(self,size):
self.size=size
self.arr=[]
self.top=-1
def push(self,elem):
if self.size<=len(self.arr):
print("sorry, stack is full")
return False
else:
self.arr.append(elem)
self.top+=1
def pop(self):
if self.top==-1:
print("sorry... |
122ce533b91ca38868f0c31ec49c17162500453d | ProgressBG-Python-Course/ProgressBG-VMware-Python-Code | /lab3/comparison_operators.py | 1,306 | 4.21875 | 4 | """
Notes:
Lexicographical Comparison:
First the first two items are compared, and if they differ this determines the outcome of the comparison.If they are equal, the next two items are compared, and so on, until either sequence is exhausted
Comparison operator Chaining:
https://docs.python.org/3/referenc... |
82ca30c65bdf45c88ca2d6c0459ed91f93da1482 | ProgressBG-Python-Course/ProgressBG-VMware-Python-Code | /lab4/switch_case_emulation.py | 475 | 4.09375 | 4 | print("Select an action:")
print("1. Action 1")
print("2. Action 3")
print("3. Action 3")
user_choice = int(input('Enter a choice:'))
if user_choice == 1:
print('Action 1 is triggered')
elif user_choice == 2:
print('Action 2 is triggered')
elif user_choice == 3:
print('Action 3 is triggered')
# switch user_... |
302aa7810a6317e7c6d5e56f56198c962498dd9a | zonyitoo/sysubbs-apiserver | /server/basic/processor.py | 5,358 | 3.953125 | 4 | """
Basic classes for the Processor
"""
class Processor(object):
"""
~~~~
Basic Processor class
Processor is used to retrieve data from the server
and format it in a correctly api format(only contain 'data' part and is a dict object)
if request fail, it only return the error code,
and pass... |
14602b28696fa422b8a5941cbb18873bd385915d | pudenko/Python | /pudenkotimer.py | 282 | 3.8125 | 4 |
import time
def timer():
s = 0
m = 0
h = 0
while s<=60:
print (h, 'Hours', m, 'Minutes', s, 'Seconds')
time.sleep(1)
s+=1
if s == 60:
m+=1
s = 0
elif m ==60:
h+=1
m = 0
s = 0
if __name__ == '__main__':
timer()
|
4009dcc9a13c6359e0501b0ba234fb4244403b83 | bleehouse/daily-code | /python/manageEmployee.py | 412 | 3.65625 | 4 | with open("employee.txt") as f:
employees = f.read().splitlines()
# employees = [line.rstrip('\n') for line in open("employee.txt")]
candadite = input("Enter an employee name to remove:").strip()
if candadite in employees:
idx = employees.index(candadite)
employees = employees[:idx] + employees[idx+1:]
... |
20ee5bfce506c372a879e4ac8517bd81e06b6707 | bleehouse/daily-code | /python/searchProduct.py | 402 | 3.96875 | 4 | import json
with open('products.json') as data_file:
data = json.load(data_file)
def searchProduct():
product_name = input("What is the product name?")
for product in data["products"]:
if product_name.lower() == product["name"].lower():
print("match")
return
else:... |
9160b41e24e18609b63891eda14e2c028afbcd51 | bleehouse/daily-code | /python/wordsearch.py | 577 | 3.984375 | 4 |
def wordsearchintext(text, word, wordcount):
if text.find(word) > -1:
text = text[(text.find(word)+1):]
wordcount = wordcount + 1
return wordsearchintext(text, word, wordcount)
else:
return wordcount
number = wordsearchintext("textaaaaaaaaaaaaaaaabbbbaaaaatextaaaaatext", "a",... |
8443ae90b2b72e1f1a91c6fdc098df29528dd82d | USussman/rambots-a19 | /Classes/driver.py | 2,514 | 4.125 | 4 | #!/usr/bin/env python3
"""
Driver class module
Classes
-------
Driver
interface with wheels for holonomic drive
"""
from .motor import Motor
import math
class Driver:
"""
A class for driving the robot.
Methods
-------
drive(x, y, r)
drive with directional components and rotation.
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.