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 |
|---|---|---|---|---|---|---|
1b601202676058620ac2074468c4130d2260c80d | nato4ka1987/lesson2 | /4.py | 540 | 4.03125 | 4 | '''
Пользователь вводит строку из нескольких слов, разделённых
пробелами. Вывести каждое слово с новой строки.
Строки необходимо пронумеровать. Если в слово длинное,
выводить только первые 10 букв в слове.
'''
my_str = input("Enter string: ")
a = my_str.split(' ')
for i, el in enumerate(a, 1):
if len(el) >... |
9161708731404df8a8d2e943b97efefb3d4a72db | benjaminwilson/word2vec-norm-experiments | /modify_corpus_word_freq_experiment.py | 1,141 | 3.5 | 4 | """
Modifies an input text for the word frequency experiment according to the
parameters defined in parameters.py
Reads from stdin, writes to stdout.
Requires sufficient diskspace to write out the modified text at intermediate
steps.
"""
import os
import sys
from parameters import *
from functions import *
wf_experime... |
e4e58672f121baae0fbe3f9ba7fac94d072073cc | ObukhovVladislav/python-adv | /homeworks/210125/tast_1_example_4.py | 1,042 | 4.0625 | 4 | # def is_palindrome(num):
# if num // 10 == 0:
# return False
# temp = num
# reversed_num = 0
#
# while temp != 0:
# reversed_num = reversed_num * 10 + temp % 10
# temp = temp // 10
#
# if num == reversed_num:
# return True
# else:
# return False
# def i... |
95413238babbc337a678c4ec2267e7f23e7547ba | jaiswalIT02/pythonprograms | /Chapter-3 Loop/untitled0.py | 261 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 3 14:21:13 2020
1,-2,3,-4....
7@author: Tarun Jaiswal
"""
n=int(input("Enter the no="))
x=range(11,1,-1)
print(x)
for item in x:
if item % 2==0:
print(n*item)
else:
print(item*n)
|
7bb24992e011787e8ab538ed3cd9a133367fa1a6 | jaiswalIT02/pythonprograms | /GUI Applications/calculator2.py | 875 | 3.515625 | 4 | from tkinter import *
root=Tk()
root.geometry("500x500")
root.resizable(0,0)
x=IntVar()
y=IntVar()
z=IntVar()
e1=Entry(root,font=("Arial",25),textvariable=x)
e1.pack()
e2=Entry(root,font=("Arial",25),textvariable=y)
e2.pack()
# Sum of two integer
def show(op):
a=x.get()
b=y.get()
if(op==1):
c=a+b... |
8213167d8b5da70eea22723295f51802b2bb85e5 | jaiswalIT02/pythonprograms | /Preparation/leftrotate.py | 482 | 3.921875 | 4 | def leftrotate(str):
l=list(str)
n=len(l)
t=l[n-1]
for i in range(n-1,0,-1):
l[i]=l[i-1]
l[0]=t
result="".join(l)
return result
str="TIGER"
str=leftrotate(str)
print(str)
# left rotate
def leftrotate(str):
l=list(str)
n=len(l)
t=l[n-1]
for i in range(n-1,0,-1):
... |
e2dbfd38a74c82a59c3600939f61ecd1f7bd683e | jaiswalIT02/pythonprograms | /Chapter-3 Loop/Series_Pattern/fibbonacy no.py | 164 | 3.765625 | 4 | n=int(input("N="))
a=0
b=1
sum=0
count=1
print("Fibbonaci series=",end=" ")
while (count<=n):
print(sum,end=" ")
count+=1
a=b
b=sum
sum=a+b
|
aaff1f7f2e02e1fba60af4e0f426762f07ad211b | jaiswalIT02/pythonprograms | /Chapter-5 Functions/c_to_f function.py | 125 | 3.6875 | 4 | def c_to_f(c):
Farhenheite=(c*9/5)+32
return Farhenheite
n=int(input("Celcius="))
f=c_to_f(n)
print(f,"'F")
|
3e0b50298a6ec8476a4a6999431ad630d91cb9a0 | jaiswalIT02/pythonprograms | /Chapter-3 Loop/oddno.py | 67 | 3.84375 | 4 |
x=range(1,10,2)
print (x)
for item in x:
print(item,end=",")
|
bd9bfbad1ab769c34652f888c40cf20b672db239 | jaiswalIT02/pythonprograms | /Preparation/+_-_n.py | 206 | 3.546875 | 4 | l=[-9,-86,56,-9,88]
positive=[]
negative=[]
for i in l:
if i >= 0:
positive=positive+[i]
if i <= 0:
negative=negative+[i]
print("positive list=",positive,"\nNegative List=",negative) |
570e15d6d3b0868329b5bf43f91b1ae898fe30fb | jaiswalIT02/pythonprograms | /Chapter-3 Loop/prime.py | 212 | 3.96875 | 4 | a=int(input("A= "))
limit=a**.5
limit=int(limit)
isprime=True
for i in range(2,limit+1):
if a % i==0:
isprime=False
break
if isprime:
print("Prime")
else:
print("NotPrime")
|
f4cb92fdc77320fe94f6aa51e466ef65d328ac93 | jaiswalIT02/pythonprograms | /Preparation/noduplicate.py | 168 | 3.53125 | 4 | l=[1,3,4,4,1,5,5,6,7]
l.sort()
print(l)
n=len(l)
nonduplicatelist=[]
prev=l[0]
for i in range(1,n):
curr=l[i]
if curr==prev:
print(curr)
|
68ce7ccdaa5bd03c6b9b7df2734337d61d8f243a | jaiswalIT02/pythonprograms | /Preparation/Basic_Python Program/split.py | 185 | 3.734375 | 4 |
word="boy"
print(word)
reverse=[]
l=list(word)
for i in l:
reverse=[i]+reverse
reverse="".join(reverse)
print(reverse)
l=[1,2,3,4]
print(l)
r=[]
for i in l:
r=[i]+r
print(r) |
a2c5a0d70841b6f946b7a9c2ef5d0a2fb79292de | jaiswalIT02/pythonprograms | /Chapter-2 Conditional/Result.py | 468 | 3.71875 | 4 |
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 2 17:09:46 2020
@author: Tarun Jaiswal
"""
p=int(input("Physics="))
c=int(input("Chemistry="))
m=int(input("Mathematics="))
if p<40 or c<40 or m<40:
print("Result=Fail")
else:
print("Result=Pass")
Total= p+c+m
print("Total={0}".format(Total))
per=... |
9999ffcec508d80c632832af3106ac14e50ca149 | jaiswalIT02/pythonprograms | /Preparation/positive_list.py | 177 | 3.671875 | 4 | #find the positive no from list
l1= [10, -21, -4, -45, -66, 93]
positive=[]
for item in l1:
if item >= 0:
positive=positive+[item]
print("positive list=",positive)
|
b7d668fbb96eb76401def55fdfcece6c435a6569 | jaiswalIT02/pythonprograms | /Chapter-3 Loop/nestedpyramidloop.py | 377 | 3.5625 | 4 | '''
n=0
r=4
for m in range(1,r+1):
for gap in range(1,(r-m)+1):
print(end=" ")
while n!=(2*m-1):
print("0",end=" ")
n=n+1
n=0
print()
'''
n=int(input("Enter the n="))
k=(2*n)-2
for i in range(1,n):
for j in range(1,k):
print(end=" ")
k=k-1
for n in range(1,i+... |
09ceb85b032927f8481fae86450d4995f6501ce2 | jaiswalIT02/pythonprograms | /Chapter-9 Regression/market.py | 615 | 3.5 | 4 |
import pandas as pd
#from sklearn import linear_model
#from sklearn import tree
from sklearn.tree import DecisionTreeClassifier
#import pandas as pd
def readexcel(excel):
df=pd.read_excel(excel)
return df
df = readexcel("F:\\Excel2\\Market.xlsx")
#print(df)
x = df[['phy','chem' ]]
y = df['division']
pri... |
234ccf83fdd88ba514fd6290c3d2f3b4894f2eec | jaiswalIT02/pythonprograms | /Chapter-3 Loop/Triangle_Pattern/reverseabcpattern.py | 156 | 3.5625 | 4 |
n=5
x=1
for i in range(1,n+1,1):
for j in range(i,0,-1):
ch=chr(ord('A')+j-1)
print(ch,end="")
x=x+1
print()
|
422097e0e6295618159d1ed54dcb6575a1975647 | jaiswalIT02/pythonprograms | /Chapter-3 Loop/Forloop.py | 334 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 3 10:06:06 2020
@author: Tarun Jaiswal
"""
x1=range(10)
print(x1)
x2=range(2,10)
print(x2)
x3=range(2,10,3)
print(x3)
print("X1=",end="")
for item in x1:
print(item,end=",")
print("X2=")
for item in x2:
print(item,end=",")
print("X3=",end="")
for item in x3:
... |
f5d819cc1ab5956c324329169dace5be9525f826 | jaiswalIT02/pythonprograms | /Chapter-2 Conditional/Many Min.py | 354 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 2 12:29:09 2020
@author: Tarun Jaiswal
"""
a=int(input("A= "))
b=int(input("B= "))
c=int(input("C= "))
d=int(input("D= "))
min=a
variablename="b= "
if b<min:
variablename="b= "
min=b
if c<min:
variablename="c= "
min=c
if d<min:
variablename="d=... |
18f396d6cab808f43723e80981b90fef011898bd | jaiswalIT02/pythonprograms | /Chapter-3 Loop/series.py | 125 | 3.703125 | 4 |
x1=range(1,11)
print (x1)
for item in x1:
if item % 2==0:
print(item)
else:
print(-item)
|
6de8cc6eff5d84304b883dd0990c56aa761ebfd3 | lavindiuss/OnicaAssignment | /orm.py | 3,280 | 3.984375 | 4 | import sqlite3 as sq
# this function create a database with all required tables and pass if its already exist
"""
database for : database connection
database_cursor for : the cursor that controls the structure that enables traversal over the records in the database
"""
database = sq.connect("Books.db")
database_curs... |
1dfb56c8d3698deca428411bc6c5774a739d5241 | beccadsouza/System-Programming-and-Compiler-Construction | /ICG/infix.py | 1,441 | 3.703125 | 4 | infix = input("Enter infix expression : ").replace(' ','')
result = input("Enter resultant variable : ")
temp,string,operators = {},[],['+','-','*','/']
count,cp = 1,0
for i in range(len(infix)):
if infix[i] in operators:
string.append(infix[cp:i])
string.append(infix[i])
cp = i+1
string.a... |
d135bef0e2867c43ac4b429033e6f06d6c43d2a8 | mvondracek/VUT-FIT-POVa-2018-Pedestrian-Tracking | /camera.py | 1,426 | 3.546875 | 4 | """
Pedestrian Tracking
2018
POVa - Computer Vision
FIT - Faculty of Information Technology
BUT - Brno University of Technology
"""
from typing import Tuple
import numpy as np
class Camera:
def __init__(self, name: str, focal_length: float, position: Tuple[int, int, int],
orientation: Tuple[int,... |
013ecfc959125154250731c0d5df74f2a7849548 | ianmunoznunezudg/Particula | /mainclass.py | 451 | 3.546875 | 4 | from particula import Particula
class MainClass:
def __init__(self):
self.__particulas = []
def agregar_inicio(self, particula: Particula):
self.__particulas.insert(0, particula)
def agregar_final(self, particula: Particula):
self.__particulas.append(particula)
def imprimir(self... |
386696a7e854e5ca447e3032dacea9e7686d0485 | rbuhler/codigobasico | /Codigo_Python/e_par.py | 224 | 3.578125 | 4 | def e_par(valor):
resultado = True
resto = valor % 2
if resto > 0:
resultado = False
else:
resultado = True
return resultado
if e_par( 3 ):
print("E par")
else:
print("E Impar") |
c37d12eab7ccf6dd8caa974bc22e47f98ec5cc36 | shaman2527/Practicando-DNI | /js/python3/practica.py | 358 | 3.96875 | 4 | # n = int (input ("Enter an integer:"))
# sum = n * (n + 1) / 2
# print ("The sum of the first interger from 1 to" + str (n) + " is" + str (sum) )
# print(type(sum))
#Modulo Horas de Trabajos y Paga
hours = float (input("Horas de Trabajo:"))
cost = float (input("Introduce lo que cobras por hora:"))
pay = hou... |
436e5365c686922f6cc775cb441d6cb014a6103c | naveen882/mysample-programs | /last_day_quarter.py | 473 | 3.59375 | 4 | import datetime as dt
import calendar
month_quarter = [3,6,9,12]
user_date = dt.datetime.strptime('2017-12-31', "%Y-%m-%d").date()
if user_date.month in month_quarter:
last_day = calendar.monthrange(user_date.year,user_date.month)[1]
actual_date = dt.date(user_date.year,user_date.month, last_day)
if user_... |
335f5f0a83fb2c433d706e2b4640d408752508cf | naveen882/mysample-programs | /#longest_substring_in_a_given_string.py | 379 | 3.71875 | 4 | #longest substring in a given string
def longSubstring(s):
charSet = []
l=0
li = []
ss = ''
for r in range(len(s)):
if s[r] not in ss:
ss+= s[r]
else:
li.append(ss)
ss = ''
return li
ret = longSub... |
1deb78c1b1af35d46bf3fef07643a25ba7a1c5f1 | naveen882/mysample-programs | /classandstaticmethod.py | 2,569 | 4.75 | 5 | """
Suppose we have a class called Math then nobody will want to create object of class Math and then invoke methods like ceil and floor and fabs on it.( >> Math.floor(3.14))
So we make them static.
One would use @classmethod when he/she would want to change the behaviour of the method based on which subclass is call... |
9bee868b22f8f2077bdcc3e13e3edb333e0a6ab4 | CHemaxi/python | /001-python-core-language/005_tuples.py | 3,322 | 3.859375 | 4 | ## >---
## >YamlDesc: CONTENT-ARTICLE
## >Title: python tuples
## >MetaDescription: python tuples creating tuple, retrive elements, Operators example code, tutorials
## >MetaKeywords: python tuples creating tuple, retrive elements, Operators example code, tutorials tuple Methods,find,index example code, tutorials
## >A... |
fc8bde15b9c00120cb4d5b19920a58e288100686 | CHemaxi/python | /003-python-modules/008-python-regexp.py | 2,984 | 4.34375 | 4 | """ MARKDOWN
---
Title: python iterators and generators
MetaDescription: python regular, expressions, code, tutorials
Author: Hemaxi
ContentName: python-regular-expressions
---
MARKDOWN """
""" MARKDOWN
# PYTHON REGULAR EXPRESSIONS BASICS
* Regular Expressions are string patterns to search in other strings
* PYTHON Re... |
5b4b6d7602f2161ba8c400a6452067a729029f08 | CHemaxi/python | /001-python-core-language/003_strings.py | 7,001 | 3.859375 | 4 | ## >---
## >YamlDesc: CONTENT-ARTICLE
## >Title: python strings
## >MetaDescription: python string, Strings as arrays,Slicing Strings,String Methods,find,index example code, tutorials
## >MetaKeywords: python string, Strings as arrays,Slicing Strings,String Methods,find,index example code, tutorials
## >Author: Hemaxi
... |
85b893d3d8e664dd898e615e77adbcafc7a46938 | CHemaxi/python | /003-python-modules/016-python-json-files.py | 1,701 | 3.8125 | 4 | """ MARKDOWN
---
Title: Python JSON
Tags: Python JSON, Read Json, write Json, Nested json
Author: Hemaxi | www.github.com/learnpython
ContentName: python-json
---
MARKDOWN """
""" MARKDOWN
# Python JSON Module
* JSON is a data format widely used in REST web services, It stands for
javascript Object Notation.
* Here... |
e6516fb6c875b55303f5098988eb876d1749c739 | lucifersasi/pythondemo | /TELUSKO/selectionsort(min).py | 345 | 3.90625 | 4 |
def sort(nums):
for i in range(5):
minpos=i
for j in range(i,6):
if nums[j]<nums[minpos]:
minpos=j
temp=nums[i]
nums[i]=nums[minpos]
nums[minpos]=temp
print(nums) #to see the sorting process step by step
nums=[5,3,8,6,7,2]
sort(nums)
pri... |
6c82a4dd7590e0faac8b65e9011f621e44a01486 | lucifersasi/pythondemo | /AndreiNeagoi/testing/game_test/guess_game_test.py | 649 | 3.578125 | 4 | import unittest
from unittest import result
import guess_game
class TestMain(unittest.TestCase):
def test_guess_val(self):
answer = 1
guess = 1
result = guess_game.guess_run(guess, answer)
self.assertTrue(result)
def test_guess_wrongguess(self):
result = guess_game.... |
2ab350c02e54f7a4677eaa5b9b20b82a0fb1ec41 | garciazapiain/euler | /euler 5.py | 297 | 3.703125 | 4 | i=1
counter=1
x=300000000
divisible=0
while (counter<x):
while (i<21):
if counter%i==0: divisible=divisible+0
else:
divisible=1
break
i=i+1
if divisible==0: print ("Number divisible by",counter)
counter=counter+1
divisible=0
i=1
|
b530137226c3edb0245d2ccb10564baa0f4a78fa | peterbekins/MIT_OCW_6.00SC-Introduction-to-Computer-Science-and-Programming | /PS11/shortest_path.py | 11,174 | 4 | 4 | # PS 11: Graph optimization, Finding shortest paths through MIT buildings
#
# Name: Peter Bekins
# Date: 5/12/20
#
import string
from graph import *
#
# Problem 2: Building up the Campus Map
#
# Write a couple of sentences describing how you will model the
# problem as a graph)
#
def load_map(mapFilename):
"""
... |
128d708db97a5073cd55a968fd83a78c7149d89f | denisdenisenko/Python_proj_1 | /Project_1/Q1.py | 668 | 3.6875 | 4 | import re
def number_of_messages_in_inbox(given_file):
"""
Counting the number of messages in the inbox
:param given_file: .txt
:return: void
"""
file_to_handle = None
try:
file_to_handle = open(given_file)
except:
print('File cannot be opened:', given_file)
exi... |
91f1b436f1ef43d14ace8e53cabec0ab202c1b45 | hussein343455/Code-wars | /kyu 6/Split Strings.py | 612 | 4.09375 | 4 | # Complete the solution so that it splits the string into pairs of two characters.
# If the string contains an odd number of characters then it should replace
# the missing second character of the final pair with an underscore ('_').
# Examples:
# solution('abc') # should return ['ab', 'c_']
# solution('abcdef... |
1ea08b041a6b98de6c0a5c55e9ffb411bdd6d3bc | hussein343455/Code-wars | /kyu 5/Best travel.py | 2,218 | 4.03125 | 4 | # John and Mary want to travel between a few towns A, B, C ... Mary has on a sheet of paper a list of distances between these towns. ls = [50, 55, 57, 58, 60]. John is tired of driving and he says to Mary that he doesn't want to drive more than t = 174 miles and he will visit only 3 towns.
#
# Which distances, hence ... |
bcd7c3ee14dd3af063a6fea74089b02bade44a1c | hussein343455/Code-wars | /kyu 6/Uncollapse Digits.py | 729 | 4.125 | 4 | # ask
# You will be given a string of English digits "stuck" together, like this:
# "zeronineoneoneeighttwoseventhreesixfourtwofive"
# Your task is to split the string into separate digits:
# "zero nine one one eight two seven three six four two five"
# Examples
# "three" --> "three"
# "eightsix" ... |
e73d1193b1cb911c3681103d0ce3db4f44340176 | hussein343455/Code-wars | /kyu 4/Roman Numerals Helper.py | 2,229 | 3.796875 | 4 | # Create a RomanNumerals class that can convert a roman numeral to and
# from an integer value. It should follow the API demonstrated in the examples below.
# Multiple roman numeral values will be tested for each helper method.
#
# Modern Roman numerals are written by expressing each digit separately
# starting wi... |
d9684a8c4fcdc5d846fb8e83ba8a9d9adf6c79e9 | hussein343455/Code-wars | /kyu 7/Holiday III - Fire on the boat.py | 373 | 3.5 | 4 | # njoying your holiday, you head out on a scuba diving trip!
# Disaster!! The boat has caught fire!!
# You will be provided a string that lists many boat related items. If any of these items are "Fire" you must spring into action. Change any instance of "Fire" into "~~". Then return the string.
# Go to work!
... |
7d688699d912214c003e718f918a530d2acb637b | hussein343455/Code-wars | /kyu 7/Simple letter removal.py | 913 | 3.828125 | 4 | # In this Kata, you will be given a lower case string and your task will be to remove k characters from that string using the following rule:
#
# - first remove all letter 'a', followed by letter 'b', then 'c', etc...
# - remove the leftmost character first.
# For example:
# solve('abracadabra', 1) = 'bracadabra' ... |
fc6a2e2351529daf107a2996b8fc8052fe4a4384 | colson1111/Other-Python-Code | /Random-Code/bubble_sort.py | 446 | 3.640625 | 4 | import numpy as np
import time
lst = np.random.randint(low = 1, high = 100, size = 10000).tolist()
lst1 = lst
# bubble sort
def bubble_sort(lst):
for i in range(len(lst)-1,0,-1):
for j in range(i):
if lst[j] > lst[j + 1]:
c = lst[j]
lst[j] = lst[j + 1]
... |
967970e8265ab10e4677188c1a5fb54a3007faf2 | pchegancas/slabwork | /MySlabs.py | 875 | 3.578125 | 4 | """
Classes for slab reinforcement calculations
"""
class Slab():
"""
Model of a slab
"""
def __init__ (self, name: str, thk: float, concrete: float):
self.name = name
self.thk = thk
self.concrete = concrete
def __repr__ (self):
print(f'Slab({self.name}, {self.thk}, {self.concrete})')
class Band():
""... |
ab31c3e1a33bbe9ec2eb8ef5235b2206c022a8d7 | kritikhullar/Python_Training | /day1/factorial.py | 288 | 4.25 | 4 | #Fibonacci
print("-----FIBONACCI-----")
a= int(input("Enter no of terms : "))
def fibonacci (num):
if num<=1:
return num
else:
return (fibonacci(num-1)+fibonacci(num-2))
if a<=0:
print("Enter positive")
else:
for i in range(a):
print (fibonacci(i), end = "\t")
|
097662ada6fcf8db91c68ee4d6e44a883ec3662e | kritikhullar/Python_Training | /day1/fibonacci.py | 364 | 4.0625 | 4 | #Factorial
print("-----FACTORIAL-----")
a= int(input("Enter range lower limit : "))
b= int(input("Enter range upper limit : "))
fact=1
def factorial (number):
if number==0:
return 1
if number==1:
return number
if number!=0:
return number*factorial(number-1)
for i in range(a,b+1,1):
pri... |
77ceb0bc9596aa7d367d99a57e0ccb1552bdbfc6 | kngavl/my-first-blog | /python_intro.py | 274 | 4.0625 | 4 | #this is a comment
print("Hello, Django girls")
if -2>2:
print("Eat dirt")
elif 2>1:
print("hooman")
else:
print("y9o")
def hi(name):
print("hello " + name)
print("hi")
hi("frank")
girls = ["shelly", "anja", "terry"]
for name in girls:
print(name) |
a32357b7aabf7fd28844f10ed46e4c2517e94006 | ningmengmumuzhi/ningmengzhi | /练习/1.py | 113 | 3.8125 | 4 | num=123.456
print(num)
num='hello'
print('who do you think i am')
you=input()
print('oh yes! i am a' )(you)
|
77cbc21b55152a47401ca785f411064581fa6225 | ladsmund/msp_group_project | /koshka/scales/pythag_modes.py | 1,384 | 3.515625 | 4 | #!/usr/bin/python
from pythag_series import PythagSeries
class PythagMode:
def __init__(self, mode, frequency):
self.name = mode.lower()
self.freq = frequency
# An empty string does not transform to a different mode
if self.name == "":
self.tonic = 1
self... |
64e73cb395d25b53a166a6e491e70a7834c96aee | sajjadm624/Bongo_Python_Code_Test_Solutions | /Bongo_Python_Code_Test_Q_3.py | 2,330 | 4.1875 | 4 | # Data structure to store a Binary Tree node
class Node:
def __init__(self, data, left=None, right=None):
self.data = data
self.left = left
self.right = right
# Function to check if given node is present in binary tree or not
def isNodePresent(root, node):
# base case 1
... |
5c0555e29053979c65911d74f52aa7c39af15d37 | bucho666/pyrl | /test/testdice.py | 643 | 3.59375 | 4 | import unittest
from dice import Dice
class TestDice(unittest.TestCase):
def testRoll(self):
self.rollTest(Dice('2d6'), 2, 12)
self.rollTest(Dice('2d6+2'), 4, 14)
self.rollTest(Dice('2d6-3'), -1, 9)
def testString(self):
self.stringTest('2d6')
self.stringTest('2d6+2')
self.stringTest('2d6-... |
85749fe8ab6730a4505eaf14e2c5cbca7d92e655 | CIick/Week9 | /print(“Cost Calculation Program for Fibe.py | 373 | 3.78125 | 4 | import os
costPerFoot = .87
print(" Cost Calculation Program for Fiber Optics")
compName= input("Please enter the company name: ")
feet = input("Please enter the feet of fiber optics to install: ")
Val = (costPerFoot * int (feet))
print( "Cost calucation for the company", compName, "Fiber Optics per foot at", f... |
222798a5d6081bd5ef04addcc5e31e550c3f38f2 | Jacob1225/cs50 | /pset7/houses/import.py | 1,175 | 3.9375 | 4 | from sys import argv, exit
import csv
import cs50
# Verify user has passed in proper number of args
if len(argv) != 2:
print("Must provide one and only one file")
exit(1)
# Open file for SQLite
db = cs50.SQL("sqlite:///students.db")
# Open file and read it if argument check was passed
with open(argv[1], "r")... |
92156b23818ebacfa3138e3e451e0ed11c0dd343 | brianspiering/project-euler | /python/problem_025.py | 1,139 | 4.375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Solution to "1000-digit Fibonacci number", Problem 25
http://projecteuler.net/problem=25
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6... |
2ce7fc6a3a166efdbb4f87ddb75c827d9c805dd7 | brianspiering/project-euler | /python/problem_003.py | 863 | 3.875 | 4 | #!/usr/bin/env python
""" Solution to "Largest prime factor", aka Problem 3
http://projecteuler.net/problem=3
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
"""
n = 600851475143 # 13195 | 600851475143
def find_factors(n):
"My attempt"
return ... |
5448d28db97a609cafd01e68c875affe1f97723c | brianspiering/project-euler | /python/problem_004.py | 992 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Solution to "Largest palindrome product", aka Problem 4
http://projecteuler.net/problem=4
A palindromic number reads the same both ways.
The largest palindrome made from the product of two 2-digit numbers is
9009 = 91 × 99.
Find the largest palindrome made from the... |
bd009da4e937a9cfc1c5f2e7940ca056c1969ae5 | brianspiering/project-euler | /python/problem_024.py | 1,489 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Solution to "Lexicographic permutations", Problem 24
http://projecteuler.net/problem=24
A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or... |
5e2ae02f6553cbe7c31995ba76abf564c596d346 | serenechen/Py103 | /ex6.py | 767 | 4.28125 | 4 | # Assign a string to x
x = "There are %d types of people." % 10
# Assign a string to binary
binary = "binary"
# Assign a string to do_not
do_not = "don't"
# Assign a string to y
y = "Those who knows %s and those who %s." % (binary, do_not)
# Print x
print x
# Print y
print y
# Print a string + value of x
print "I sai... |
3a3717209ab762e0a98678a58553014a16e0ec3b | Allen-Maharjan/Assignment-II-Control-Statement | /No_10.py | 741 | 4.03125 | 4 | #changing camelcase to snake case and kebab case1
def transformer(sample,seperator):
final_answer = ''
if seperator == 1:
for i in sample:
if i.isupper() == True:
final_answer += "_"
final_answer += i.lower()
print(f'Snakecase = {final_answer[1::]}')
... |
bf98158d76a44a21dee04e7de1f54047b8b35184 | Allen-Maharjan/Assignment-II-Control-Statement | /No_18.py | 284 | 3.59375 | 4 | import json
class Person():
def __init__(self, name, age):
self.name = name
self.age = age
person_string = '{"name": "Allen", "age": 21}'
person_dict = json.loads(person_string)
print(person_dict)
person_object = Person(**person_dict)
print(person_object.name)
|
690bffde0d59c3593879d1b7ea1bef2cd2c37301 | Naminenisravani/guvi | /positive.py | 133 | 4.15625 | 4 | x=int(input('INPUT'))
if x>0:
print("x is positive")
elif (x==0):
print("x is equal to zero")
else:
print("x is neative")
|
23f9d9fc5134daddae2aa9bc7c15853370b464ae | EddyScript/Git-With-Eddy | /Calculator.py | 1,092 | 4.28125 | 4 | # Assignment 1---------------------------------------------
def calculator():
first_number = int(input("Enter a number: "))
operator = input("Enter an operator: ")
ops = ["+","-","*","/"]
if operator in ops:
second_number = int(input("Enter another number: "))
else:
print("Sorry," + ... |
87b1700a53f458dc06fd245bcb4d041f45d1d969 | BronyPhysicist/BaseballSim | /player_pkg/bats_and_throws.py | 803 | 3.59375 | 4 | '''
Created on Apr 03, 2017
@author: Brendan Hassler
'''
from enum import Enum
from random import random
class Bats(Enum):
LEFT = "Left"
RIGHT = "Right"
SWITCH = "Switch"
def __str__(self): return str(self.value)
class Throws(Enum):
LEFT = "Left"
RIGHT ... |
6d70d520f69c0a7e7109a14410f7eaca60e52e36 | nhantrithong/Sandbox | /prac3 - scratch exer 2.py | 482 | 4 | 4 | def main():
score = get_score()
while score < 0 or score > 100:
print("Invalid score, please re-enter an appropriate value")
score = float(input("Enter your score: "))
if score < 50:
print("This is a bad score")
elif score > 50 and score < 90:
print("This is a passable sc... |
bd91b70078d5e7ea12a584d83f9a16071806ed04 | AaronShabanian/PythonPrograms | /friends.py | 1,248 | 3.953125 | 4 | file=open("people.txt",'r')
while True:
dict={}
finalList=[]
for line in file:
line=line.rstrip("\n")
list=line.split(",")
name=list[0]
del list[0]
values=list
values=set(values)
dict.update({name:values})
for key in dict:
prin... |
eb1491b0d3efc61f2462d17e314244fe5c95a352 | charliechoong/sudoku_solver | /CS3243_P2_Sudoku_25.py | 10,478 | 3.546875 | 4 | import sys
import copy
import time
from Queue import PriorityQueue
# Running script: given code can be run with the command:
# python file.py, ./path/to/init_state.txt ./output/output.txt
class Sudoku(object):
def __init__(self, puzzle):
self.puzzle = puzzle
# all empty squares in input p... |
6dee0f8aff74d29aed5f6384ad958dae27ba3a52 | ALaDyn/Smilei | /validation/easi/__init__.py | 29,631 | 3.609375 | 4 | class Display(object):
"""
Class that contains printing functions with adapted style
"""
def __init__(self):
self.terminal_mode_ = True
# terminal properties for custom display
try:
from os import get_terminal_size
self.term_size_ = get_t... |
272f71dcc72f166a4bf938c7d24c2fcfc156fef3 | amshapriyaramadass/learnings | /Hackerrank/numpy/array.py | 250 | 3.609375 | 4 | import numpy as np
def arrays(arr):
# complete this function
# use numpy.array
a = np.array(arr,dtype='f')
return(a[::-1])
if __name__ =="__main__":
arr = input().strip().split(' ')
result = arrays(arr)
print(result)
|
14c8a6e8dbdb673d146e92f1d3812523ce1b556f | amshapriyaramadass/learnings | /Python/Exercise Files/Ch2/classes_start.py | 565 | 3.96875 | 4 | #
# Example file for working with classes
#
class myWheels():
def wheel1(self):
print("wheel is alloy")
def wheel2(self,SomeString):
print("this is steel rim" + SomeString)
class myCar(myWheels):
def wheel1(self):
myWheels.wheel1(self)
print("this is car wheel dia 30inch")
def wheel2(self,so... |
dc66d84ad39fb2fe87895ca376652e9d95781326 | amshapriyaramadass/learnings | /Hackerrank/Interviewkit/counting_valley.py | 789 | 4.25 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'countingValleys' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
# 1. INTEGER steps
# 2. STRING path
#Sample Input
#
#8
#UDDDUDUU
#Sample Output
#1
#
def cou... |
b003a3afa4758e8696090f05bdba608f5ea5f10b | mazalkov/Python-Principles-Solutions | /Online status.py | 278 | 3.625 | 4 | # https://pythonprinciples.com/challenges/Online-status/
def online_count(dictionary):
number_online = 0
for i, (key, value) in enumerate(dictionary.items()):
if value == 'online':
number_online += 1
return number_online
|
d8fa7c098496d84e58e0a49577c7c866f1f60f2c | flyfish1029/pythontest | /studytext/while_mj.py | 235 | 4 | 4 | #-*- coding: UTF-8 -*-
numbers = [12,37,5,42,8,3]
event = []
odd = []
while len(numbers)>0:
number = numbers.pop()
if(number % 2 == 0):
event.append(number)
else:
odd.append(number)
print(event)
print(odd)
|
de5d15d0b7c4c9c8e4113c2abaf3463af7a368af | andremourato/travian_bot | /utils.py | 256 | 3.59375 | 4 | from datetime import datetime, timedelta
def add_seconds_to_datetime_now(seconds):
"""Add seconds to current timestamp and return it."""
future_date = datetime.now() + timedelta(seconds=seconds)
return future_date.strftime('%H:%M %d-%m-%Y')
|
b51bed97a9cb40110ca0d7a897f4e2d27b1e1d5e | bobosod/From_0_learnPython | /chapter4_2.py | 226 | 3.921875 | 4 | list = ["apple", "banana", "grape", "orange", "grape"]
print(list)
print(list[2])
list.append("watermelon")
list.insert(1,"grapefruit")
print(list)
list.remove("grape")
print(list)
print(range(len(list)))
help(list)
|
e634301ac092a01c6cfc61fcd9215d66f65d4deb | tutorials-4newbies/testing101 | /test_phone_validator.py | 1,088 | 3.5625 | 4 | import unittest
from lib import CellPhoneValidator
# This is the spec!
class PhoneValidatorTestCase(unittest.TestCase):
def test_phone_validator_regular_number(self):
value = "0546734469"
expected_true_result = CellPhoneValidator(value).is_valid()
self.assertTrue(expected_true_result)
... |
543832a8bac0de76fc71f18de41e352d2893860f | basseld21-meet/meet2019y1lab3 | /debugging.py | 965 | 3.5 | 4 | Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license()" for more information.
>>> ##In order complete this challenge you need to debug the following code.
##It may be easier to do so if you improve the code qu... |
f834c6ebc4442b3e4c945003704b4ec15f353289 | lin-compchem/qmmm_neuralnets | /qmmm_neuralnets/input/filter.py | 3,268 | 3.53125 | 4 | """
This file contains methods for selecting feature from input vectors
"""
import numpy as np
def do_pca(bfs, n_components):
"""
This is the code from my PCA experiment. Should do again and report
results in the manual
Params
------
bfs: list of ndarrays
The basis function arrays
... |
795d5db9f77b07f2680468da5694dfd8c37bf234 | klinok9/learning_python | /Глава4.py | 1,361 | 3.53125 | 4 | # char = ['w', 'a', 's', 'i', 't', 'a', 'r']
# out = ''
# length = len(char)
# i = 0
# while (i< length):
# out = out +char[i]
# i= i+1
# length = length * -1
# i=-2
# while (i >= length):
# out = out + char[i]
# i = i-1
# print(out)
# smothies = [1,2,3,4,5]
# length = len(smothies)
# for i in range(len... |
ee3ec39130ee54a0cfa72eb81d158a027840f222 | anuriq/parallels-fibonacci | /src/fibonacci.py | 182 | 4.1875 | 4 |
def fibonacci_number(n):
n = int(n)
if n == 1 or n == 2:
return 1
else:
result = fibonacci_number(n - 1) + fibonacci_number(n - 2)
return result
|
35775689bab1469a42bae842e38963842bf54016 | scottherold/python_refresher_8 | /ExceptionHandling/examples.py | 731 | 4.21875 | 4 | # practice with exceptions
# user input for testing
num = int(input("Please enter a number "))
# example of recursion error
def factorial(n):
# n! can also be defined as n * (n-1)!
""" Calculates n! recursively """
if n <= 1:
return 1
else:
return n * factorial(n-1)
# try/except (if ... |
293770c85b55ca8be91305a5d6a005962dddee4a | CelvinBraun/human_life_py | /life_turtle.py | 1,217 | 3.6875 | 4 | from turtle import Turtle
START_X_CORR = -450
START_Y_CORR = 220
STEPS = 8
SIZE = 0.3
class Life:
def __init__(self, age, years):
self.start_x = START_X_CORR
self.start_y = START_Y_CORR
self.steps = STEPS
self.size = SIZE
self.weeks = round(years * 52.1786)
self.ag... |
a4721adc85bf2e62d8cd37cf97f1dc2ef9e4ffff | inaju/thoughtsapi | /test_api.py | 2,010 | 3.578125 | 4 | import requests
class TestApi:
def __init__(self):
self.user_url = "http://127.0.0.1:8000/auth/"
self.user_profile_url = "http://127.0.0.1:8000/auth/users/"
self.user_profile_data = "http://127.0.0.1:8000/api/accounts/"
self.user_data = {
'username': 'ibrahim',
... |
5548acf94dcf476343655ef2947fb9b6d5e5968c | Philippe-Boddaert/Philippe-Boddaert.github.io | /premiere/bloc1/chapitre-06/corrige.py | 6,984 | 3.8125 | 4 | #!/usr/bin/env python3
# Author : Philippe BODDAERT
# Date : 19/12/2020
# License : CC-BY-NC-SA
from enquete import Enquete
def est_anagramme(mot1, mot2):
'''
Indique si 2 mots sont anagrammes l'un de l'autre
;param mot1: (str) un mot
:param mot2: (str) un mot
;return: (bool) True si les 2 mots so... |
5d11169ca662b27c93169fe9c48338b339ed9f33 | Allykazam/algorithms_tools | /list_manip.py | 678 | 4.03125 | 4 | def oddNumbers(l, r):
# Write your code here
odd_arr = []
for num in range(l, r + 1):
if num % 2 != 0: #even numbers would be == instead of !=
odd_arr.append(num)
return odd_arr
print(oddNumbers(0, 12))
def rotLeft(a, d):
for _ in range (d):
front_val = a.pop(0)
... |
7106bb0336835310ea40ecaf3cd4a29f1f231269 | HemlockBane/simple-banking-system | /card_db.py | 3,360 | 3.5 | 4 | import sqlite3 as sq3
class Db:
def __init__(self):
self.table_name = "card"
self.db_name = "card.s3db"
self.connection = self.init_db()
def init_db(self):
create_table_query = f'''create table if not exists {self.table_name} (
id INTEGER PRIMARY K... |
52c84ab4101801d394c4c8ee1dc3621e54b8285c | Reyes2777/100_days_code | /python_class/exercise_1.py | 515 | 4.15625 | 4 | #Write a Python program to convert an integer to a roman numeral.
class Numbers:
def int_to_roman(self, number_i):
value = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
roman_numbers = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
roman_num = []
f... |
13578b6a7bdcfe4fede9f52f79b48f5044285299 | Alessandro100/x-puzzle-solver | /xpuzzle.py | 7,651 | 3.640625 | 4 | class XPuzzle:
#sample input: 1 0 3 7 5 2 6 4
def __init__(self, rows, cols, input):
self.rows = rows
self.cols = cols
self.arr = []
# we keep track of the 0 position to increase the performance of our algorithm
self.zero_position = (0,0) #row, column
self.__init... |
9aeb414b897c3948dfe4313d40b30bd7471a3d49 | priyal-jain-84/Projects | /sudoku project.py | 2,429 | 4.25 | 4 | # Sudoku project using backtracking method #
board=[
[7,3,0,9,5,0,0,0,0],
[2,0,0,6,7,0,5,8,0],
[0,0,5,0,1,0,4,0,0],
[1,9,0,0,6,3,2,0,5],
[0,4,0,0,0,0,6,0,0],
[5,6,8,2,0,7,0,0,0],
[0,2,0,0,8,1,3,0,0],
[0,0,1,0,0,9,7,6,0],
[0,7,0,5,2,0,8,0,9]
... |
dd466737b8abb26679212eceabda0ae7114c2495 | stevenbrand99/holbertonschool-higher_level_programming | /0x05-python-exceptions/3-safe_print_division.py | 260 | 3.5625 | 4 | #!/usr/bin/python3
def safe_print_division(a, b):
try:
inside_result = a / b
except (ZeroDivisionError, TypeError):
inside_result = None
finally:
print("Inside result: {}".format(inside_result))
return inside_result
|
8923477b47a2c2d283c5c4aba9ac797c589fbf7e | nobin50/Corey-Schafer | /video_6.py | 1,548 | 4.15625 | 4 | if True:
print('Condition is true')
if False:
print('Condition is False')
language = 'Python'
if language == 'Python':
print('It is true')
language = 'Java'
if language == 'Python':
print('It is true')
else:
print('No Match')
language = 'Java'
if language == 'Python':
print('It is Python')
... |
645074e3b2e1274fb0380182c95124df18ce2a89 | liamliwanagburke/ispeakregex | /politer.py | 8,060 | 4 | 4 | '''Provides a 'polite' iterator object which can be sent back values and which
allows sequence operations to be performed on it.
exported:
Politer -- the eponymous generator/sequence class
@polite -- decorator that makes a generator function return a Politer
'''
import functools
import itertools
import collec... |
6a22f2e3cd18309c2b74becebafa184467ce9b87 | Piper-Rains/cp1404practicals | /prac_05/hex_colours.py | 591 | 4.375 | 4 |
COLOUR_CODES = {"royalblue": "#4169e1", "skyblue": "#87ceeb", "slateblue": "#6a5acd", "slategray1": "#c6e2ff",
"springgreen1": "#00ff7f", "thistle": "#d8bfd8", "tomato1": "#ff6347", "turquoise3": "#00c5cd",
"violet": "#ee82ee", "black": "#000000"}
print(COLOUR_CODES)
colour_name = inpu... |
e8893f7e629dede4302b21efee92ff9030fe7db2 | Piper-Rains/cp1404practicals | /prac_05/word_occurrences.py | 468 | 4.25 | 4 |
word_to_frequency = {}
text = input("Text: ")
words = text.split()
for word in words:
frequency = word_to_frequency.get(word, 0)
word_to_frequency[word] = frequency + 1
# for word, count in frequency_of_word.items():
# print("{0} : {1}".format(word, count))
words = list(word_to_frequency.keys())
words.s... |
0f6e1b50046506c97b52e79e6108bef72b64aa9f | siva237/python_classes | /numpys.py | 990 | 3.75 | 4 | # Numpy is the core library for scientific computing in Python.
# It provides a high-performance multidimensional array object, and tools for working with these arrays.
import numpy
# a=numpy.array([1,2,3]) # rank 1 array
# print(a.shape) # (3,)
# print(type(a)) # <class 'numpy.ndarray'>
# b=numpy.... |
93aff832710c79b6a88e20cdd1e6f8d0c50b1e81 | siva237/python_classes | /copy_ex.py | 343 | 3.6875 | 4 | import copy
# s={1,2,3,4}
# s1=copy.deepcopy(s)
# print(s1 is s)
# s.add(10)
# print(s)
# print(s1)
# s={1,2,3,4}
# s1=copy.copy(s)
# print(s1 is s)
# s.add(10)
# print(s)
# print(s1)
# l=[1,2,3,4]
# l1=copy.copy(l)
# print(l1 is l)
# l.insert(1,22)
# print(l)
# print(l1)
l=[1,2,3,4]
l1=l
print(l1 is l)
l.insert(1... |
a7554b02548c913fcf50cb1a1b7c621a646cf06a | siva237/python_classes | /read_write_append/most_occuring_words.py | 198 | 3.78125 | 4 | # file = open("doc.txt", 'w')
import collections
words = open("doc.txt", 'r').read()
list_of_words = str(words).split(" ")
words1 = collections.Counter(list_of_words).most_common(10)
print(words1) |
6abf00b079ceab321244dbe606f05bac9a347be0 | siva237/python_classes | /Decorators/func_without_args.py | 1,331 | 4.28125 | 4 | # Decorators:
# ----------
# * Functions are first class objects in python.
# * Decorators are Higher order Functions in python
# * The function which accepts 'function' as an arguments and return a function itslef is called Decorator.
# * Functions and classes are callables as the can be called explicitly.
# def hel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.