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 |
|---|---|---|---|---|---|---|
56def9ae13aa0af94fc1529f2d16879c191b4c9b | pr0d33p/PythonIWBootcamp | /Functions/4.py | 171 | 4.34375 | 4 | def reverseString(string):
strToReturn = ""
for letter in string:
strToReturn = letter + strToReturn
return strToReturn
print(reverseString("Hello")) |
cac747c0a961bd11f51532dff163f98c48409ae0 | pr0d33p/PythonIWBootcamp | /Data Types/4.py | 148 | 3.625 | 4 | string1 = "abc"
string2 = "xyz"
newString1 = string2[:2] + string1[2:]
newString2 = string1[:2] + string2[2:]
print(newString1 + ' ' + newString2) |
5761bda1dc5763f3e0acae42b4b98c928c84fb19 | pr0d33p/PythonIWBootcamp | /Functions/7.py | 422 | 4.21875 | 4 | string = "The quick Brow Fox"
def countUpperLower(string):
lowerCaseCount = 0
upperCaseCount = 0
for letter in string:
if letter.isupper():
upperCaseCount += 1
elif letter.islower():
lowerCaseCount += 1
print("No. of Upper case characters: {}".format(upperCase... |
cb889b684e3938c254db763db2fa1481d24ba321 | pr0d33p/PythonIWBootcamp | /Functions/20.py | 198 | 3.796875 | 4 | def interSection(arr1, arr2):
result = list(filter(lambda x: x in arr1, arr2))
print("Intersection : ",result)
arr1 = [1, 3, 5, 7, 9]
arr2 = [2, 3, 5, 7, 11]
interSection(arr1,arr2) |
c5c7b363243db27bacf7ff7405229cf0edf77018 | jodaruve/Parcial | /ejercicio 68.py | 818 | 4.125 | 4 | ## 68
print("Este programa le mostrara la cantidad de nmeros positivos, negativos, pares, impares y multiplos de ocho ingresados. Recuerde que cuando no desee ingresar ms nmeros debe escribir -00")
t_positivos=0
t_negativos=0
t_pares=0
t_impares=0
mult=0
num=float(input("Por favor ingrese un numero "))
while num!=-00:
... |
401c8bc1ab4d1e994e845ce0d4b4c5b3988b36b8 | jodaruve/Parcial | /ejercicio 18.py | 267 | 3.984375 | 4 | ## 18
print("Este programa le mostrara la fuerza entre dos objetos")
ac=float(input("Por favor ingrese la aceleracion en m/s^2 "))
masa=float(input("Por favor ingrese la masa en kg "))
fuerza= masa*ac
print("La fuerza entre los dos objetos es de:", fuerza, "Newtons") |
01dec19b0393e8c75d308dd804651d77b6e9d3e7 | jodaruve/Parcial | /ejercicio 70.py | 189 | 3.921875 | 4 | ## 70
print("Este programa convertir el numero decimal ingresado a binario")
num=int(input("Por favor ingrese el numero decimal "))
b=bin(num)
print("El numero", num, "en binario es", b)
|
a105b08c802d0592a2a60e4826e2a8fc726b6102 | jodaruve/Parcial | /ejercicio 28.py | 304 | 4.09375 | 4 | ## 28
print("Este programa calculara si el numero ingresado es positivo o negativo")
num=float(input("Por favor ingrese un numero "))
if num == 0:
print("El numero", num, "no es ni negativo ni positivo")
elif num > 0:
print("El numero", num, "es positivo")
else:
print("El numero", num, "es negativo") |
c283ddf99673e2669e5c3c017a7a726fa3837dbc | jodaruve/Parcial | /ejercicio 20.py | 205 | 3.6875 | 4 | ## 20
suma1=0
suma2=0
suma3=0
num=int(input("Por favor ungrese un numero "))
suma1=num*1
suma2=num*11
suma3=num*111
suma=suma1+suma2+suma3
print(suma1)
print(suma2)
print(suma3)
print("Su suma es:", suma)
|
61db81fd1c92e8688bc4f0e3c007ed19a1da1ca7 | jodaruve/Parcial | /ejercicio 44.py | 407 | 3.875 | 4 | ## 44
print("Este programa calculara si los nmeros ingresados estn entre 0 y 5")
num1=int(input("Por favor ingrese un numero "))
num2=int(input("Por favor ingrese otro numero "))
if num1 and num2>5:
print("Los numeros", num1,num2, "no estan entre 0 y 5")
elif num1 and num2<0:
print("Los numeros", num1,num2, "no est... |
9cde3ab6135e2e0957a7e10870747caaa38495ea | jodaruve/Parcial | /ejercicio 26.py | 447 | 4.0625 | 4 | ## 26
print("Este programa mostrara la funcion de las condicionales")
c1=True or False
c2=False or False
c3=True and True
c4=False and True
c5=(False and False) or (True and True)
c6=(False or False) and (True and True)
print("True or False es", c1)
print("False or False es", c2)
print("True and True es", c3)
print("Fa... |
590c4bfbffa1f55ac2c905ab55ea4be97f45ad84 | jodaruve/Parcial | /ejercicio 65.py | 521 | 3.90625 | 4 | ## 65
sum_p=0
sum_i=0
i=0
c_p=0
c_i=0
print("Este programa le mostrara el promedio de los nmeros pares y impares ingresados")
cant=int(input("Por favor digite la cantidad de nmeros que va a ingresar "))
while i<cant:
i=i+1
num=float(input("Por favor ingrese el numero "))
if num%2==0:
c_p=c_p+1
sum_p=sum_p... |
ab41f792a4b168f5390c3e14e24e079161eca2d2 | jodaruve/Parcial | /ejercicio 29.py | 419 | 4.0625 | 4 | ## 29
print("Este programa calculara si el numero ingresado es par-positivo, par-negativo, impar-positivo o impar-negativo")
num=float(input("Por favor ingrese un numero "))
if num > 1:
if num % 2 == 0:
print("El numero", num, "es par positivo")
else:
print("El numero", num, "es impar positivo")
elif num % 2 == 0... |
2df2b53ec9f62cb221fe8ac78e13b9d14a9ad3df | NurbekSakiev/Essential_Algorithms | /merge_Sort.py | 550 | 4.15625 | 4 | // Algorithms
// Merge Sort
// author: Nurbek Sakiev
def mergeSort(list_):
if (len(list_) <= 1):
return list_
mid = len(list_)//2
first = mergeSort(list_[:mid])
second = mergeSort(list_[mid:])
return list(merge(first,second))
def merge(list1, list2):
i=j=0
last = []
while (i <len(list1) and j<len(list2)):
... |
8ec919cee9c1ce1c5a1a92e94e661e153449b5cd | axisonliner/Python | /del_files.py | 1,854 | 4.125 | 4 | # Script for deleting files from a folder using the command line:
# command line: python del_files.py arg1 arg2
# - arg1 = folder path
# - arg2 = file extention
# Example: python del_files.py C:\Desktop\folder_name .exr
import os
import sys
import math
def get_size(filename):
st = os.stat(filename)
... |
77c3e1566009c4471f1b24434afe50edbb190281 | axisonliner/Python | /codewars/Unique In Order.py | 707 | 3.734375 | 4 | from itertools import groupby
def unique(s):
# print len(s)
# print s
# print s[1:] + s[-1:]
# if s == [] or s == '':
# return ['A']
# return [x for x, y in zip(s, s[1:] + s[:1]) if x != y or len(s) == 1]
# return cmp(s, s[1:] + s[:1])
# -------------------------
# uniq = None
#... |
20737d21a09fdec052729f8a2fee18ed8aa90395 | sonumandal95/pyprog | /naming_prog.py | 790 | 4.03125 | 4 | """
Scope:
1.Enter and 10 names in list
2.Title case them
3.Remove duplicates
4.Sort those name is acending order of their first name
"""
name_list=[]
title_case_name=[]
duplicates_name=[]
final_name_list=[]
for i in range(5):
user_name=input("Enter a name : ")
name_list.append(user_name)
for list_name in name... |
120a097a220eb20cdedc4f3a4051e17e0f4fdcce | Albedo1996/curso-python | /cadena.py | 494 | 3.984375 | 4 | #dado el texto 'esto es una prueva ' imprimir una cadena formateada de la sig. manera:
#'esto es una prueva '
#-imprimir cuentas letras 'e' tiene la cadena
#-capitalizar cadena
#-imprir longitud de cadena
#-reemplazar
dato = (input("Ingrese un texto: "))
fruta = dato
cuenta = 0
for carac in fruta:
if carac == "e... |
15343a0e4aa0578eebbafb93d8c3d1b16d2a766d | L-ingqin12/LanQiaoCup-Python | /src/3 算法训练/算法训练 前缀表达式.py | 105 | 3.703125 | 4 | a = input().split()
if a[0] == '/':
print(int(a[1])//int(a[2]))
else:
print(eval(a[1]+a[0]+a[2])) |
4c578239d8a250c537fa689e380c6b347231f08f | L-ingqin12/LanQiaoCup-Python | /src/4 算法提高/算法提高 成绩排序2.py | 1,441 | 3.578125 | 4 | class Score():
def __init__(self,id,math,english,chinese):
self.id = id
self.math = math
self.english = english
self.chinese = chinese
self.total = math + english + chinese
def __gt__(self,b):
if self.total > b.total:
return True
elif self.tot... |
b4aa5f81890f4f157349ce3350721d8b40dd6ba0 | L-ingqin12/LanQiaoCup-Python | /src/3 算法训练/算法训练 矩阵乘法.py | 2,309 | 3.65625 | 4 | class Matrix:
def __init__(self,n,m):
self.items = [0 for i in range(n*m)]
self.row = n
self.col = m
def row_len(self):
return self.row
def col_len(self):
return self.col
def npr(self):#num_per_row
return self.col
def npc(self):#num_per_col
... |
2a0f013ad2aac2a67e9eafb1fa8a009d9aa663a8 | ESROCOS/tools-pusconsole | /app/Utilities/Database.py | 2,907 | 4.375 | 4 | import sqlite3 as sq3
from sqlite3 import Error
class Database(object):
"""
This class represents a database object. It implements
some methods to ease insertion and query tasks
"""
def __init__(self, dbname: str):
"""
This is the constructor of the class
:param dbname: The... |
a7b36a35322e99ba79794df6d62fa09cf2f5f219 | yashjain87553/commands2 | /commands2/logical problem solve using python code/Kruskal_MSt_Really_Special_Subtree.py | 2,687 | 3.5625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
from collections import defaultdict
#
# Complete the 'kruskals' function below.
#
# The function is expected to return an INTEGER.
# The function accepts WEIGHTED_INTEGER_GRAPH g as parameter.
#
#
# For the weighted graph, <nam... |
51ce4736339c72d7a9943e59e05db658c6b41399 | yashjain87553/commands2 | /commands2/logical problem solve using python code/mergelinkedlist.py | 2,196 | 4 | 4 | class Node_ex:
def __init__(self,data=None):
self.data = data
self.nextnode = None
class linklist_ex:
def __init__(self):
self.head = None
def addnode(self,data=None):
node=Node_ex(data)
if self.head==None:
self.head=node
else :
start=self.head
temp=start
while temp.nextn... |
f4e4049807573b562721f60a469029214e93cf7b | L200194051/Praktikum-Algopro | /praktikum 6 data dan operator/kegiatan4tipedata.py | 1,679 | 3.796875 | 4 | ## kegiatan 4 tipe data oleh Dafa Cahya Alfianiko L200194051
>>> nama = 'Dafa Cahya Alfianiko'
>>> nim = 051
>>> tinggi = 1.70
>>> berat = 55
>>> tahunlahir = 2001
>>> aku = (tahunlahir, berat, tinggi, nimn nama)
>>> data = (tahunlahir, berat, tinggi, nim, nama)
>>> type(aku)
<class 'tuple'>
>>> #because the ... |
89bd65dd0f18fb9780772e74d3a25d5acf8c27e2 | deleonalejandro/proyectosistemasoperativos | /Proyecto FIFO LRU/main.py | 27,185 | 3.515625 | 4 | #
#Misc. Libraries
import os
import re
import time
import math
import sys
import statistics
from decimal import Decimal, ROUND_DOWN
import operator
from functools import reduce
def SwapIn(ProcessLocation, SwapMemory):
#Swap In will tell you which indexes of the Swap Memory correspond to the proces... |
2429e9ce4d88c8f44067e274d47760656a6f6481 | JuanFryS/Javascript-Precompiler | /errores/tabla_simbolos.py | 5,477 | 3.53125 | 4 | # -*- coding: UTF-8 -*-
#
# En este archivo se encuentra el código correspondiente a
# la tabla de símbolos, y la gestión de la misma mediante
# los diferentes métodos declarados.
#
class Info(object):
tipo = ""
ambito = ""
desplazamiento = 0
num_par = 0
tipo_par = []
# Constructor
def __init__(self, tipo, amb... |
fb58f92aec0676ac02c14874fcda3216524d3d56 | DonnGDongGe/algorithm010 | /Week01/trap.py | 2,881 | 3.515625 | 4 | """双指针"""
class Solution1:
def trap(self, bars):
if not bars or len(bars) < 3:
return 0
volume = 0
left, right = 0, len(bars) - 1
l_max, r_max = bars[left], bars[right]
while left < right:
l_max, r_max = max(bars[left], l_max), max(bars[right], r_max... |
a78ebf8260f3aabd69c553b48495c6b16b44ac73 | DonnGDongGe/algorithm010 | /Week01/swapPairs.py | 746 | 3.640625 | 4 | # 两两交换链表中的节点
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def swapPairs(self, head):
thead = ListNode(-1)
thead.next = head
c = thead
while c.next and c.next.next:
a, b = c.next, c.next.next
# c.nex... |
b4aada7eecf00171958df6cd9b9ae0b822b8f0fa | jeyong/realalg | /graph_bft.py | 654 | 3.59375 | 4 |
class Graph:
def __init__(self):
self.vertexs={"S":["A", "B"], "A":["F"], "B": ["A", "F"], "F": None}
def __str__(self):
return str(self.vertexs)
def BFT(self, start):
if list(self.vertexs.keys()).count(start) == 0 :
return
q = []
visited = []
... |
87a89b32d03dcfab6ccecf1527eed9c7fd7edc1d | Tashwri93/Python-Files-and-Exceptions | /exercise10.8.py | 329 | 3.765625 | 4 | filename = 'the.txt'
try:
with open(filename) as file_object:
contents = file_object.read()
except FileNotFoundError:
msg = "Sorry, the file " + filename + " does not exist."
print(msg)
else:
words = contents.split()
num_words = words.count('the')
print(num... |
511a21b636493d589d3e6b3587cd33c0e2fb0437 | andersonbispo/multiplesThreeAndFive | /tests.py | 1,482 | 3.625 | 4 | import unittest
import multiples
class MultiplesTests(unittest.TestCase):
def test_is_multiple_of_three(self):
self.assertTrue(multiples.is_multiple_of_three(9))
def test_is_not_multiple_of_three(self):
self.assertFalse(multiples.is_multiple_of_three(4))
def test_is_multiple_of_five(sel... |
7129cbaca503f3dcde5cf4dfb29ad4aa56059fc7 | SiChiTong/micro_mouse_final | /control_mousebot/scripts/Graph.py | 1,349 | 3.765625 | 4 | """
class to scan Lidar scan to build graph maze understanding
Theory - building should only interact with four nearest walls
"""
"""
in a 16x16 maze there are 16 nodes.
each node represnts a possible robot position.
The robot being able to move between nodes represents a connection.
"""
class Graph2(object):
d... |
e7eea0e92c5c8cf7c537f545b05a17a819b4d108 | pab2163/pod_test_repo | /Diana/stock_market_challenge.py | 1,221 | 4.25 | 4 | # Snippets Challenge
# Playing with the stock market.
# Write code to take in the name of the client as the user input
name = input("Hi there!\nWhat is your name?: ")
print("Hello "+ name + "!" )
# Write code to get user input savings" and personalize message with "name"
savings =int(input("What are your curren... |
d3db4c2dbb599de13e7396db16f96912d335b126 | Abdullahalmuhit/BT_Task | /BT_Solution.py | 548 | 4.125 | 4 | value = int (input("How many time you want to run this program?: "))
def check_palindromes(value):
charecter = input("Enter Your One Character: ")
my_str = charecter+'aDAm'
# make it suitable for caseless comparison
my_str = my_str.casefold()
# reverse the string
rev_str = reversed(my_st... |
2de44c6740e7af44204b080dd849419879287a28 | rajatkashyap/Python | /CountEven.py | 184 | 3.953125 | 4 | def count_evens(nums):
num=0
for i in nums:
if i%2==0:
num+=1
return num
print count_evens([2, 1, 2, 3, 4])
print count_evens([2, 2, 0])
print count_evens([1, 3, 5]) |
8639646f11d8d6aa4d034cacb96398635efef857 | rajatkashyap/Python | /prime.py | 369 | 3.671875 | 4 | i=int(raw_input())
a=[]
'''for p in range(2,i+1):
for j in range(2,p):
if p%j==0:
break
else:
a.append(p)
print list(set(a))'''
for i in range(2,i+1):
for j in range(2,i):
#if i==2:
# a.append(i)
if i%j==0:
bre... |
66e388a9696fedc572bcbf81c6caaeae43b6b905 | rajatkashyap/Python | /parse_email.py | 1,105 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Sep 17 20:30:00 2018
@author: U40MV02
"""
import re
def parse_email (s):
"""Parses a string as an email address, returning an (id, domain) pair."""
e,d=s.split('@')
x=re.search('^\D[\w.]+@[\w.-]+\D$',s)
if not x:
raise ValueError
ret... |
aba17ef81791931b9edbe5c6bd75fd0e20c8b850 | rajatkashyap/Python | /first.py | 1,565 | 3.953125 | 4 | print "Hello Rajat"
#print "How are you doing?"
cars=3
space_in_cars=4
print cars,space_in_cars
print "There are", cars, "cars, with" , space_in_cars, "person space each"
name='Rajat'
hair_color='Black'
hieght=69 #inches
weight=70
print "My Name is %s," % name,"I am %d inches tall" % hieght,"and my ... |
9297bd49c2a7ddd20007b3d0f599ce7a15cfa670 | rajatkashyap/Python | /make_itemsets.py | 564 | 4.21875 | 4 | '''Exercise 3 (make_itemsets_test: 2 points). Implement a function, make_itemsets(words). The input, words, is a list of strings. Your function should convert the characters of each string into an itemset and then return the list of all itemsets. These output itemsets should appear in the same order as their correspond... |
959944451bc1b4fb36518f650069273fcfe11752 | rajatkashyap/Python | /ThreeSum.py | 653 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue May 21 10:11:46 2019
'[-1, 0, 1, 2, -1, -4]
'[-4, -1, -1, 0, 1, 2]
@author: u40mv02
"""
def threeSum(nums):
z=len(nums)-1
res=[]
nums.sort()
for x in range(len(nums)-2):
y=x+1
while(y<z):
s=nums[x]+nums[y]+nums[z]
... |
1a69ac34a246ddcb53641785cbd3f97cb3c61bb9 | rajatkashyap/Python | /longestPalindrome1.py | 491 | 3.859375 | 4 | def longest_palindromic(text):
palins=[]
for i in range(len(text)):
for j in range(i+1,len(text)):
sub=text[i:j+1]
if sub==sub[::-1]:
palins.append(sub)
print palins
print max(palins)
'''if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longes... |
beb596a61aca775677126364eba322cfab9d4843 | rajatkashyap/Python | /sum67_again.py | 1,035 | 3.796875 | 4 |
'''Return the sum of the numbers in the array, except ignore sections of numbers starting with a 6 and
extending to the next 7 (every 6 will be followed by at least one 7). Return 0 for no numbers.
sum67([1, 2, 2]) → 5
sum67([1, 2, 2, 6, 99, 99, 7]) → 5
sum67([1, 1, 6, 7, 2]) → 4
sum67([1, 6, 2, 2, 7, 1, 6, 99,... |
e453bc4d89de782eb0712f46f1a8f22039a85019 | rajatkashyap/Python | /SolAnything.py | 963 | 3.828125 | 4 | def checkio(anything):
def __gt__(self, other):
return self > other
def __lt__(self,other):
return self < other
def __le__(self,other):
return self <= other
def __ne__(self, other):
return self!=other
def __ge__(self,other):
return self>=other
d... |
e1132b66e55c80aa4f765a596fd0bfac74456e4b | rajatkashyap/Python | /LCM.py | 215 | 3.875 | 4 | def lcm(x,y):
x=int(x)
y=int(y)
if x<y: lar=y
else: lar=x
for i in range(lar,x*y+1):
if i%x==0 and i%y==0:
return i
#else:
# return x*y
print lcm(6,8) |
cf05dfd355a651e4fa3c259fc327f5b449c20da6 | rajatkashyap/Python | /StringMatch.py | 248 | 3.734375 | 4 | def string_match(a, b):
s=0
if len(a) <= len(b): s=len(a)
else: s=len(b)
#print s
count=0
for i in range(s-1):
if a[i:i+2]==b[i:i+2]:
count=count+1
return count
print string_match('abcde', 'abcd')
|
2ea37e91de03d8aa601f82ccad87120fc5dce4b0 | rajatkashyap/Python | /UniqueWords.py | 364 | 3.875 | 4 | dict_words={}
s=raw_input("Enter text")
s1=s.split()
print s
for word in s1:
word=word.lower()
if word in dict_words:
dict_words[word]+=1
else:
dict_words[word]=1
for word in dict_words:
if dict_words[word]==1:
print word
str_lower=[]
for i in s1:
str_lower.append(i.lower())
print [x f... |
6af1210d29481da34707cc14cdfba58fa819bf1e | rajatkashyap/Python | /EvalFloating.py | 937 | 3.625 | 4 | def eval_strfrac(s, base=2):
integral, point, fractional = s.strip().partition('.')
print integral, point, fractional
integral_i= int(integral,base)
s=0
for i in range(len(fractional)):
s=s+int(fractional[i],base)*(base**-(i+1))
#
# YOUR CODE HERE
#
return float... |
6bff103f0a291aa1b0e1d5e7a44dddf5467fafb1 | super1G/PythonExercise | /ch7.py | 338 | 3.84375 | 4 | # while
n=1
sum=0
while n<10:
print(n)
n+=1
sum+=n
print(sum)
# for
for x in [1,3,5]:
print(x)
for x in "ASDFFG":
print(x)
for x in range(5): #range(5)=[0,1,2,3,4]
print(x)
for x in range(5,10): #range(5,10)=[5,6,7,8,9]
print(x)
sum=0
for x in range(1,11):
sum=sum+x
#print(x.' ... |
8095f1c33d099fcdad65003a2f4add5d07bd5090 | orionbearduo/Aizu_online_judge | /ITP1/ITP_1_6_A.py | 539 | 4.28125 | 4 | """
Reversing Numbers
Write a program which reads a sequence and prints it in the reverse order.
Input
The input is given in the following format:
n
a1 a2 . . . an
n is the size of the sequence and ai is the ith element of the sequence.
Output
Print the reversed sequence in a line. Print a single space character be... |
0935e6a46fdd933261931fa71727206015745918 | orionbearduo/Aizu_online_judge | /ITP1/ITP_1_5_C.py | 824 | 4.28125 | 4 | """
Print a Chessboard
Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.
#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
#.#.#.#.#.
.#.#.#.#.#
Note that the top left corner should be drawn by '#'.
Input
T... |
bdff89efc61f5158b6d87dd6b5eeb5f11e91b898 | orionbearduo/Aizu_online_judge | /ITP1/ITP_1_8_A.py | 245 | 4.3125 | 4 | # Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
# Sample Input
# fAIR, LATER, OCCASIONALLY CLOUDY.
# Sample Output
# Fair, later, occasionally cloudy.
n = str(input())
print(n.swapcase())
|
91e681b7829f5144d0a3e4b4e9616d852201d659 | orionbearduo/Aizu_online_judge | /ITP1/ITP_1_2_D_Circle_in_a_Rectangle.py | 645 | 3.921875 | 4 | '''
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle.
As shown in the following figures, the upper right coordinate (W,H) of the rectangle and the central coordinate x,y) and
radius r of the circle are given.
Input Five integers W, H, x, y and r ... |
32ae9981b5c31548ec5a4bec426bbcb74d3ca545 | tmyarow/SortingAlogrithmsVisualizer | /TextBox.py | 1,159 | 3.96875 | 4 | class TextBox:
def __init__(self, text, text_color, font, x, y, is_center_coordinates, window, background_color=None):
"""Creates and shows a text box on a pygame window
Args:
text (String): text to show
text_color (Color): text color
font (pygame.font): text fon... |
f44384106b68c32231325a3ef71f0cdbcd2deae3 | ShoumikMajumdar/Imitation-Learning-Car | /network.py | 2,661 | 3.53125 | 4 | import torch
class ClassificationNetwork(torch.nn.Module):
def __init__(self):
"""
1.1 d)
Implementation of the network layers. The image size of the input
observations is 96x96 pixels.
"""
super().__init__()
gpu = torch.device('cuda')
def forward(self... |
dd8e680dc6602a27517af06f09319447b4256735 | renuit/renu | /factor.py | 226 | 4.125 | 4 | n=int(input("Enter a number:"))
fact=1
if(n<0):
print("No factorial for -Ve num")
elif(n==0):
print("factorial of 0 is 1")
else:
for i in range(1,n+1):
fact=fact*i
print("factorial of", n,"is",fact)
|
fd8872140f11c45ac08bb91bd9a06683a216aa69 | jbaik1016/pdsnd_github | /bikeshare.py | 7,410 | 4.34375 | 4 | import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv','new york city': 'new_york_city.csv', 'washington': 'washington.csv' }
MONTHS = ['january', 'february', 'march', 'april', 'may', 'june', 'all']
DAYS = {'monday':0, 'tuesday':1, 'wednesday':2, 'thursday':3, 'friday':4, 'saturday... |
59a95426cd9ce1331f05b52bff879e24f7d4b7ae | ShaamP/Library-Project | /Library.py | 9,403 | 3.96875 | 4 | import datetime
#####################################
# COMPSCI 101 S1 C, 2015 #
# Assignment Three Question 1 #
# #
# @author YOUR NAME and UPI #
# @version THE DATE #
#####################################
# This function displays the introduction part of... |
7c94602bbc0ce53124f4e2c892c85d24dcbd0331 | garima-16/Examples_python | /occurrence.py | 260 | 4.4375 | 4 | #Program to find the occurrences of a character in a string
string1=input("enter any string ")
ch=input("enter a character ")
count=0
for i in string1:
if ch==i:
count+=1
print("number of occurrences of character in string ",count)
|
d12264b5ca6fd8ae5fa1d15cd57a4e3d3c614d57 | OneHotEncoder01/Scientific-Calculator-python3 | /Scientific calculator/sci2.py | 8,246 | 3.625 | 4 | from tkinter import*
import math
import parser
import tkinter.messagebox
import sys
def main():
root = Tk()
root.title("Scientific Calculator")
root.configure(background="#d3dbd3")
root.resizable(width = False, height = False)
root.geometry("1022x568+0+0")
calc = Frame(root)
calc.grid()
textDisplay = Entry(... |
202ead1362df5fc65590c30fecc7fdc3ed0849c0 | bryce-anderson/adventofcode2015 | /19/main.py | 1,321 | 3.53125 | 4 | from collections import deque
def parseInput(f):
steps = []
for l in f.readlines():
l = l[:-1]
parts = l.split()
if len(parts) == 3:
[a,_,c] = parts
steps.append((c, a))
elif len(parts) == 1:
def o(s):
c = 0
... |
cb790efb7d8bb9c1df9b2cfa548f9bf7af28c759 | Paulo-Filipe/earlycoding | /hyp.py | 1,143 | 3.8125 | 4 |
def find_hyp(sza, szb):
hyp = (sza**2 + szb**2)**0.5
return hyp
def is_right_angle (sza, szb, szc):
if float(sza) + float(szb) < float(szc) or float(sza) + float(szc) < float(szb) or float(szb) + float(szc) < float(sza):
print ("it's not a triangle!")
elif float(sza) <= 0 or float(szb) <= 0 o... |
0e1dcc2c3dc649e99a92b4b484bcb52a90c962b5 | Paulo-Filipe/earlycoding | /fabiomeladotxtadventure.py | 9,598 | 3.84375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
print ("Pe. Fabio Melado Fake Text Adventure\ninspirado pelas maravilhas do Zap moderno\ndigite amem para comecar")
inicio = False
while inicio == False:
iniciar = raw_input ("")
if iniciar.lower() == "amem":
inicio = True
inicio = F... |
f568c4199bab24ede00a1cc89b9848c772d6dbd9 | DL-py/matplotlib-notebook | /010坐标轴刻度.py | 391 | 3.890625 | 4 | """
坐标轴刻度:
"""
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(-10, 11)
plt.figure() # 获得当前Figure
fig1 = plt.gcf()
fig1.add_subplot()
ax1 = plt.gca() # 获得当前Figure中的axes
ax1.plot(x, x**2)
# 方法1:
ax1.locator_params('x', nbins=30) # nbins表示列数,可以指定具体的轴
# 方法2:
plt.locator_params('y', nbins=20)
plt.show... |
88476657bf5dfdd723f0b2e51ce7c6857f33627e | DL-py/matplotlib-notebook | /013文字.py | 491 | 3.765625 | 4 | """
文字:
"""
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(-10, 11)
plt.plot(x, x**2)
plt.text(0, 40, 'y=x**2', family='fantasy', size=10, color='r',
style='italic', weight='black', bbox=dict(facecolor='y', alpha=0.5))
# 0,40表示x,y坐标,family表示字体类型,size表示字体大小,style='italic'表示斜体
# weight表示字体的粗细:b... |
3bc3ca99ed75d22ed3af48597640505524303a6b | Dinesh-Sivanandam/Data-Structures | /Binary Search tree/min_max_values_in_tree.py | 1,616 | 3.8125 | 4 | class BinarySearchTreeNode:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def add_child(self, data):
if data == self.data:
return # node already exist
if data < self.data:
if self.left:
... |
c310929561622e694202ce37ffcd91d77ef4551c | Dinesh-Sivanandam/Data-Structures | /Linked List/insert_values.py | 1,664 | 4.375 | 4 | #Creating the class node
class Node:
def __init__(self, data=None, next=None):
self.data = data
self.next = next
#Creating the class for linked list
class LinkedList:
#this statement initializes when created
#initializing head is none at initial
def __init__(self):
... |
982a730741c2b711e4a11992fa72475b3e10c15b | ifranc-r/computorv1 | /computorv1.py | 1,997 | 3.765625 | 4 | from math import *
from time import sleep
import sys
def is_num(num):
try:
float(num) # for int, long and float
except ValueError:
print "\nError:\nThe input are not correct\n"
sys.exit(-1)
return float(num)
def solvequadratic(a, b, c):
discriminant = b * b - 4 * a * c
if (discrimin... |
8242be88dd919b6e9c99d40d081d0f8d3bdaa89d | lengerfulluse/hLDA | /post_analysis/word_allocate.py | 1,146 | 3.703125 | 4 | #!/usr/bin/env python
from __future__ import print_function
import argparse
import os
import sys
import operator
import string
class WordAllocate:
levels_dir = ""
# words level allocation.
allocation = {}
def __init__(self):
pass
def getAllocation(self, levels_dir):
if not os.path.exists(levels_dir):
prin... |
8bdf35989b3d6094608726e815c1da7cb542b468 | skumardotpython/JulyBatch | /RegularExpression/27Aug19RegularExpression3.py | 269 | 3.609375 | 4 | # Program to remove all whitespaces
import re
# multiline string
string = 'abc 12\
de 23 \n f45 6'
# matches all whitespace characters
pattern = '\s+'
# empty string
replace = ''
new_string = re.sub(pattern, replace, string)
print(new_string)
# Output: abc12de23f456 |
2c6be602e4b5ffaada4af8308a8ad2a9193bfc78 | skumardotpython/JulyBatch | /WindowsApplication/11Sep19_WinAppGrid.py | 315 | 4.03125 | 4 | # !/usr/bin/python3
from tkinter import *
root = Tk( )
def Calculalte():
pass
e1 = Entry(root)
e1.pack
var = 0
for r in range(3):
for c in range(3):
var = var + 1
print(c, end=' ')
Button(root, border=1, text=str(var), command=Calculalte).grid(row=r, column=c)
root.mainloop() |
3df3f94e6feeb99e771d0993b6725a94d314b317 | maor90b/Bartov | /project2-master/טיפוסי נתונים/Dict_Ex_7.6.py | 100 | 3.765625 | 4 | dic1={1:10,2:20,3:30}
key=int(input("enter number: "))
if key in dic1:
del dic1[key]
print(dic1) |
2316c0f0a9da8d0223a2fba5ff0e384aae0cc13b | maor90b/Bartov | /project2-master/לולאות 4/תרגיל 4.py | 139 | 3.984375 | 4 | num=int(input("enter number: "))
num2=0
while num//10!=0:
num2=num2+num%10
num2=num2*10
num=num//10
num2=num2+num
print(num2)
|
7796e323611d2ea688759a121d8917a12941e6d9 | maor90b/Bartov | /project2-master/package1/דוגמה 5.py | 231 | 3.875 | 4 | grade =int(input("enter number: "))
name= input("enter name: ")
if grade>=70 and (name=="Michael" or name=="George"): # להוסיף סוגריים כדי לעשות שני תנאים
print("passsed")
else:
print("failed") |
b77f01a7a336afadc8c1b6aac1a71d649e047ea1 | maor90b/Bartov | /project2-master/Functionals/Lambda.py | 191 | 3.921875 | 4 | # num=5
# func1=lambda num:num*2
def func1(num):
return num*2
# print(func1(20))
list1=[1,2,3,4,5,6]
# list2=map(func1,list1)
list2=map(lambda num:num*2,list1)
print(list(list2))
|
916ffa5b108f1371c1e960659769e0a4aac251ff | maor90b/Bartov | /project2-master/package1/1.5.py | 135 | 3.875 | 4 | salary=int(input("enter salary: "))
percent_growth=int(input("enter your percent growth: " ))
print(salary*(percent_growth/100)+salary) |
8cf94f263fe14f4f2487f41f0446e8b968f3f9c6 | maor90b/Bartov | /project2-master/package1/דוגמה 4 תנאים.py | 911 | 4.28125 | 4 | grade =int(input("enter number: "))
if grade<0 or grade>100:
print("the grade is between 0 and 100")
if grade>=0 and grade<=100: # דרך נוספת
if 90<=grade<=100:
print("very good")
if grade<90 and grade>=80:
print("good")
if grade<80 and grade>=70:
print("ok")
if grade<70
... |
4eff83aad706e82d8b179ab67d09900f25500997 | maor90b/Bartov | /project2-master/package1/בסיסי ת 4.py | 255 | 3.96875 | 4 | print("choose number between 1-9 in the following quets: ")
num1=input("enter number one: ")
num2=input("enter number two: ")
num3=input("enter number three: ")
num4=num1+num2+num3
num5=int(num4)*2
print("new number=",num4,"and",str(num4)+"*2="+str(num5)) |
8499b5c3a0c127bfc8a038173683ace5d8609d1a | maor90b/Bartov | /project2-master/Functionals/EXercices/Ex_2.py | 117 | 3.546875 | 4 | def num(a):
if a < 100 or a > 999:
print('false')
else:
print('true')
n=int(input())
num(n) |
558c1184deea30aea9d7c6183ffe40d90a538b80 | maor90b/Bartov | /project2-master/package1/תרשים סרימה if.py | 96 | 4.125 | 4 | num=int(input("enter number: "))
if num>=0:
print("positive")
else:
print("negative") |
870b14bff6037f70d03cfce0e1edefb8c366a992 | maor90b/Bartov | /project2-master/טיפוסי נתונים/Dict_7.7.py | 166 | 3.53125 | 4 | dic1={1:10,2:20,3:30,5:30,6:10}
dic2={}
for i in dic1.items():
dic2[i[1]]=i[0]
print(dic2)
dic1.clear()
for i in dic2.items():
dic1[i[1]]=i[0]
print(dic1)
|
ff67f4c000d50c00aac4fa0e81e49664de9ae65c | maor90b/Bartov | /project2-master/מחרוזות/תרגיל 5.2.py | 46 | 3.640625 | 4 | str1 = input("enter str: ")
print(str1[::-1])
|
f3adeb10d8e33675d875b6dc7437096c4fa10c1d | maor90b/Bartov | /Package_2/main_inheritance_2.py | 609 | 3.625 | 4 | from Package_2.Rectangle import Rectangle
from Package_2.Box import Box
shapes=[]
type=int(input("enter shape type: 1-rec 2-box 0-exit: "))
while type!=0:
if type==1:
rec=Rectangle(7,4)
shapes.append(rec)
if type==2:
box=Box(20,10,7)
shapes.append(box)
type = int(input("e... |
048985067aa76a493594b62ac4d8097973372d88 | maor90b/Bartov | /project2-master/טיפוסי נתונים/Dict_7.2.py | 115 | 3.90625 | 4 | dic1={1:10,2:20,3:30}
keys=int(input("enter key:"))
if keys in dic1:
print("true")
else:
print("false")
|
82c1254a1eeeb2f3dd166e2efbec924f0d10bf68 | Veranchos/HSE_Programming | /classworks/translit.py | 318 | 3.90625 | 4 | trans = {'ა': 'а', 'ბ': 'б', 'გ': 'г', 'დ':'д', 'ე': 'е', 'ვ': 'в', 'ზ': 'з', 'ჱ': 'эи', 'თ': 'т', 'ი': 'и', 'კ': 'к', 'ლ': 'л', 'მ': 'м', 'ნ': 'н', 'ჲ': 'йэ', 'ო': 'о', 'პ': 'п', }
word = input()
for letter in word:
if letter in trans:
print(d[letter]) |
ee9ca64c80cd089bdc76b75102c834f94d923205 | vikramacharya/alexa | /universityGuru/alexa-university.py | 1,776 | 3.53125 | 4 | from flask import Flask
from flask_ask import Ask, statement, question, session
from university_api import UniversityNews
app = Flask(__name__)
ask = Ask(app, "/")
@ask.launch
def new_game():
session.attributes['last_intent'] = 'Launch'
return question(
'You can get the university domain detail by name of univer... |
e0620834b1626bd0e631828bacab3c6afe14a1cb | LeeJehwan/Baekjoon-Online-Judge | /code/05354_J박스.py3.py | 269 | 3.515625 | 4 | t = int(input())
for _ in range(t):
x = int(input())
l = [['#']* x for _ in range(x)]
for i in range(1,x-1):
for j in range(1,x-1):
l[i][j] ='J'
for k in l:
for z in k:
print(z, end='')
print()
print() |
4408d39b7b75c7e66826e5674d12090dabc891c2 | LeeJehwan/Baekjoon-Online-Judge | /code/03447_버그왕.py3.py | 292 | 3.625 | 4 | try:
while True:
s = input()
while True:
if "BUG" in str(s):
s2 = ""
for a in s.split("BUG"):
s2+=a
s = s2
else:
print(s)
break
except:
exit()
|
35b2f593b746f3d79dd512e87c7d3c3ffe3d8f04 | LeeJehwan/Baekjoon-Online-Judge | /code/11586_지영 공주님의 마법 거울.py3.py | 243 | 3.546875 | 4 | n = int(input())
l = list()
for _ in range(n):
l.append(input())
k = int(input())
if k == 1:
for x in l:
print(x)
elif k == 2:
for x in l:
print(x[::-1])
else:
for x in range(n-1, -1, -1):
print(l[x])
|
9cf9336eeca644ace0e8f3612bf5eb99125d31eb | egatzinski/Programming-Real-World-Concurrency | /multithread.py | 2,493 | 3.71875 | 4 | import threading
import random
import time
thread_id = 1
ticketsAvailable = 2
lst_seats_available = list(range(1, ticketsAvailable + 1))
empty_lst = []
boolean = [True, False]
class Customer(threading.Thread):
ticketsSold = 0
def __init__(self):
threading.Thread.__init__(self)
... |
558f7caf13425f7467f5c5ea018e00f78cb69cc0 | ChHeYo/mini_blockchain | /blockchain_module/transaction.py | 1,418 | 3.671875 | 4 | # import sha256 as the whitepaper also uses sha256
from hashlib import sha256
from datetime import datetime
class Transaction:
'''
A transaction consists of the following:
- index: index of a tx within the block
- previous hash: previous tx that has been hashed
- timestamp: when the tx was instant... |
2620f245f3cd5d4a00a090322dede9b0c90e5c4f | PicciDavide/esercizi_lab | /esercizio_pag_190_25.py | 575 | 3.90625 | 4 | registro = {}
registro_voti = []
for i in range(30):
nome = input("Inserire il nome dello studente ")
while True:
try:
voto = float(input("Inserire il voto dello studente "))
break
except ValueError:
print("Si deve inserire un numero")
registro[nome] = vot... |
786ef5c5915a92941455d9a180f5ac914aaef271 | PicciDavide/esercizi_lab | /esercizio_28.py | 463 | 3.859375 | 4 | elenco = input("inserire l'elenco degli studenti con la formula: studente1, lancio1; studente2, lancio2;...\n")
elenco = elenco.split(";")
valori = []
for i in elenco:
scrittore_toggle = False
numero = " "
for l in i:
if scrittore_toggle:
numero = numero + l
if l == ",":... |
47be8ec8d2bcae1829e8e7d18bc70b16dc82afc0 | PicciDavide/esercizi_lab | /esercizio_26.py | 541 | 3.625 | 4 | """calcola la media degli stipendi dei dipendenti di un'azienda, acquisiti con una ripetizione fino a quando
si inserisce il valore -1 per segnalare la fine dell'input dei dati"""
stipendi = []
run = True
while run == True:
stipendio = int(input("immettere lo stipendio del dipendente: "))
if stipendio ... |
d0c25d25b8da87ca21eb9173178edb2b8055c22e | PicciDavide/esercizi_lab | /esercizio_pag_191_33.py | 568 | 3.859375 | 4 | '''Scrivere un programma che registri in ordine di arrivo i nomi dei pazienti di laboratorio,
successivamente stampa il paziente che deve essere sottoposto all'esame per primo
perché è il primo della coda'''
coda = []
while True:
print("Scrivere 0 per terminare l'inserimento")
paziente = input("Scrivere il no... |
8f32300bb3e6cf2ea65aedec592b4d6f5b01df43 | DatLombardo/Computational-Science-CSCI2072 | /tridag_matvecAssign2.py | 3,440 | 3.640625 | 4 | #Michael Lombardo
#100588642
#Assignment 2
import math
import numpy as np
import scipy
import scipy.linalg
import time
import matplotlib.pyplot as plt
#Generate full matrix, didn't bother making it only upper triangular
#as it would not effect the caluclation.
def generateMatrix(size):
A = scipy.zer... |
d4d6b26a59a6d3e4ad2f002c3bb9062eb466cd5b | holypanda/pythonTutorials | /learnPython/day_4 逻辑判断与循环/实战1 猜数字游戏/guess_number_game.py | 506 | 3.6875 | 4 | import random
random_int = random.randint(0, 100)
round_count = 0
while True:
player_guess_num = int(input("猜一个数字,范围是0-100")) # 有可能出错的代码
if player_guess_num < random_int:
print("你猜的数字太小了!")
elif player_guess_num > random_int:
print("你猜的数字太大了!")
elif player_guess_num == random_int:
... |
0693111789c72af4db96730c3caa7b0cf4422571 | sachinasy/oddevenpython | /prac1.py | 268 | 4.34375 | 4 | # program to identify the even/odd state of given numbers
# function to print oddeven of given number
#oddeven function
number = int(input("enter a number: "))
if number % 2== 0:
print ("the entered number is even")
else:
print ("the entered number is odd")
|
9ac47ee7304a389e980b7ea7b3025cbcb13e47c8 | epangar/python-w3.exercises | /Python_basics/31-40/39.py | 264 | 3.96875 | 4 | """
39. Write a Python program to compute the future value of a specified principal amount,
rate of interest, and a number of years.
"""
def interest(amount, rate, years):
for i in range(1, years+1):
amount = amount * ((100.00 + rate)/100)
return amount |
0f2b01072bd92b87601a241627e1db0da46ca7be | epangar/python-w3.exercises | /Python_basics/31-40/32.py | 476 | 3.828125 | 4 | """
32. Write a Python program to get the least common multiple (LCM) of two positive integers.
"""
def LCM(first, second):
if first % second == 0:
return first
elif second % first == 0:
return first
else:
my_min = min([first, second])
my_max = max([first, second])
multiplier = 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.