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 |
|---|---|---|---|---|---|---|
06a0c8fda7a357941b0b4f0cb20f731503f53a9a | zischuros/Introduction-To-Computer-Science-JPGITHUB1519 | /Lesson 2.5 - How to Solve problems/Final- dayBetweenDates/demo copy.py | 1,088 | 4.09375 | 4 |
def nextDay(year1, month1, day1):
if(day1 < 30):
day1 = day1 + 1
return year1, month1, day1
else:
if(day1 == 30 and month1 == 12):
year1 = year1 + 1
month1 = 1
day1 = 1
return year1, month1, day1
else:
... |
5c01abaef41a8f6a8e493a83aa4112be81e1226d | zischuros/Introduction-To-Computer-Science-JPGITHUB1519 | /Lesson 4- Problem Set(optional)/Converting Seconds/prueba.py | 243 | 3.734375 | 4 |
time = 7261.7
hour = int(time / 3600)
time = time % 3600
minute = int(time / 60)
print minute
time = time % 60
seconds = time
string_tiempo = str(hour) + ":" + str(minute) + ":" + str(seconds)
print string_tiempo
|
9ca7a8b2b6f1cce6f51b6602b113330f51404669 | zischuros/Introduction-To-Computer-Science-JPGITHUB1519 | /Lesson3 - How to Manage Data/For Loop/for loop.py | 125 | 3.640625 | 4 | #sintax
#for <''name''> in <''list''>:
# <''block''>
lista = [1,2,3,[4,5] ]
for i in lista :
print i
|
56d157b267f13ab2f733da71e7aa2ec4ac4cc026 | zischuros/Introduction-To-Computer-Science-JPGITHUB1519 | /Lesson 1 - How to get Started/Selecting sub-sequencies/sub-sequencies.py | 254 | 3.625 | 4 |
string = "programacion"
# string [start : stop-1]
print string[0:8]
print string [5:] #from start to end
print string [:6] #from begin to stop
print string [5:5] # do not exist
print string[:] # from begin to end
input() |
c24dc740ed8ee048dcc650ab54fae4c3e556c758 | zischuros/Introduction-To-Computer-Science-JPGITHUB1519 | /Cumulative Practice Problems/Longest Repetition/longest repetition.py | 1,023 | 4.09375 | 4 | # Question 8: Longest Repetition
# Define a procedure, longest_repetition, that takes as input a
# list, and returns the element in the list that has the most
# consecutive repetitions. If there are multiple elements that
# have the same number of longest repetitions, the result should
# be the one that appe... |
cde5e75426beb00f361a73bb722cfc59e73c2137 | zischuros/Introduction-To-Computer-Science-JPGITHUB1519 | /Exercises/Simulador de loteria/loteria.py | 868 | 3.5625 | 4 | from random import randint
def generar_premios(lista) :
cont = 1
while cont <= 3 :
r = randint(1,100)
lista.append(r)
cont = cont + 1
def apostar(lista) :
cont = 1
print "\nCuantos numeros desea apostar : "
cant = int(input())
while cont <= cant :
print "Ingrese #", cont, "... |
bd10d41666210157c76142da0f3c666f5f9b4a6d | SergioRodRam/AprendiendoPython-Y-GitHub | /tiposDeDatos.py | 207 | 3.796875 | 4 | #! /usr/bin/python
#Esto es una cadena en python
c = "Hola Mundo"
#Esto es un entero
e = 23
#Comprobar con la fucnion "type"
type(c)
type(e)
#Imprime el tipo de dato que contiene
print(type(c))
print(type(e)) |
3c0e090ce2d0c2b55c9181ffb3dedf88574ababa | PraveenKumar305/DS-and-Algo-Python | /Datastructures/Hash Table/first_recurring_char.py | 916 | 4.09375 | 4 | #Google Question
# Given an array = [2,5,1,2,3,5,1,2,4]:
# Return 2
# Given an array = [2,1,1,2,3,5,1,2,4]:
# Return 1
# Given an array = [2,3,4,5]:
# Return undefined/None
# naive: O(n^2), SC: O(1)
def first_recurring_char(input):
for i in range(len(input)):
for j in range(i-1,0,-1):
... |
6eeb0463f0b42acc6fde7d5b61449e790949897b | dylan-hanna/ICS3U-Unit-5-05-Python | /address.py | 816 | 4.125 | 4 | #!/usr/bin/env python3
# Created by: Dylan Hanna
# Created on: Nov 2019
# This program accepts user address information
def mailing(name_one, address_one, city_one, province_one, postal_code_one):
print(name_one)
print(address_one)
print(city_one, province_one, postal_code_one)
def main():
while Tru... |
6b0e4aa2d88b08fdba883fbc9184242b71793d4b | asechnaya/-python-postgresql- | /movie-system/menu.py | 2,456 | 3.859375 | 4 | # 100DaysOfCode, Day 16
import json
import os
from user import User
def menu():
name = input("Enter your name: ")
filename = "{}.txt".format(name)
if file_exists(filename):
with open(filename, 'r') as f:
json_data = json.load(f)
user = User.from_json(json_data)
else:
... |
22324d3a12ce941bf0313ed7aae413fe03e30f6b | kimukook/RoboticMotionPlanningAlg | /KalmanFilter.py | 6,486 | 3.640625 | 4 | '''
This is a simple script that implements the Kalman filter.
- The KF algorithm is written with author own effort.
- The dynamics are referred by the following link:
https://github.com/balzer82/Kalman/blob/master/Kalman-Filter-CA-Ball.ipynb?create=1
- If you are looking for a good tutorial of Kalm... |
c245eb2dde0c3b41b2ef12e6a9c86b2b32b9b885 | PetraMarkova7/Pyladies_Brno | /02/uloha2.py | 608 | 4.03125 | 4 | tah_pocitaca = 'kamen'
tah_cloveka = input('kamen, nožnice, nebo papier? ')
if tah_cloveka == tah_pocitaca:
print('Remíza.')
elif (tah_cloveka == 'kamen'and tah_pocitace == 'papier') or (tah_cloveka == 'papier'and tah_pocitaca == 'nožnice') or (tah_cloveka == 'nožnice'and tah_pocitaca == 'kamen'):
print('Počíta... |
821ad576d77ac6c4c70c4dc1371750ab272a373c | ShelbyBhai/Mini-Projects-in-Python | /Encryption/EncryptedMessage.py | 456 | 4.4375 | 4 | print("Enter the Given Text & Shift Value : ")
_input_string = input()
_shift_Value = int(input())
print(_input_string, _shift_Value)
encrypted_input_string = ""
for char in _input_string:
if char.isupper():
encrypted_input_string += chr((ord(char)+_shift_Value-65)%26+65)
elif char.islower():
... |
742874c7cfd913f3c19051916030771094483d40 | ghost7890/spider | /中医宝典/hanzitopinyin.py | 2,046 | 3.5 | 4 | # coding:utf-8
"""
汉字转拼音
eg:
输入:中文
输出:zhong wen
"""
import re
class HanzitoPinyin(object):
"""
将汉字转化成拼音
"""
def __init__(self):
super(HanzitoPinyin, self).__init__()
self.pinyinList = [] # 存储拼音的list
self.wordsList = [] # 存储汉字的list
self.pinyin_dict = {} ... |
160609b34149a83ffd81cd0bc313ddfe08658e3e | haydnkeung/LeetCode | /algorithms/Maximum Level Sum of a Binary Tree.py | 1,410 | 3.703125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def getResult(self) -> int:
myKeys = list(self.myDict.keys())
highest = self.myDict[myKeys[0]]
result = myKeys[0]... |
f65cbc51338839147bd38e46b7f6be5d5ce01b93 | amirhj/PN-MTFGRL | /functions.py | 980 | 3.78125 | 4 | class Functions1:
def __init__(self, fg):
self.fg = fg
def v(self, var):
return self.fg.get_value(var)
def f1(self):
return 3 * self.v("x1")**3
def f2(self):
return 4 * self.v("x1")**4 - self.v("x2")**2
def f3(self):
x3 = self.v("x3")
return -1 * (x3**3 + x3)
def f4(self):
return self.v("x2")*... |
950e99c41f612c55c92ff941eb6023b287f40c01 | AlessandroFMello/EstruturaDeRepeticao | /Exercicio007.py | 1,018 | 3.71875 | 4 | import msvcrt
while True:
arr = []
contador = 0
arr.append(float(input('Digite um número:\n').replace(',', '.')))
while contador < 4:
arr.append(float(input('Digite outro número:\n').replace(',', '.')))
contador += 1
print('O array atual é: %s' % arr)
print('Utiliz... |
1b951469c738b8a4d609e082096d3ac9b8d49ebc | AlessandroFMello/EstruturaDeRepeticao | /Exercício003.py | 2,374 | 4.0625 | 4 | import msvcrt
while True:
while True:
nome = input('Digite seu nome:\n')
if len(nome) <= 3:
print('O nome deve ser maior que 3 caracteres\n')
True
else:
break
while True:
idade = int(input('Digite a sua idade:\n'))
if ida... |
276757ba5c6079dedff1ab368aad6d5c68f62c66 | AlessandroFMello/EstruturaDeRepeticao | /Exercício002.py | 677 | 3.9375 | 4 | import msvcrt
while True:
nome = input('Digite seu nome:\n')
while True:
senha = input('escolha uma senha:\n')
if senha == nome.upper() or senha == nome.lower():
print('Senha inválida')
print('A senha escolhida deve ser diferente de seu nome\n')
Tr... |
24bd74123015cb5b4d511f38c345c781abb6249d | ckinne1771/ArraySplitter | /ArraySplitter.py | 1,082 | 4.03125 | 4 | #Array Splitter Class. The number of splits is determined by the number passed into the method.
class ArraySplitter:
#Method for array splitting.
def splitArray(arrayToSplit, numberOfSplits):
#get the length of the passed in array.
length = len(arrayToSplit)
#Declaration of the array this ... |
1e4f3f6e00627fd8103c1ca7797f21e30498f37f | weirdname404/courses | /algorithms/greedy_algorithms/largest_number.py | 1,242 | 3.875 | 4 | # python3
# Compose the largest number out of a set of integers.
import functools
import random as r
def strange_less(a, b):
v1 = a + b
v2 = b + a
if v1 > v2:
return -1
if v1 == v2:
return 0
return 1
def largest_number(nums):
nums.sort(key=functools.cmp_to_key(strange_les... |
8ce772532220671af05ee25bda96033a5c2934b6 | weirdname404/courses | /algorithms/divide_and_conquer/points_and_segments2.py | 5,702 | 3.8125 | 4 | # python3
"""
You are given a set of points on a line and a set of segments on a line. The goal is to compute, for
each point, the number of segments that contain this point.
"""
import sys
import random
import time
def cool_count_p_s(starts, ends, points):
segments = {}
res = []
# O(n)
for i in rang... |
fc297249e6054914a6e6a523c63a516cd25ac873 | weirdname404/courses | /data_structures/heaps_and_disjoint_sets/job_queue.py | 5,079 | 4.15625 | 4 | # python3
"""
You have a program which is parallelized and uses n independent threads
to process the given list of m jobs.
Determine for each job which thread will process it and when will it start processing.
"""
class PriorityQueue:
def __init__(self, num_workers):
# workers = [(i, start_time)]
... |
094081e5aa98c06df6ce1a33f2b09b476b37d383 | weirdname404/courses | /algorithms/dynamic_programming/primitive_calculator.py | 1,617 | 3.875 | 4 | # python3
"""
Given an integer n, compute the minimum number of operations needed to obtain the number n
starting from the number 1
"""
from collections import deque
def get_optimal_sequence(n):
# due to the fact that we count opt. n of calculations for every number up to N
# every index of actions_arr is a ... |
7561a70ca3f36465b35aaea91315701217601df4 | weirdname404/courses | /math_thinking/15puzzle.py | 1,412 | 3.671875 | 4 | #bin/python3
import sys
def count_transpositions(p, c):
if len(p) <= 1:
return p, c
min_v = min(p)
min_vi = p.index(min_v)
if p[0] != min_v:
# swap
tmp = p[0]
p[0] = min_v
p[min_vi] = tmp
c += 1
res, c = count_transpositions(p[1:], c)
retur... |
02dabab0f655da76da24eb0ed88307b12ff9e41b | weirdname404/courses | /data_structures/stacks_and_queues/process_packages.py | 3,265 | 3.78125 | 4 | # python3
"""
You are given a series of incoming network packets, and your task is to simulate their processing
INPUT: The first line of the input contains the size S of the buffer and the number n of incoming network packets.
Each of the next n lines contains two numbers. i-th line contains the time of arrival A and
... |
48f3b40be5086ff7a6ff29cd8f44fd9b6659c812 | weirdname404/courses | /algorithms/warmup/fib_sum_sq_ld.py | 460 | 4.03125 | 4 | #python3
# Compute the last digit of the sum of squares of Fibonacci numbers till Fn
def fib_mod_sum(n):
mod_seq = [0, 1]
# mod is 10 -> pisano period is 60
pp = 60
fib_i = n % pp
for _ in range(1, fib_i):
mod_seq.append((mod_seq[-1] + mod_seq[-2]))
fn_seq = mod_seq[:fib_i + 1]
r... |
57616a7489577f9277a4b86e13e288784eff0bb7 | CNJayAndrew/DSA | /mergesort(review).py | 1,299 | 4 | 4 | #这里采用了归并的思想,正常人的思路都是先分后和。所以先看下面的函数,后看上面的。
def merge(list1,list2) :
templist = [] #这里创建的list是为了之后储存排序好的列表。
h = j = 0 #我们要从每个列表的0号位,也就是第一个数开始比较。
while h<len(list1) and j<len(list2) : #当这两个列表没有比较完的时候,循环不停止。
if list1[h] < list2[j] : #举例,当list1和list2相比较的时候,如果list1的大,则在templist中加入list1中的数。
... |
71c4494337d91c2cc242453cafbce2b0bb66c18d | Binnikarl/Max_int | /sequence.py | 199 | 3.921875 | 4 | n = int(input("Enter the length of the sequence: ")) # Do not change this line
n1 = 0
n2 = 1
n3 = 0
for i in range(n):
nsum = n1 + n2 + n3
n1 = n2
n2 = n3
n3 = nsum
print(nsum)
|
76f438d967a2ad7f1bd12f5b9b096b74ae130aa4 | inakicezonortega/arcade-labs | /lab04-camel/lab04-camel.py | 5,489 | 3.59375 | 4 | import arcade
import random
def menu():
print("0. Beber de la botella (agua+70, gasta 1 turno y 1 sorbo).\n"
"1. Caminar (distancia+(6-12), gasta 1 turno y 15 de energia).\n"
"2. Correr (distancia+(15-21), gasta 1 turno y 25 de energia).\n"
"3. Descansar (energia+75, gasta 1 tu... |
870d8536737e98f5e09e6475cea90552b8ae1aaf | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 4 - Style and Structure/73-multi-line-strings.py | 2,669 | 4.125 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 4. Style & Structure > Section 3:
# Multi-line strings (1/2)
'''
Sometimes we end up wanting to use very long strings, and this can
cause some problems.
If you run pycodestyle on this, you'll get the following message:
some_script.py: E501 line too l... |
861a628085be4eea68e5e32c6cab55f2d0f36838 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 2 - Strings and Lists, Part 1/29-f-strings.py | 1,068 | 4.3125 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 2. Strings & Lists Part 1 > Section 16: f-strings
# Do it in the terminal:
'''
f-strings is something that was added to Python in version 3.6—
so in order for this to work on your own computer, you must be sure
to have Python 3.6 or later. As a remin... |
7f513d0cd47b422fdb76932867b951ad66fdf38b | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 2 - Strings and Lists, Part 1/38-boolean-values.py | 535 | 3.796875 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 2. Strings & Lists Part 1 > Section 22:
# Boolean values
# Try them in interpreter
>>> True and True
True
>>> True and False
False
>>> False and False
False
>>> True or True
True
>>> True or False
True
>>> False or False
False
>>> True and True... |
5c237e8e3f59ca5485fec8ee416fb9580282db09 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 2 - Strings and Lists, Part 1/18-indexing-starting-letter-detection.py | 885 | 4.0625 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 2. Strings & Lists Part 1 > Section 8: Indexing
'''
write a function called start_K that checks whether a string starts
with the letter K.
If the string starts with K, the function should return True. If it
doesn't, the function should return False.
... |
8eafc4cab7035114ead9e844e3f5a57c3c489e01 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 2 - Strings and Lists, Part 1/24-slicing-word-triangle-exercise.py | 977 | 4.1875 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 2. Strings & Lists Part 1 > Section 12: Slicing(1/2)
'''
Exercise: Word triangle
find a partially completed for loop.
Goal is to finish the loop so that it prints out the following:
d
de
def
defi
defin
defini
definit
definite
definitel
definitely
'''... |
95e54eacc1da6c8c5b8724634c686b56b1ae1e41 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 3 - Strings and Lists, Part 2/43-mutable-vs-immutable.py | 905 | 4.3125 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 3. Strings & Lists Part 2 > Section 3:
# Mutable vs. immutable
'''
List are mutable (can be modified)
Strings are immutable (cannot be modified)
'''
# Exercise 1 - Mutable
print('\nExercise 1 - Mutable:\n')
breakfast = ['toast', 'bacon', 'eggs']
pri... |
f9ca6dad8f3dc6f8363fe1b8a49072604bb770ab | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 3 - Strings and Lists, Part 2/66-convert-string-into-list.py | 800 | 4.5625 | 5 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 3. Strings & Lists Part 2 > Section 17:
# Find and replace (1/2)
# Convert a string into a list
# Approach 1 (without using split method)
def list_conversion(string):
list = []
for index in string:
list.append(index)
return list
... |
46b0b93e3d86c6cc425459be309bd3bd15ed3d1c | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 2 - Strings and Lists, Part 1/19-range-function.py | 1,245 | 4.71875 | 5 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 2. Strings & Lists Part 1 > Section 9:
# The range function, revisited
'''
Earlier, we used the range function with for loops.
We saw that instead of using a list like this:
'''
print()
for side in [0, 1, 2, 3]:
print(side)
print()
# Range can ... |
7ddb50137c6bfc6465cebc77b14a99521a3bd591 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 2 - Strings and Lists, Part 1/36-methods-on-strings.py | 407 | 3.90625 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 2. Strings & Lists Part 1 > Section 21:
# Methods on strings
# There are many methods on strings. Some of them are: (Try them in interpreter)
>>> "banana".startswith("ban")
True
>>> "bonobo".startswith("ban")
False
>>> "bonobo".endswith("ban")
False
... |
9580691741d7e3c606279cd91512724f8c087993 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 3 - Strings and Lists, Part 2/56-break-exercise-no-repeating-words.py | 686 | 4.21875 | 4 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 3. Strings & Lists Part 2 > Section 10:
# Infinite loops and breaking out
# Exercise - Repeated words:
'''
Write an function to store the words input by the user
and exit the while loop when a word is repeated.
There's another way to exit from an in... |
4e4ed96929cf2fe0808c10535714fb92c2f7e6e8 | vamshi-krishna-prime/Programming_Nanodegree | /6. Python, Part 2/Lesson 3 - Strings and Lists, Part 2/45-augmented-assignments.py | 941 | 4.59375 | 5 | # Udacity > Intro to the Programming Nanodegree >
# Python part 2 > 3. Strings & Lists Part 2 > Section 4:
# Augmented assignments
# Try them on interpreter
>>> n = 1
>>> n = n + 2
>>> n = 2
>>> n = n * 3
>>> n
6
>>> n = 5
>>> n = n / 2
>>> n
2.5
>>> n = 10
>>> n = n - 6
>>> n
4
>>> s = "Hello"
>>> s = s + " wor... |
612dbf123309396abbe8755f327c1e0eed8d5303 | divineBayuo/NumberGuessingGameWithPython | /Number_Guessing_GameExe.py | 1,959 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 3 10:52:42 2021
@author: Divine
"""
#putting both programs together
#importing required libs
import tkinter as tk
import random
import math
root = tk.Tk()
canvas1 = tk.Canvas(root, width = 300, height = 300)
canvas1.pack()
#making the game cod... |
689dd9fd88703949137e421c20c9a31c88f60448 | bbongcaron/ExpressionEvaluation | /Evaluator.py | 608 | 3.734375 | 4 | import Expression as Expr
def main():
while True:
expr = input("\nEnter the expression, or hit return to quit => ")
if not expr:
break
vars = []
arrays = []
Expr.makeVariableLists(expr, vars, arrays)
in_filename = input("Enter variable values' file name, ... |
889e61decfe5895ef0f60e754b16e1068f3e0907 | yuzuNeko/hpltool_beta | /convert.py | 271 | 3.734375 | 4 |
"""将我曾经使用过的类型,文件都转换为可以操作的,熟悉的python数据结构
"""
def convert_dict(obj,obj_type=None,interface=None):
"""将一切可能的类型,转换为字典
"""
if obj_type==None:
print('没有指定类型')
return |
41ad58c38b7d1e3730fab85f2d7600b43e91685f | goateater/MyCode | /python_refresher/random_numbers.py | 655 | 3.890625 | 4 | #!/usr/bin/env python
from random import *
print random()
print("Random numbers")
print("Using the random module, we can generate pseudo-random numbers. The function random() generates a random number "
"between zero and one [0,0.1 .. 1]. Numbers generated with this module are not truly random but they are en... |
cca6ea9561c63a741e72107d537b70054a4220c2 | goateater/MyCode | /learn_python/basic_string_operations.py | 785 | 4.5 | 4 | #!/usr/bin/env python
bso = """
Basic String Operations
----------------------
Strings are bits of text. They can be defined as anything between quotes:
As you can see, the first thing you learned was printing a simple sentence. This sentence was stored by Python as a string.
However, instead of immediately printin... |
d0a923f77cc18f1b83c5a69ede4e8c1028fd8283 | Mariog75/coding_challenges | /python/Strings/IsUnique.py | 521 | 3.609375 | 4 | #O(n^2)
def isunique ( str ):
for i in range(len(str)):
ch = str[i]
for j in range(i+1, len(str)):
if(ch == str[j]):
return 0
return 1
#O(n)
def isuniquebetter ( str ):
if(len(str) > 128):
return 0
arr = [None] * 128
for ch in str:
i... |
fdd317c6c7e5e98e464080e1d327a28b2a5dda75 | ayelet-w/Excellenteam_Bootcamp_Exercises | /Python/functions/increase.py | 520 | 3.828125 | 4 | def increase(key_, amount=1):
def increase_func(dict_input):
dict_input[key_] += amount
return increase_func
def salary_retires(employee):
years = 70 - employee["age"]
i = 1
increase_the_employee_age_by_2 = increase("age", 2)
increase_the_employee_salary_by_1000 = increase("s... |
e0109ba7a079cb4ef8c3ebfc51e3a58187565377 | SSDC-SLIET/practice | /Week-06/1. Primitive/Solutions/Ashish kumar(GCS-1840024)/Solution 02.py | 137 | 3.53125 | 4 | #code# code
n = int(input())
for i in range(0,n):
t = int(input())
y=0
for i in range(1,t+1):
y=y+i*i
print(y)
|
ba969eff50596dc5532a6d806e40dd10dca135a1 | SSDC-SLIET/practice | /Week-05/2.Auxiliary/Solutions/Adarsh Prashar/solution-3.py | 253 | 3.578125 | 4 | def Count_of_Matchstick_need_to_Pick():
Matchstick = int(input())
if Matchstick % 5 == 0:
return -1
return Matchstick%5
if __name__ == '__main__':
for i in range(int(input())):
print(Count_of_Matchstick_need_to_Pick())
|
74d2094838fafc58f62cb06d8b15ea064577f0ba | SSDC-SLIET/practice | /Week-05/1.Primitive/Solutions/ADARSH PRASHAR (GCS-1940043)/code-1.py | 128 | 3.609375 | 4 | for i in range(int(input())):
num1,num2=map(int,input().split())
print(num1+num2 if (num1+num2)<12 else (num1+num2)%12)
|
e4c42761fef2ce12de9fee370e48e09b142e0b0f | Buckley212/Buckley | /number_guess.py | 812 | 4.0625 | 4 | import random
# Game Loop
def pick_winner():
# Getting the player's number
player_guess = input("Please input a number from 1 to 5: \n")
player_number = int(player_guess) #Turning it into an integer
computer_number = random.randint(1, 6)
if player_number <6 and player_number > 0 and... |
a2fd6f4a7e2f6006fcf1f883c3a5a674aacf7155 | triptigupta346/python-practice | /swapnode_linklist.py | 1,246 | 4.0625 | 4 | # Problem Statement:
# You are given one non-empty linked lists representing some integers and one k value. you need to swap the first kth value of linked list with the last kth value in the one iteration only
# Example:
# Input: (1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7) with kth value 3
# Output: 1 -> 2 -> 5 -> 4 -> 3 -... |
0c4fdb8ae594391a68edc233800bf65cb8b1ad2e | git-Pqrd/scraper_eparts | /sort_cell.py | 961 | 3.859375 | 4 | import csv
def insertion_sort(arr, simulation=False):
for i in range(len(arr)):
cursor = arr[i]
pos = i
while pos > 0 and arr[pos - 1] > cursor:
# Swap the number down the list
arr[pos] = arr[pos - 1]
pos = pos - 1
# Break and do the fi... |
dbe12f4cccd2a3b26cc0528d41de9d4fc2325bba | ramishtaha/Higher_Lower_Game | /main.py | 927 | 3.640625 | 4 | from art import logo, vs
from game_data import data
from os import system
import random
import os
def cls():
os.system('cls' if os.name=='nt' else 'clear')
a = random.choice(data)
b = random.choice(data)
def print_choice(id, c):
print(f"Compare {id}: {c['name']}, {c['description']}, from {c['country']}.")... |
071013cfbf294372611a72b440dfbe7bc3b9bf2b | Kushal997-das/30-days-code | /Day8.py | 479 | 3.5 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import sys
n = int(sys.stdin.readline().strip())
phoneBook = dict()
for i in range(0, n):
entry = sys.stdin.readline().strip().split(' ')
phoneBook[entry[0]] = entry[1]
query = sys.stdin.readline().strip()
while query:
phoneNumber = ph... |
0c170d9aea8a1fc0ecd4f1ef0e442bd554c99d97 | JolloDede/Fibonacci | /Fibonacci.py | 2,319 | 3.59375 | 4 | # %% für time.sleep
# import time
import os
import locale
locale.setlocale(locale.LC_ALL, '')
# %%fibo kann ich aber nicht zählen
def fibo(n):
global counter
counter += 1
if n <= 1:
# %%wenn n = 1 ist dann wird es beendet
return n
else:
# %%wir einfach so weit he... |
9e6244107b24bc44311159c3333576366912dbc3 | DevZeyad/uri-online-judge-solution-inpython | /1040.py | 535 | 3.625 | 4 | N1,N2,N3,N4 = input().split()
Avg = ((float(N1)*2) + (float(N2)*3) + (float(N3)*4) + (float(N4)*1)) / 10
print("Media:", '%.1f' % Avg)
if Avg >= 7.0:
print("Aluno aprovado.")
elif Avg < 5.0:
print("Aluno reprovado.")
elif Avg <= 6.9:
print("Aluno em exame.")
newScore = float(input())
print("Nota ... |
a976e7877b8746ddc5091193d0c675248db24443 | DevZeyad/uri-online-judge-solution-inpython | /1043.py | 304 | 3.5625 | 4 | A,B,C = input().split()
if (float(A) < float(B)+float(C)) and (float(B) < float(A)+float(C)) and (float(C) < float(B)+float(A)):
Perimetro = float(A) + float(B) + float(C)
print("Perimetro =",'%.1f'%Perimetro)
else:
Area = 0.5 * (float(A)+float(B)) * float(C)
print("Area =",'%.1f'%Area)
|
56c46cafefc242878aeabcc1fb360a9f08d73499 | DevZeyad/uri-online-judge-solution-inpython | /1037.py | 315 | 3.859375 | 4 | value = float(input())
if value >= 0 and value <= 25:
print("Intervalo [0,25]")
elif value > 25 and value <= 50:
print("Intervalo (25,50]")
elif value > 50 and value <= 75:
print("Intervalo (50,75]")
elif value > 75 and value <= 100:
print("Intervalo (75,100]")
else:
print("Fora de intervalo")
|
cee707fd9a104fa037f0a74491ca7376eca1229d | david-kubecka/pyrebrickable | /tests/cli/__init__.py | 1,485 | 3.546875 | 4 |
def parse_docstring(docstring):
"""Parse the docstring into its components.
:returns: a dictionary of form
{
"short_description": ...,
"long_description": ...,
"params": [{"name": ..., "doc": ...}, ...],
"returns": ...
... |
770fe3a9ba3ccec8e4acb13ed176f1ecebea4717 | minhphuc010194/Python | /index.py | 3,251 | 3.515625 | 4 | #===============================REGEX=======================
#Demo 1--------------
'''
import re;
regex1 = re.compile(r'anh (.*?) trai');
type(regex1);
chuoiDemo = "anh Phuc dep trai qua";
kq = regex1.search(chuoiDemo);
name = kq.group(1);
print(name)
'''
#Demo 2 ----------------
# import re
# noidung = '''
# nhat k... |
ae6778774204e11db260e70f9ff81764f7a16c2e | bcouchman/CPSC481 | /vectory.py | 1,065 | 3.765625 | 4 | class Vector:
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y
def __repr__(self):
tmp = (self.x, self.y)
return tmp
def __add__(self, other):
return Vector(self.x + other.x, self.y + other.y)
def __sub__(self, other):
return self.__add__(-1 * ot... |
9873b348f11101191dab7bee497aef67852f1955 | ssangitha/guvicode | /sum_of_square_digit.py | 87 | 3.65625 | 4 | n=input()
s=0
for i in n:
a=int(i)**2
s=s+a
print(s)
#....sum of square of digit....
|
70775252f224f3f0333e5eacaa5c279333b8b3ad | ssangitha/guvicode | /hunter_28.py | 98 | 3.515625 | 4 | s=input()
a=""
for i in s:
if i not in a:
a=a+i
print(a)
#...........no duplicates........
|
3b4ce092c4c45ad52ba2393931135e2ac5c421e6 | ssangitha/guvicode | /nearest_power_of_2.py | 81 | 3.546875 | 4 | s=input()
n=int(s,2)
x=n
while 1:
if x&(x-1):
x=x+1
else:
print(x)
break
|
067d85085cef9d3e7bba584ec59b4cfa6d08c7a5 | ssangitha/guvicode | /primenum_less_than_n.py | 186 | 3.515625 | 4 | n=int(input())
a=""
if n==2:
print("0")
else:
for i in range(2,n):
for j in range(2,i+1):
if i%j==0:
break
if i==j:
a=a+str(i)+" "
print(a.strip())
#..........prime....
|
f38090aa5f1f653ed07ebf1f7111c5a6d71945fc | ssangitha/guvicode | /repeated_string.py | 148 | 3.640625 | 4 | n=input()
for i in n:
if n.count(i)!=1:
print("yes")
break
elif i==n[-1]:
print("no")
#.....check whtr number contain repeated digit.....
|
822ab81266507c73baeddd8d03386089254388fc | ssangitha/guvicode | /factors.py | 99 | 3.546875 | 4 | n=int(input())
a="1 "
for i in range(2,(n//2)+1):
if n%i==0:
a=a+str(i)+" "
a=a+str(n)
print(a)
|
f7724bb225e5b48ce67bea5da7ddfa44d27dc211 | ssangitha/guvicode | /swap_bitwis.py | 86 | 3.671875 | 4 | a,b=map(int,input().split())
a=a^b
b=a^b
a=a^b
print(a,b)
#.........swap.....spl.....
|
8d01d2395ddc8d9e7c57e9564ecb4d4a2921a128 | jakeOmega/solarSystemModel | /system.pyw | 15,257 | 3.515625 | 4 | from tkinter import *
from world import *
#constants
initRunTime = 32 # How often to advance by one timestep in the simulation initially
initWidth = 800 # default view width
initHeight = 600 # default view height
drawTime = 1000/10 # How often (in ms) to refresh the screen
zoomAm... |
97229c91f9c04d9c7be8df207cc2af2202482527 | taylortom/AlgorithmicFuntimes | /QuicksortSimple.py | 822 | 4.0625 | 4 | #
# Basic Quicksort
# Time: O(n log n) O(n2) worst-case
# Space: O(n)
#
# List is split into two at a pivot point half way through the list
# Items smaller than the pivot go into one list, larger items in the other
# The algorithm is called recursively on the two lists
#
import Random
# the list to sort
list = Random... |
4774fda0bd3a69a31a190bb39fecad1f58825cb2 | DavidC117/prueba_python1 | /5.py | 311 | 3.96875 | 4 | print ("suma de numeros")
num1 = int (input("dame un numero"))
num2 = int (input ("dame otro numero"))
resultado = num1+num2
print("El resultado de la suma es:",resultado)
cantidad = int (input ("Digita tu cantidad"))
B = float (input ("dame el iva"))
print ("El iva es: ", B*cantidad)
input ("...")
|
72787983b7803ddedc6faee425b111f4c5e7d1a2 | vonderchild/hackerearth | /basics/2.py | 907 | 4.03125 | 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.
Input :
test cases,t
two strings a and b, for each test case
Output:
number of alphabet... |
0f245a4eaa759a9f6fa2f39fd166f17c4960aa99 | vonderchild/hackerearth | /basics/17.py | 960 | 3.875 | 4 | """
You are given a number N. You can perform the following operations on N any number of times:
> If N is even, divide N by 2.
> If N is odd, replace N with 3N+1.
Your task is to find out, for a given N,
if it is possible to reach the number 1 after performing the above two valid operations on N any number ... |
d515664d4785021a539e79fcbf0bc74d7383b4bd | starVader/Python | /PythonScripts/redx search.py | 263 | 3.78125 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import re
N = int(raw_input())
for i in range(N):
mob = str(raw_input())
match =re.search(r'(^[7-9]\d{9}$',mob)
if match:
print "YES"
else:
print "NO"
|
571d37b795389bf83a29ec19249c4d7d6e21640e | starVader/Python | /PythonScripts/inheriting existing class.py | 624 | 3.890625 | 4 | class AthleteList(list):
def __init__(self,namea,dob =None,times = []):
list.__init__([])
self.name = namea
self.dob = dob
self.extend(times)
def top3(self):
return (sorted(set([sanitize(t)for t in self]))[0:3])
def sanitize(timestring):
if '-' in timestring:
... |
b92a3ad55eb8dd12b7915ec06882abe1b500a7a4 | starVader/Python | /PythonScripts/Class with complex no.py | 1,535 | 3.90625 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
import math
class Complex:
def __init__(self,real,imag):
self.r = real
self.i = imag
def __add__(obj1,obj2):
realr = obj1.r + obj2.r
imagr = obj1.i + obj2.i
print "%.2f+%.2fi" % (realr,imagr)
... |
9561d1cbaacca4fc74c779517732dcbd693d298b | starVader/Python | /PythonScripts/map and lambda.py | 265 | 3.578125 | 4 | def fibn(N):
result = []
a,b = 0,1
i = 0
while( i < N):
result.append(a)
a,b = b,a+b
i = i + 1
return result
N = int(raw_input())
final = []
mylist =fibn(N)
print list(map(lambda i: i*i*i,mylist))
|
62ea37df12d60f19fe7e430856fc52f9f186f7fa | fcvlh/python-cursoemvideo | /d005.py | 148 | 3.921875 | 4 | n1 = int(input('Digite um número: '))
a = n1-1
s = n1+1
print('Para o número {}, o seu antecessor é {} e o seu sucessor é {}'.format(n1, a, s))
|
26f1b7d64c34cce8530ffbc109aaeb0728e48fca | fcvlh/python-cursoemvideo | /scripts.python/Aula04/desafio03.py | 132 | 3.90625 | 4 | print('==== Desafio 03 ====')
numero1=input('Primeiro número:')
numero2=input('Segundo número:')
print(int(numero1)+int(numero2))
|
16178fa0a3ae5091e94262919365b27cc0b9471b | frannythebanny/NAO-EPITECH | /bazar/behaviors/rssfeed/languageProcessing.py | 4,536 | 3.59375 | 4 | import os, re, pickle
class LanguageProcessing:
"This class provides methods to process language (eg: detect lang)."
def __init__(self, sDictionaryPath = "/opt/appu/data/pkl"):
"The path where the data are stored/to be stored."
self.sDictionaryPath = sDictionaryPath # TODO : throw an exception if it's not ... |
53b3a2043e2690029c32d11c4d176dc1d6749e4c | Jan-Gys/Honours | /v.0Pre-Class/BetterBase64.py | 1,630 | 3.5 | 4 | """
Jan-Gys Malan
15462757
"""
import math
s = open("encode.txt","r")
#decode_table = {}
def words_2_decimal():
n = ()
for item in s:
for letter in item:
n = int(ord(letter))
decimal_2_binary(n)
def decimal_2_binary(n):
'''convert denary integer n to binary string bStr'''
... |
5b146354c2b8c2604c71cca899d8be82466c7049 | parkerdgabel/CS120Assignment11 | /huffman.py | 4,237 | 4.15625 | 4 | def _huffman_walk(tree, func=lambda x: None, huff_seq=[]):
"""Walks a huffman tree based on the sequence.
Parameters: tree is a node
func is the function to apply.
huff_seq is the huffman sequence
Returns: None
Pre-conditions: None
Post-conditions: None
"""
if... |
d3abb306f36f6fe994aacb555ea2202f8de80c5b | eaesh/Artificial-Intelligence | /Knapsack-Search/iterativeDeepening.py | 1,003 | 3.59375 | 4 | import knapsack
def solve(targetValue, maxWeight, items):
stateSpace = getStateSpace(knapsack.Knapsack(), maxWeight, items)
solution = getSolution(targetValue, stateSpace)
if solution is not None:
print([item.name for item in solution.items])
else:
print("No Solution")
def getStateSpac... |
580ad2ab9d46cc5fc0bedd6b0caab227b5bc9532 | KVSRoyal/SORTASample | /Example.py | 1,204 | 3.6875 | 4 | # An example of our custom sorta implementation
from SORTA import SORTA
# Make a SORTA object for matching
sorta = SORTA()
# We will only print the top match
match = sorta.get_matches('congenital nose anomalies')[0]
print('"congenital nose anomalies" matched to "{}", with code HP:{} and estimated accuracy of {}%'.for... |
a23e9b0ea28b3f1ca240484609533c7dcbce5c6c | BraydenChumbley/SoftwareSearch | /terminations.py | 4,713 | 3.796875 | 4 | # My CS teacher preaches adding a header to every file so this now exists
# Author: Brayden Chumbley
# Description: A program that searches for software to be removed in event of a termination
# Yeah, I have no idea what is actually going on in this file. It really is just
# a bunch of solutions on stackover... |
6109b5782b949224aeab7149e2bad165570fd792 | baeeunwoo/exam | /variable.py | 507 | 3.984375 | 4 | '''
변수입력과 연산자
a = input("숫자를 입력하세요: ")
print(a)
# a, b = input("숫자를 입력하세요: ").split()
# print(type(a))
# c = a + b
# print(type(c))
# print(c)\\
# a, b = input("숫자를 입력하세요: ").split()
# a = int(a)
# b = int(b)
# print(type(a))
a, b = map(int, input("숫자를 입력하세요: ").split())
print(a + b)
print(a - b)
print(a * b)
... |
85c68935e566688a0eb7118c6be15e395ad7792a | nghokui/ffbng | /code/dbco.py | 6,670 | 4.1875 | 4 | import os, sqlite3
class DBConnector():
def __init__(self, in_db_path, in_db_name):
""" Initialization method attempts to open the database and create
the connection and cursor objects.
Raises an exception if the database does not exist at the path.
"""
if not os.pa... |
0e8a851da2fdde528f0d5c11cbe043245d6f3b3c | retzstyleee/Chapter-06-ProTek | /latihan/lat1.py | 296 | 3.609375 | 4 | def isPythagoras(a, b, c):
print ('a = ', a, 'b = ', b, 'c = ', c, ' => ', (a ** 2) + (b ** 2) == (c ** 2))
a = 3
b = 4
c = 5
isPythagoras(a, b, c)
a = 5
b = 9
c = 12
isPythagoras(a, b, c)
a = 8
b = 6
c = 10
isPythagoras(a, b, c)
a = 7
b = 8
c = 11
isPythagoras(a, b, c) |
9e3823d617a37ceac4153ac3f0de287b448d4d4d | dzhemz/iate-prg-course-2021-ZDD | /myFib.py | 498 | 4 | 4 | # Алгоритмы и структуры данных шаг 2.2 задача 1
def fib(n):
if n == 1:
return 1
elif n == 2:
return 1
else:
value1 = 1
value2 = 1
for i in range(n - 2):
if i % 2 == 0:
value1 += value2
else:
value2 += value1
... |
fda905fe3749cc743490f832440692d0cd9bee96 | Shaileshsachan/Machine_Learning | /data_preprcossing.py | 1,536 | 3.609375 | 4 | import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.impute import SimpleImputer
dataset = pd.read_csv('data.csv')
x = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values
imputer = SimpleImputer(missing_values=np.nan, strategy='mean')
imputer.fit(x[:, 1:3])
x[:, 1:3] = imputer.tr... |
aaee6eab6646010e9d230ef1a949e2dee5a16eae | Aditya-Panchwagh/Optical-Character-Recognition- | /ocr_with_api.py | 1,593 | 3.53125 | 4 | import cv2
import numpy as np
import requests
import io
import json
img = cv2.imread("Annotation 2020-04-25 215317.jpg") # cv2.imread() method loads an image from the specified file
height, width, _ = img.shape # to take only selected part of the image
# Cutting image
#roi = img[0:... |
e500f68bcfd4e4fa12f4615141aae972b0730a1f | yudhaprimadiansyah/MyRandomPythonScript | /crypto.py | 495 | 3.671875 | 4 | # Pada Suatu Hari, Wik_Wik dikirimi pesan oleh seseorang dari klub pecinta serangga, namun pesan tersebut terenskripsi, orang tersebut hanya
# memberikan Kunci dan sebuah potongan kode program yang menurutnya akan sangat berguna, kunci yang diberikan yaitu = PECINTASERANGGA
# coba bantu Wik_Wik memecahkan kodenya
def e... |
0c7343e278e88fc6faecf2b8ec610ed3644bed9d | DeepeshAggarwal/tictactoe | /tic-tac-toe.py | 3,458 | 3.578125 | 4 | #!/bin/python
import random
import copy
CHOICE = ()
def gameOver(player, board, depth):
if board[0][0] == board[1][0] and board[1][0] == board[2][0] and board[0][0] != '_':
if board[0][0] == player:
return 10-depth
else:
return depth-10
elif board[0][1] == board[1][1] and... |
b8fb82b5adca11e20e7908cc18dab445b72b74d6 | jfowlw/2-Layer-vs-3-Layer-NN-Project | /3LayerNN.py | 4,718 | 3.703125 | 4 | import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
class NeuralNetwork:
def __init__(self, num_input, num_hidden, num_output):
self.input_dim = int(num_input)
self.output_dim = int(num_output)
self.hidden_dim = int(num_hidden)
... |
308cd92ef73f7a5f041e50c53608fc23aa651ff9 | JunkaiCheng/Pong-Game | /deep.py | 7,891 | 3.5 | 4 | '''
Each row in expert policy:
ball_x, ball_y, velocity_x, velocity_y, paddle_y, action
Action:
0 - move up
1 - stay
2 - down
This program will build a deep network that classidies states into action classes
Minibatch Gradient-descent is used to train this network
Four Layer neural network with 256 units per layer, ... |
e69fbe22b7ba3679a9bf25e5f9d05e8b9787655d | surathjhakal/python_codes | /armstrong_number.py | 332 | 4.03125 | 4 | def armstrong(n):
total=0
temp=n
while n>0:
r=n%10
total+=r**3
n=n//10
if temp==total:
print("the number",temp,"is a armstrong number")
else:
print("the is not a armstrong number")
def main():
n=int(input("enter a number"))
arm=armstrong(n)
print(... |
d4e76934637812fdfbbc6876602116e63d7d566a | surathjhakal/python_codes | /palindrome_numbe.py | 278 | 3.953125 | 4 |
def palindrome(n):
sum=0
temp=n
while n>0:
r=n%10
sum=sum*10+r
n=n//10
if temp==sum:
return "true"
else:
return "false"
def main():
n=int(input("enter a number"))
palin=palindrome(n)
print(palin)
main()
|
2c2a5f83d2c249f39f5c6e346ce93f79dc8c41d2 | AP-MI-2021/lab-2-RaulParaschivBucur | /main.py | 3,941 | 3.703125 | 4 | # 11)
def get_leap_years(start: int, end: int) -> list[int]:
"""
Input: Doi ani --> start, end
Output: O lista cu anii bisecti dintre anii introdusi
"""
lst = []
if (start > end) or ((start == 0) and (end == 0)):
return lst
for idx in range(start, end + 1):
if ((idx % 4 == 0)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.