blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
6049aa35b768b73012a8f91ae874dbb1181ab485 | dawidbo/algorithms | /Codility/countDiv.py | 550 | 4 | 4 | '''
that, given three integers A, B and K, returns the number of integers within the range [A..B]
that are divisible by K, i.e.:
{ i : A ? i ? B, i mod K = 0 }
For example, for A = 6, B = 11 and K = 2, your function should return 3,
because there are three numbers divisible by 2 within the range [6..11], namely 6, 8 ... |
02dc573984175a72c07d73a11f686ea85a1f1524 | milton4code/pythonHello | /if_else.py | 204 | 3.859375 | 4 | age = 20
if age > 18:
print("成年人")
elif age >5:
print("小崽子")
else:
print("没有了")
s = input("出生:")
_s = int(s)
if _s > 2000:
print("00后")
else:
print("00前") |
5a3852040bf00b3d4ea4daee5f399307a6f40f74 | Marm00taa/Treco | /LISTA 8/EXERC_1.py | 826 | 3.640625 | 4 | import sys,time,os,math
nome=str(input("digite o seu nome: \n"))
email=str(input("digite o seu e-mail: \n"))
idade=int(input("digite a sua idade: \n"))
telefone=int(input("digite o seu telefone: \n"))
rua=str(input("digite o seu endereço: \n"))
numero=int(input("digite o número da sua casa: \n"))
cep=int(input("digite... |
1b6d2557bca7d67e7719b530f04c936bafebfc3d | markmelnic/VU-Intro-Py | /Module 3/Pizza/pizza-mmc560.py | 728 | 3.71875 | 4 | """ Assignment: pizza
Created on 28 oct. 2020
@author: Mark Melnic """
M_INGREDIENTS = 10
M_USING = 3
L_INGREDIENTS = 9
L_USING = 4
def factorial(number: int) -> int:
prod = 1
for n in [number - i for i in range(number)]:
prod *= n
return prod
def possibilities(ingredients: int, used: ... |
ce5c873d5a69fc375031dcf02a178ce972197b52 | tanmaya191/Mini_Project_OOP_Python_99005739 | /6_OOP_Python_Solutions/aug31/valid_email.py | 179 | 3.90625 | 4 | import re
print("Enter a email address")
y = input()
m = re.match(r'[A-Za-z](\w|-|\.|_)+@[A-Za-z]+\.[A-Za-z]{1,3}', y)
if m:
print("Valid")
else:
print("Invalid")
|
f8ade6bce1617651df3359a4f6de3ec75b5c150a | kammitama5/Distracting_KATAS | /changeitupbuggy.py | 531 | 3.84375 | 4 | def changer(string):
arr = []
x = list(string)
for i in x:
if i == " " or i.isdigit():
a = i
arr.append(a)
elif ((i.isalpha())):
a = chr(ord(i)+1)
if ((a == "a") or (a == "e") or (a == "i") or (a == "o") or (a == "u") or (a == "A") or (a == "E") or (a ==... |
468cfa27c9a35f71f207a72c5cb95227818f1478 | Sargarin/Python-Projects | /Design Pattern - Dependency Injection/main.py | 3,016 | 3.53125 | 4 | """
W celu wykonania zadania wybrałem framework python Injector,
wymagał on jedynie komendy: pip install injector oraz dodania modułu do IDE pycharm
Mimo obszernego researchu i zrozumienia idei DI oraz IOC nie byłem w stanie zrozumieć do końca w jaki sposób powinno zostać
to zastosowane w podanym zadaniu, może to... |
59c35436eaccf4dfafa9f6624ea0889a278b2c2e | AntonValk/Machine-Learning | /Assignment-1/Question-1.py | 1,270 | 3.875 | 4 | # COMP 551 Assignment 1
import numpy as np
import matplotlib.pyplot as plt
# Question 1
def generate_student_days(num_days):
random_variable = np.random.uniform(0,1,num_days)
event_log = np.zeros(4,dtype=int)
for element in random_variable:
if element <= 0.2:
event_log[0] += 1
# Case movies
el... |
6ab69dc3ba30b286bc931508c5f22843bfc5d3f8 | zbpatel/CS229-Project | /utils.py | 3,079 | 3.546875 | 4 | # Helper functions for creating train, test and validation sets
def split_by_day(df, train_range, test_range):
# train range and test range should be length 2 arrays of strings formatted "YYYY-MM-DD"
train_s, train_e = train_range
test_s, test_e = test_range
# partitions a DateTimeIndex-indexed datafram... |
76d05bddae392b72e89e8aa8383e54099236d5d6 | aHojo/PythonPractice | /randomExercises/conditionalFunc.py | 283 | 4.03125 | 4 | def stringLength(stringu):
if (type(stringu) == int):
return "Sorry integers do not have any length"
elif (type(stringu) == float):
return "Sorry float do not have any length"
return len(stringu)
print(stringLength(10))
print(stringLength("sladfkjas"))
|
479d93e3ac70995866e3b274c617ef31fc3608fb | kcollett1/daily_coding_problem | /solved/prob37/prob37.py | 1,036 | 4.375 | 4 | # The power set of a set is the set of all its subsets.
# Write a function that, given a set, generates its power set.
# Given {1, 2, 3}, it should return
# {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
# You may also use a list or array to represent a set
## I am assuming that order of power sets does not ma... |
702ced39c302b7d10db8b125c8cb4e4798efaa84 | akhilbommu/May_LeetCode_Challenge | /Day18-PermutationInString.py | 379 | 3.515625 | 4 | from collections import Counter
class PermutationInString:
def checkInclusion(self, s1: str, s2: str) -> bool:
for i in range(len(s2)-len(s1)+1):
if Counter(s1) == Counter(s2[i:i+len(s1)]):
return True
return False
obj = PermutationInString()
print(obj.checkInclusion("ab... |
f7c3b70a306950a85ef28e9afe16dcc0022d68b3 | Evelyn-agv/Ejercicios.Extra-POO | /examen/pregunta 9.py | 416 | 3.828125 | 4 | class Examen:
def __init__(self, lista=[]):
self.lista= lista
def ListaMenor(self,num):
listaMenor=[] #"ERROR"-->Es una lista no una tupla
for menor in self.lista:
if num > menor: #"ERROR"-->Se busca los numeros menores, no mayores
listaMenor... |
a13ca08a57ba34b85b33395974443340022bee9f | abhisheksingh75/Practice_CS_Problems | /Strings/Implement strStr().py | 1,382 | 3.984375 | 4 | """
strstr - locate a substring ( needle ) in a string ( haystack ).
Try not to use standard library string functions for this question. Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
NOTE: Good clarification questions:
What should be the return value if the... |
73a6dbfd2e01345a128800aa5a9b823effa4eeab | Deys2000/Basic-Python-Tutorial | /28-30 Tkinter module graphics/randomTriangles.py | 818 | 4.15625 | 4 | print('''python program #28
Hashir - June 1 2018
This program is an intro to TKINTER module
It will display lots of multicolored triangles
''')
from tkinter import*
import random
tk = Tk()
canvas = Canvas(tk,width=450,height=450)
canvas.pack()
colors = ['blue','red','green','cyan','yellow','black','magent... |
db4b5f47bd227db1e0791243c8adf8a2cd27d482 | tcvanthiel/Image-Compression | /image_analysis.py | 1,292 | 4.0625 | 4 | import matplotlib.pyplot as plt
import numpy as np
def decompose_rgb(image):
"""
Decompose rgb image into its red, green and blue components. Output three arrays
"""
image_r = image[:,:,0] #Extract the red values from the RGB code
image_g = image[:,:,1] #Extract the green values from the RGB code
... |
ce107e0082896ebd3ca7bde7cc77eafee18dc0e9 | albong/pairsearch | /pairsearch.py | 2,675 | 4.4375 | 4 | #!/usr/bin/python3
"""
https://docs.python.org/3/library/tkinter.html
https://likegeeks.com/python-gui-examples-tkinter-tutorial/
"""
import tkinter as tk
import tkinter.scrolledtext
STARTING_PAIRS_TUPLE = ("(0, 1) - Trivial", "(13/84, 55/84) - Bourgain", "(9/56, 37/56) - Bombieri and Iwaniec", "(89/560, 369/560) - Wa... |
ce5284bd0b409e1f194e69ef34ca298bf609dfa6 | sumit-kushwah/oops-in-python | /files/Exercise Files/Ch 1/typecheck_start.py | 824 | 4.3125 | 4 | # Python Object Oriented Programming by Joe Marini course example
# Checking class types and instances
class Book:
def __init__(self, title):
self.title = title
class Newspaper:
def __init__(self, name):
self.name = name
# Create some instances of the classes
b1 = Book("The Catcher In The ... |
f1dde03aaa244e510528e454a7d7a73185c581b9 | KRHS-GameProgramming-2019/Madlibs---Even-Sam-and-Roxanne | /Story1.py | 1,449 | 3.84375 | 4 |
#Evan
from Getters import *
def Story1(debug = False):
if debug: print("Story1 Function")
print("\n")
friendName1 = getWord("Enter a name: ", debug)
sport1 = getSport("Enter a sport: ", debug)
Place1= getPlace("Enter a place (proper noun): ", debug)
animal1 = getAnimal("Enter an animal: ", d... |
20ac3fd69b8988a6e4e93d4fd94eb0369e089e25 | nischalshrestha/automatic_wat_discovery | /Notebooks/py/steffanj/titanic-preprocessing-eda-and-ml-in-python/titanic-preprocessing-eda-and-ml-in-python.py | 62,651 | 3.875 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Introduction
# This is my first Kaggle experience, and one of the first machine learning projects that I wrote in Python.
#
# When the RMS Titanic sank in 1912, 1502 out of 2224 passengers and crew members died. There were not enough lifeboats for everyone. In the Hollywood... |
d1786fd258af242ec9e578fbf0f50ac039048747 | ashokjain001/Coding_Practice | /Sorting/bubblesort.py | 753 | 4.1875 | 4 | '''Python implementation of Bubblesort
Bubble sort has a run time of O(n^2)
After each pass the largest element is pushed
towards the end and the Iteration continues
till all the elements are in correct position'''
def bubblesort(array):
l=len(array)
for i in range(l-1):
for j in range(l-i-1):
if array[j]>arra... |
d2fd3db904a60342b8e3940cf2f6eb0b33fdddf0 | rsamit26/InterviewBit | /Python/Strings/StringMath/MultiplyStrings.py | 649 | 3.984375 | 4 | """
Given two numbers represented as strings, return multiplication of the numbers as a string.
Note: The numbers can be arbitrarily large and are non-negative.
Note2: Your answer should not have leading zeroes. For example, 00 is not a valid answer.
For example,
given strings "12", "10", your answer should be “120”.... |
0cd77939457585e9d4548ee92593e27a6748f13f | yehonadav/python_course | /exercises/level_1/games/guess_with_hints.py | 3,405 | 4.09375 | 4 | class GuessGame:
import sys
if len(sys.argv) > 1:
guess = sys.argv[1]
else:
guess = "piggy love bunny"
words = guess.split(' ')
words_length = len(words)
hint_word_edges_range = range(2 + words_length, 2 + 3 * words_length, 2)
def __init__(self):
self.hints = 0
... |
33c74a9352ac8cad19ec162c77187d5a18d87e2d | mohdomama/minimax | /min_max.py | 2,138 | 3.5 | 4 | class Min_Max():
def is_winning(self, board, player):
for i in range(0,9,3):
if board[i] == board[i+1] == board[i+2] == player:
return True
for i in range(3):
if board[i] == board[i+3] == board[i+6] == player:
return True
if board[0]... |
0685194db19453af6dcacf9f7b0bfca904a10e16 | gdevina1/MIS3640-Repository | /Session 3/Session3InClass.py | 1,466 | 4.28125 | 4 | print("Data Types")
#numbers --------------------------------------------------------------------------------------------
print("3.14e-2") # scientific notation
print("123 + 222") # integer addition
print("1.5 * 4") # floating-point multiplication
print("2 ** 100") # 2^100
print("len(str(2 ** 1000000))") # How man... |
3fe574d79e7ef47f872077bc401bcfcfd147704d | DroogieDroog/pirple_python_is_easy | /hw3/main.py | 828 | 4.0625 | 4 | """
pirple/python/hw3/main.py
Homework Assignment #3
Create function that determines if 2 or more of the passed
parameter values are equal (including strings with numbers
as their value)
"""
def two_are_equal(a, b, c):
if int(a) == int(b):
result = True
elif int(a) == int(c):
result = True
... |
2cc2ab17948b5d9052ac86b92872b6773eb0eda2 | ShitalTShelke/Assignments | /Nehali Assignment/1ton no printing using while loop.py | 84 | 3.796875 | 4 | a=int(input("enter number count"))
i=1
while i<=a:
print(i, end=" ")
i=i+1
|
7cc253e52bcb70baecc169a7856e7b39f1905b47 | vinodbellamkonda06/myPython | /interview/interviw.py | 1,507 | 4 | 4 | '''val1=int(input("enter a value:\n"))
list1=[0,1]
for i in range(1,val1):
list1.append(list1[-1]+list1[-2])
print (list1)
print(3 == 4 - 1)'''
'''import re
p= input("Input your password")
x = True
while x:
if (len(p)<6 or len(p)>12):
print("make sure password contains between 6 to 12 characters")
... |
fc106840861486a2c5a57baf01f781ad8ec00bb4 | jon-infante/Calculate-Probability | /probability.py | 936 | 3.875 | 4 | import math
from random import choices
def calc_probability(prob_heads, num_flips):
"""Calculates the amount of times Heads and Tails gets flipped,
looking for 2 Heads 1 Tails.
prob_heads: float
flips: int
"""
answers = [[['H'], ['H'], ['T']], [['H'], ['T'], ['H']], [['T'], ['H'], ['H']]]
... |
fe44fdc001c259ec42943dabb5f9e1d3669731b0 | Mahdiazhari/printable-random-objects | /generator.py | 2,586 | 4.125 | 4 | import random
import string
import os
class Generator:
"""This class generates four types of printable random objects and stores them in a single file."""
@staticmethod
def generate_alphanumerics():
"""This function generates a random alphanumeric which contains a random number of spaces befo... |
b3dd4ac40df581517aaed391b12919c473215989 | SilverEzhik/abstract-algebra-scripts | /rsa/generate.py | 1,024 | 4.25 | 4 | #!/usr/bin/env python3
import sys
from helper import *
p = 0
q = 0
if len(sys.argv) < (1 + 2):
print("Please enter the first prime number (p): ")
p = get_int()
print("Please enter the first prime number (q): ")
q = get_int()
else:
p = int(sys.argv[1])
q = int(sys.argv[2])
n = p * q
m = int... |
c156750a678daa310bbd236fd52b13adee9e5248 | jimskon/PythonNameLookup | /textindex.py | 1,021 | 3.984375 | 4 | def removePunctuation(s):
"Remove all punctuation from a string"
import string
for c in string.punctuation:
s= s.replace(c,"")
return s
def addToIndex(index,word,line):
if word not in index:
index[word]=[line] # make new entry
else:
index[word].append(line)
class textindex:
def __init__(sel... |
b9d6791b12ac7df32891a432b728e5701c41a737 | besseddrest/python-exercises | /leetcode/215-kth-largest-element-in-array.py | 781 | 3.921875 | 4 | # https://leetcode.com/problems/kth-largest-element-in-an-array/
"""
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.
Example 1:
Input: [3,2,1,5,6,4] and k = 2
Output: 5
Example 2:
Input: [3,2,3,1,2,4,5,5,6] and k = 4
Output... |
a6dfd75995284857669f46bd02c99186820ed0cf | Musfiqshohan/Cryptography-and-Security-CSE-4168- | /Lab1/1.4/solution04.py | 2,575 | 3.625 | 4 | from Crypto.Cipher import AES
import codecs
def main():
f1 = open("substitution_ciphertext.txt", "r")
cipher=f1.read()
mn = 10000000000
mntext = ""
for i in range(0,26):
d,str=decrypt(i,cipher)
if(d<mn):
mn=d
mntext=str
print(mn, mntext)
def d... |
1004496c01632f61921338146b1ef51aee666344 | jakehoare/leetcode | /python_1_to_1000/333_Largest_BST_Subtree.py | 1,625 | 3.984375 | 4 | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/largest-bst-subtree/
# Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree
# with largest number of nodes in it.
# Bottom-up recursively determine whether a subtree is a BST if its child... |
506cdb5ef8e4c9a7c9049a9b3d285c1cdce901d4 | FaderVader/CPH_AdvancedProg | /Dag10-week45/randi.py | 874 | 3.671875 | 4 | import random
weekdays = [
"Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday", "Sunday"
]
choices = [
[ "A"],
[ "A"],
[ "A", "B", "C", "D"],
[ "A", "B", "C", "D"],
[ "A", "B", "C", "D"],
[ "A", "B", "C", "D"],
[ "A", ... |
362208fa9b22c55bf032d1eb09cae20da2b8781d | CrisOspina/crud-python | /CRUD/insertar.py | 611 | 3.71875 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
import sqlite3
# Inserta data
try:
db = 'estudiantes.db'
conexion = sqlite3.connect(db)
print("conexion realizada con exito a la bd " + db)
cursor = conexion.cursor()
insertar = "INSERT INTO estudiante (nombre, apellido, cedula, telefono) VALUES (?,?,?... |
308c2fd2f8e98e4d45cccfdd0236c55bb5a65eae | BBBocian/Python | /Other/100+ Pytchon challenging programming/Zad_2_silnia.py | 151 | 3.578125 | 4 | n = int(input("Podaj wartosc: "))
def silnia(n):
if n>1:
return n*silnia(n-1)
elif n in (0,1):
return 1
print(silnia(n))
|
f2c1f85b78c51c7ac326d7b5bb1f1cebb5ffc5b2 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2438/61053/247821.py | 252 | 4 | 4 | import re
str = input()
list = re.split('\[|,|\]',str)
list.remove("")
list.remove("")
list=sorted(list)
print('[',end="")
for i in range(0,len(list)):
if i == 0:
print(list[i],end="")
else:
print(", "+list[i],end="")
print(']') |
9ae4d05b070db3b0cc74bc4265cdb0118f4d2aae | Nevilli/unit_ten | /brick.py | 900 | 4 | 4 | # Liam Neville
# 12/11/18
# This program creates the bricks that will be drawn in the class_file
import pygame
class Brick:
def __init__(self, width, height, color, main_surface):
"""
This function includes all of the measurements and variables for the bricks
:param width: width of bric... |
51e79384feaf6a982535828b075e4c4e35ee768e | fuse999/Sprint-Challenge--Intro-Python | /src/oop/oop1.py | 1,599 | 3.96875 | 4 | # Write classes for the following class hierarchy:
#
# [Vehicle]->[FlightVehicle]->[Starship]
# | |
# v v
# [GroundVehicle] [Airplane]
# | |
# v v
# [Car] [Motorcycle]
#
# Each class can simply "pass" for its body. The exercise is about setting up
# the hie... |
ee6ba960af439b0e8b7a5d1bb740234b7a27f7dd | CarolineYHao/CP1404 | /Prac 3/broken_score.py | 398 | 3.796875 | 4 | def main():
score = float(input("Enter score: "))
result_text = process_result(score)
print(result_text)
def process_result(score):
if score < 0 or score > 100:
result_text = "Invalid score"
elif score >= 90:
result_text = "Excellent"
elif score >= 50:
result_text = "Pa... |
e03acf9cf75f7b1c2d47e53c40589a0c887c8bc0 | DiegoSilvaHoffmann/Curso-de-Python | /Meus_dessafios/Exercicios2021/ex022.py | 334 | 3.96875 | 4 | nome = str(input('Digite um nome: ')).strip()
separa = nome.split()
print('Seu nome em maiusculas {}'.format(nome.upper()))
print('Seu nome em minusculas {}'.format(nome.lower()))
print('Seu nome tem {} letras'.format(len(nome) - nome.count(' ')))
print('Seu primeiro nome é {}, e tem {} letras.'.format(separa[0], len(s... |
abfe56f9975e7507c600ff199ec8543666ae6549 | SparklingFire/codewars_catas-master | /04-the-observed-pin.py | 499 | 3.703125 | 4 | # https://www.codewars.com/kata/the-observed-pin/python
from itertools import product
PIN = {'1': ('1', '2', '4'),
'2': ('1', '2', '3', '5'),
'3': ('2', '3', '6'),
'4': ('1', '4', '5', '7'),
'5': ('2', '4', '5', '6', '8'),
'6': ('5', '6', '9', '3'),
'7': ('4', '7', '8'),
... |
77c9ebda009d55118a3e326d2c5f888e650ed8ef | devacademyla/python | /1_programacion_procedural/clase/menu/solucion_1.py | 616 | 3.890625 | 4 | # -*- coding: utf-8 -*-
opcion_elegida = False
opciones_validas = range(1, 4 + 1) # [1, 2, 3, 4]
while not opcion_elegida:
print u"Elija una de las siguientes opciones:\n"
print u"1.- Python"
print u"2.- Javascript"
print u"3.- Java"
print u"4.- Ruby"
print u"\nElija una opción:",
opcion =... |
980735459437ef0882b7b7cbb359e5fdca2ac398 | govardhananprabhu/DS-task- | /fine.py | 1,304 | 3.96875 | 4 | """
Given a date and an array of integer containing the numbers of the cars traveling on that date(an integer), the task is to calculate the total fine collected based on the following rules:
Odd numbered cars can travel on only odd dates.
Even numbered cars on only even dates.
Otherwise a car would be fined 250 ... |
9e7a93f8dbe60615eed197e18853e4968d086e73 | SnehalThakur/PythonTutorial | /SQLiteDBIntegration/PythonSqliteIntegration_cursor.py | 1,770 | 4.09375 | 4 | import sqlite3
# Open a Database connection
connection = sqlite3.connect(r"C:\Users\Snehal Thakur\PycharmProjects\pythonProject\SQLite\db\employeeSqlite1.db")
print("connection=", connection)
print("sqlite3.version=", sqlite3.version)
# Getting all tables from sqlite_master
sql_query = """SELECT name FROM sql... |
96dcfe66841ae92267983bec9b558916c9329027 | manjesh41/project3 | /6.py | 128 | 4.125 | 4 | '''
Q.No.6 Write a Python program to reverse a string.
'''
def my_function(x):
print(x[::-1])
return
my_function('manjesh') |
b98c6be67dd2a3c76b2169fc540da1faa0efeea8 | FoxAndWaffle/testRepo | /random_game.py | 894 | 4 | 4 | import random
# genreate a random number 1 - 10
secret_num = random.randint(1, 10)
guesses = []
def game():
while len(guesses) < 5:
try:
guess = int(input("Guess a number between 1 and 10, inclusive: "))
except ValueError:
print("{} isn't a number!".format(guess))
else:
if guess == ... |
1d93cc4f983f5457cd7c73bc90b88de444b16068 | Divine11/InterviewBit | /Heaps And Maps/Merge_K_Sorted_List.py | 2,617 | 3.921875 | 4 | # Merge k sorted linked lists and return it as one sorted list.
# Example :
# 1 -> 10 -> 20
# 4 -> 11 -> 13
# 3 -> 8 -> 9
# will result in
# 1 -> 3 -> 4 -> 8 -> 9 -> 10 -> 11 -> 13 -> 20
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def buildHeap(arr,n):
for i in range(... |
8cf1476a7f1a0ed5fdef6a037ce0e12ad9b8ccf5 | dee12452/PracticeProblems | /Python/src/Cracking the Coding Interview Problems/One_One.py | 518 | 4.0625 | 4 | """1.1 Implement an algorithm to determine if a string has all unique characters. What
if you cannot use additional data structures?"""
def all_unique_characters(string):
hash_tab = [0 for j in range(0, 500)]
for i in range(0, string.__len__() - 1):
if hash_tab[ord(string[i])] == 0:
hash_t... |
4fa0ee31f3b3b6636c0418042b21de369b6b8b11 | hrai/hackerrank-30days | /exercises/day9.py | 140 | 4.125 | 4 | #!/bin/python3
# Complete the factorial function below.
def factorial(n):
if n <= 1:
return n
return n * factorial(n - 1)
|
7245f3f634dfbbe2b68c8fb7f60d4abb7e69825d | mario-alop/ejemplos_python | /dos_listas.py | 362 | 3.671875 | 4 | numeros1 = []
numeros2 = []
iguales = []
aux = 0
for i in range(5):
numeros1.append(int(input(f'Lista 1ª introduzca el {i+1} número: ')))
print()
for i in range(5):
numeros2.append(int(input(f'Lista 2ª introduzca el {i+1} número: ')))
for i in range(5):
if numeros1[i] in numeros2:
iguales.append... |
15ca060f10904a75069198778f64aabcec8a2b49 | michail82/TestMikl | /MIklTest2_Week2_32_ Sequence length.py | 61 | 3.71875 | 4 | len = 0
while int( input() ) != 0:
len += 1
print( len )
|
0ccd6192c98646a6fdc9df1db6cedcde6e5d5320 | code-in-the-schools/Operators-and-dataTypes_LizvethM | /main.py | 829 | 3.578125 | 4 | janRainfall2019 = 3.15
febRainfall2019 = 3.64
marRainfall2019 = 4.14
aprRainfall2019 = 4.12
mayRainfall2019 = 3.24
junRainfall2019 = 3.65
julRainfall2019 = 4.54
augRainfall2019 = 3.34
septRainfall2019 = 3.27
octRainfall2019 = 4.45
novRainfall2019 = 3.56
decRainfall2019 = 4.37
springRainfall2019 = marRainfall2019+aprRa... |
33209fd0558d259642262af7f213e91d7445bfca | yasminms/URI-Online-Judge | /1159.py | 159 | 3.515625 | 4 | n = 1
soma = 0
while (n != 0):
n = input()
if (n != 0):
for i in range(n, n+10, 1):
if (i % 2 == 0):
soma += i;
print soma
soma = 0
|
5b2a6052d04232adb9fb80224674d3e253651180 | VincentGaoHJ/Sword-For-Offer | /rsc/1_easy/offer_11.py | 1,975 | 4.0625 | 4 | # coding=utf-8
"""
@Time : 2020/7/29 10:10
@Author : Haojun Gao (github.com/VincentGaoHJ)
@Email : vincentgaohj@gmail.com haojun.gao@u.nus.edu
@Sketch : 剑指 Offer 11. 旋转数组的最小数字
https://leetcode-cn.com/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/
"""
# class Solution:
# def minArray(self, numsber: L... |
64808526d9e1665e761c716581a6664eb2f2ddee | kadimisetty/action-hero | /action_hero/types_utils.py | 2,190 | 3.734375 | 4 | import uuid
__all__ = [
"is_convertible_to_UUID",
"is_convertible_to_float",
"is_convertible_to_int",
"is_truthy",
]
def is_convertible_to_int(value):
"""Returns True if value is convertible to int"""
try:
int(value)
except ValueError:
return False
else:
retur... |
328fd7a7bddd1ec0b8b1e82bf21651ae5782a6d7 | strong1133/hh99_cpt2_Algorithm | /altari/programmers/level01/행렬의덧셈.py | 321 | 3.75 | 4 | # 프로그래머스_알고리즘_2021-03-18, level01_행렬의 덧셈_/by 정석진
def sumMatrix(A, B):
answer = [[c + d for c, d in zip(a, b)] for a, b in zip(A, B)]
return answer
def sumMatrix(A, B):
for i in range(len(A)):
for j in range(len(A[0])):
A[i][j] += B[i][j]
return A
|
1c37d79023930e18c35a75e0939de3f34c6f6f14 | boknowswiki/mytraning | /lintcode/python/0941_sliding_puzzle.py | 1,710 | 3.671875 | 4 | #!/usr/bin/python -t
# bfs
import collections
class Solution:
"""
@param board: the given board
@return: the least number of moves required so that the state of the board is solved
"""
def slidingPuzzle(self, board):
# write your code here
boardStr = ""
for i in range(len... |
574f5fe3b2002d72c5658b3616530c1bf738ec67 | bmk316/daniel_liang_python_solutions | /2.6.py | 435 | 4.125 | 4 | # QUESTION 2.6
number = eval(input("Input number between 0 and 1000, whose integers need to be summed: "))
first_digit = number % 10
print(first_digit)
number_after_extracting_first_digit = number // 10
second_digit = number_after_extracting_first_digit % 10
print(second_digit)
third_digit = number_after_extra... |
423a7e22f6608723cb846d35e4b6dcb12f5e509b | LimHengGuang/8-tiles-puzzle-solver | /helper_scripts/move_executor.py | 4,109 | 3.953125 | 4 | import sys
"""
This is a helper script to do testing
Takes in init_state and moves as input
Prints True if the moves solves the puzzle
Else, prints False
"""
class Puzzle(object):
def __init__(self, init_state, goal_state):
self.init_state = init_state
self.goal_state = goal_state
self.acti... |
aeebf2394f59906e25dcec7ac12705663ce7e608 | ROF618/Auto_The_Boring | /ch.9PracProject.py | 2,929 | 4.53125 | 5 | """
Practice Projects
For practice, write programs to do the following tasks.
Selective Copy
DONE -> Write a program that walks through a folder tree and searches for files with a certain file extension (such as .pdf or .jpg). Copy these files from whatever location they are in to a new folder.
Deleting Unneeded File... |
b4f817e9e77c26247902fb3fedbb5e485f67a884 | ctee88/BreakoutProject | /ball.py | 1,825 | 3.921875 | 4 | #Author: Cameron Tee
#Date: 07/03/2020
#Purpose: A class managing the behaviour of the ball
import pygame
class Ball(pygame.sprite.Sprite):
def __init__(self, settings, screen, paddle):
super().__init__()
self.screen = screen
self.settings = settings
#Generate ball and get its rect attribut... |
78b1abea0650a1c911baa5b406f96a568acd4b22 | ceto2016/python | /lec 5 string/string.py | 120 | 3.78125 | 4 | string = '''mohamed
age 211
yaleeel
hobaaaa'''
print(string[0:31])
string.upper()
num = string.endswith('a')
print(num)
|
e388df76c50e779cb9f473147aebfb7545faef9a | bencouser/project_euler | /37.py | 475 | 3.53125 | 4 | # Find the sum of the only eleven primes that are both truncatable from left to right
# and right to left
import MyModule as mm
countTruncatableBoth = 0
sumTruncatableBoth = 0
number = 13
while countTruncatableBoth < 12:
if mm.is_it_prime(number):
digits = mm.find_digits(number)
length = len(digi... |
d417b0ee423fae7ec8382a4acba2f62ae8fdfbb6 | CocoYeh1014/CCCPython | /guessNumber.py | 462 | 3.78125 | 4 | import random
num = random.randint(1,10)
time = 0
while True:
guess = int(input('num?'))
if guess < num:
print('bigger')
time+=1
if time>5:
print('over 5 times')
break
elif guess > num:
print('smaller')
time+=1
if time>5:
... |
c358321037706eb52d09ae299566c7727b6cddc5 | gislaine-a-sa/Python---Estrutura-de-Repeticao | /Estrutura de Repetição 01.py | 190 | 4.09375 | 4 | print (' Estrutura de Repetição - Exercício 1')
nota = float (input ('Informe um número:'))
while (nota>10) or (nota<0):
nota = float (input ('Informe um número de 0 a 10:'))
|
d5d4cd7fa45947cb8794afbeb15b541cb093497e | bhawani021/python-programs | /decorators/decorators.py | 771 | 3.921875 | 4 | #!/usr/bin/env python
"""
Decorators example
"""
# Example 1
def d_greet(func):
def inner(name):
return 'Hello ' + func(name)
return inner
@d_greet
def message(name):
return name
call_message = message('Bhawani')
print(call_message)
# Example 2
def decorator1(func):
def inner(name):
... |
62dc0fc3c7d20d5c0a6f48f4f48e0b1df2ea7fff | DiasDogalakov/PP2_summer2020 | /Contest(16.06.20)/H.py | 229 | 3.8125 | 4 | #formula is LCM(a, b) = (a * b)/GCD(a, b)
n, m = input().split()
n = int(n)
m = int(m)
gcd = 0
for i in range(m, 0, -1):
if m % i == 0 and n % i == 0:
gcd = i
break
lcm = (n * m) / gcd
print(int (lcm + gcd))
|
17aaee57181a532f3aaf078e3e76dd5c6db0da3f | Nyyen8/Module11 | /class_definitions/Customer.py | 2,648 | 3.609375 | 4 | """
Program: Customer.py
Author: Paul Elsea
Last Modified: 07/7/2020
Defining the Customer class.
"""
from Validation_Utilities import Validation_Functions as vFunc
class Customer:
'''Customer class constructor'''
#Constructor
def __init__(self, idnum, lname, fname, addStr, addCity, addState, phone):
... |
aec8a9294d31d88ea1c38ae0a65ec65913e6b012 | Rachanahande/python1 | /LAB_QUESTIONS/7.py | 163 | 3.734375 | 4 | lb = int(input("enter the lower bound "))
ub = int(input("enter the upper bound"))
res = " ".join([i for i in range(lb,ub+1) if i%9 == 0 and i %5 !=0])
print(res) |
b8d8c69e894227da5a7986ad1511f52bd4874172 | magnusbraaten/tassen | /apps/photo/autocrop.py | 1,782 | 3.640625 | 4 | """ Face and feature detection with opencv. """
import numpy
import cv2
def opencv_image(imagefile, size=400, grayscale=True):
""" Convert ImageFile into a cv2 image for image processing. """
cv2img = cv2.imread(imagefile.source_file.file.name)
width, height = cv2img.shape[0], cv2img.shape[1]
if wid... |
e917ca64d309b545208ac29f8e6252565bc51b49 | dekaghub/LeetCode | /AddTwoProblem.py | 1,278 | 3.578125 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
... |
c474dbc817c237a7e3cee36f49dbb064e3b15f36 | josenaldo/python-learning | /exercicios/semana3/s03e02-fizz-buzz-p1.py | 224 | 4.09375 | 4 | def main():
numero = int(input('Informe um número: '))
print(f'{"Fizz" if (numero % 3 == 0) else numero}')
#-----------------------------------------------
# a linha a seguir inicia a execução do programa
main() |
14746feb3f6c2ef1b1487b1c772a1d17be4e8a8f | satyam-seth-learnings/machine_learning | /Machine Learning using Python(NIELIT Lucknow)/My Code/Assignments/Assignment-1(Day-3)/5.Write a Python program to interchange first and last elements in a list.py | 277 | 4.34375 | 4 | # Write a Python program to interchange first and last elements in a list.
# Logic-1
l=[1,2,3,4,5]
print(f'List: {l}')
l[0],l[-1]=l[-1],l[0]
print(f'List: {l}')
# Logic-2
# l=[1,2,3,4,5]
# print(f'List: {l}')
# l.insert(0,l.pop())
# l.append(l.pop(1))
# print(f'List: {l}') |
1ccbaa4b61fade76b9765a471c87101fe270c288 | ErikAndersen81/DM550-FractalProject | /Fractal rule reader version 1.py | 290 | 4.03125 | 4 | F="F"
rule=str(input("What is the rule?"))
depth=int(input("How deep should it be?"))
rule2=rule
def FG(F,rule,depth):
if depth<=0:
print(rule)
else:
while depth>0:
rule2=rule.replace("F",rule)
depth=-1
print(rule2)
FG(F,rule,depth)
|
5af490620dbbfd24e8ab67295ade72910aae7b3c | SlaviSotirov/HackBulgaria | /week_0/day_1/fib.py | 263 | 3.96875 | 4 | def nth_fibonacci(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return nth_fibonacci(n-1) + nth_fibonacci(n-2)
def main():
print(nth_fibonacci(1))
print(nth_fibonacci(10))
if __name__ == '__main__':
main()
|
61aa08534fe545d86c417013602a370fe6098981 | thien-win/py | /DataStructures/3_LinkedList/3_linked_list.py | 8,989 | 4.0625 | 4 | class Node:
def __init__(self, data=None, next=None):
self.data = data
self.next = next
class LinkedList:
def __init__(self):
self.head = None
def print(self):
if self.head is None:
print("Linked list is empty")
return
itr = self.head
... |
6bc09928488f225a657d6ea6167f785d08614227 | megamcloud/cei | /framework/cei_python3/impl/ceiutils.py | 1,286 | 3.859375 | 4 | import time
class CEIUtils:
@staticmethod
def get_now(format: 'str'):
"""
Convert current date/time in UTC to string
:param format The format of the output string, following below rules:
%Y The 4 characters year code. like 2019.
%M The 2 characters month in year. range... |
8f2d1a9d546851095718a7298be077aedfbadc7b | cadolphs/advent_of_code_2019 | /day02/opcode_computer.py | 1,866 | 3.703125 | 4 | class OpcodeComputer:
'''Class representing our Integer Computer'''
def __init__(self, program):
'''Initialize with program, given as a list of integers'''
self.memory = program
self.instruction_pointer = 0
def set_inputs(self, noun, verb):
'''Provide inputs in the form of ... |
99e87252bf1e8c7cc3d5e29e0df750c010133325 | shivamchourasia/Training | /s/shivam/ifelif.py | 215 | 4.0625 | 4 | var1=int(raw_input("enter"))
var2=int(raw_input("enter"))
op=raw_input("enter the operator")
if op=='+':
print var1+var2
elif op=='-':
print var1-var2
elif op=='/':
print var1/var2
elif op=='*':
print var1*var2
|
20646586cd1334d90f6c6126ea29ed921a060466 | aditp928/cyber-secruitiy- | /1-Lesson-Plans/Unit03-Python/2/Activities/07-Stu_FirstFunctions/Solved/Length-Bonus.py | 617 | 4.09375 | 4 | # returns true if item is lengthable, false otherwise
def lengthable(item):
length_viable = type(item) is str or type(item) is list
return length_viable
# returns the length of item
def length(item):
if not lengthable(item):
return None
count = 0
for i in item:
count = count + 1
... |
1ecfdb3d46903f4db42486298977c026076b1c56 | karenlorhana/decisao_e_repeticaoPython | /exerciciosDecisao/questao02.py | 195 | 4.1875 | 4 | #verificar se o valorr digitado é positivo ou negativo
x = float(input("digite um valor: "))
if(x > 0):
print("o valor digitado é positivo")
else:
print("o valor digitado é negativo")
|
4a2437f5c19cddc9247d5100eb3dd0e61571f6f2 | liugenghao/pythonstudy | /Thread/queueTest.py | 469 | 3.59375 | 4 |
import queue
# q = queue.Queue(maxsize=2)
q = queue.Queue()#堆
q.put("d1")
q.put("d2")
q.put("d3")
print(q.qsize())
print(q.get())
print(q.get())
print(q.get())
q2 = queue.LifoQueue()#栈
q2.put(1)
q2.put(2)
q2.put(3)
print(q2.get())
print(q2.get())
print(q2.get())
q3 = queue.PriorityQueue()#可设定优先级,自动排序
q3.put((-1,'... |
a2c62c42b6796744ced30eed82bfa88a19a39963 | cesarfois/Estudo_Livro_python | /#Livro_Introd-Prog-Python/cap-6/Listagem 6.50 - Obtenção do preço com um dicionário .py | 603 | 3.78125 | 4 | print('=' * 72)
print('{:=^72}'.format(' Listagem 6.50 '))
print('{:=^72}'.format(' By César J. Fois '))
print('=' * 72)
print('{0:=^72}'.format(' Listagem 6.50 - Obtenção do preço com um dicionário '))
print('=' * 72)
print('')
tabela = {"Alface": 0.45,
"Batata": 1.20,
"Tomate": 2.30,
... |
5fbb25da9c4145856c6a086b584374e02e5cdab9 | birajit95/Data-Structure | /Data Structure/Array/mergeSort.py | 591 | 3.609375 | 4 | a = [2,1,4,5,6,9,3,10,7,8]
l = 0;
h = 9
def mergeSort(a, l, h):
if l<h:
mid = (l+h)//2
mergeSort(a, l, mid)
mergeSort(a, mid+1, h)
merge(a, l, mid, h)
def merge(a, l, mid, h):
n1 = mid - l
n2 = h - mid + 1
L = [None]*n1
R = [None]*n2
for i in range(0, n1):
L[i] = a[l+i]
for j in range(0, n2):
R[... |
3189bc968784e6ef2eb0a5c2457159184c6f7fe0 | id3at/practicepython.org | /divisors.py | 607 | 3.984375 | 4 | """
Autor id3at
"""
#https://www.practicepython.org/exercise/2014/02/26/04-divisors.html
#Exercise 4
#Create a program that asks the user for a number and then prints out a list
#of all the divisors of that number. (If you don’t know what a divisor is, it
#is a number that divides evenly into another number.
while Tr... |
8dcf8f0fc1220eae69e1df3de892e180fc3e47bb | WolfAmon/bored-stuffs | /Chapter 17 - Manipulating images/PracticingMethods.py | 2,924 | 3.984375 | 4 | from PIL import Image
'''
this file contains several basic practices to understand the functionality of the pillow library
'''
# just loading the which will be working
catImage = Image.open('zophie.png')
# ******************************************************
# Cropping
# *******************************************... |
e30b4f366f59216d4b8d3b43ff260e2c245e2d3c | mohitsharma2/Python | /translate.py | 873 | 3.875 | 4 | """
Name:
Translate Function
Filename:
translate.py
Problem Statement:
Write a function translate() that will translate a text into "rövarspråket"
Swedish for "robber's language".
That is, double every consonant and place an occurrence of "o" in between.
Take Input from User
Data:
... |
670eff6b361a48e17cd85e137905bc5e064a5ff1 | trungbanh/Caro_python | /Broad.py | 662 | 3.546875 | 4 | class Broad :
def __init__(self,Rows=10,Cols=10) :
Rows = Rows
Cols = Cols
Map = list()
self.__initBroad()
def __initBroad(self) :
for x in range( Rows ) :
for y in range (Cols ):
Map[x][y] =0
def setTic(self,x,y,player):
"""
... |
d829ec39a3e780b30731e1bdd4b5c7b5054a5713 | edwardangus810/IDEA-Python | /pyton文件/4.15装饰器3.py | 709 | 3.796875 | 4 | # 不定长参数
def func(functionName):
print("---func---1---")
def func_in(*args, **kwargs):
print(args) # 如果a,b没有定义,那么会导致16行的调用失败
print("---func_in---1---")
functionName(*args, **kwargs)
print(args) # 如果没有把a,b当作实参进行传递,那么会导... |
759b446c525b634a6754bf5986a93156080f8b53 | SupiKery321/movies_catalogue- | /SQL/SQL/models.py | 2,733 | 3.609375 | 4 | import sqlite3
class TodosSQLite:
def __init__(self, db_file):
self.conn = self.create_connection(db_file=db_file)
def create_connection(self, db_file):
""" create a database connection to the SQLite database
specified by db_file
:param db_file: database file
:re... |
e5e27f9ee7a7ef5b4f0a301c0f5b4fe376ba7609 | jacekku/PP3 | /Python/02/zadanie18.py | 186 | 3.9375 | 4 | def print_sideways_piramid(size=1,char="*"):
for i in range(size//2):
print(char*(i+1))
for i in range(size//2+1,0,-1):
print(char*i)
print_sideways_piramid(7) |
6a470c4dc79923dfd0f1f2ed782ed4c89fc932ee | antohneo/pythonProgramming3rdEdition | /PPCh3PE1.py | 458 | 4.59375 | 5 | # sphere.py
# python3
# calculates volume and surface area of a sphere given radius
import math
def main():
print("Program calculates the vol. & surface area of a sphere given the radius.")
radius = float(input("Enter the radius of a sphere: "))
volume = 4 / 3 * math.pi * radius ** 3
surfaceArea = 4 ... |
bffbe67dbce5b033fa9ab16b6bf2c658a373166c | jedwardblack/PythonPrograms | /Lab 9/findNumber.py | 358 | 3.734375 | 4 | #Name: Joseph Black and Hudson Jones
#Assignment: findNumber.py
def main():
myList = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
num = eval(input("Please enter a number: "))
i = 0
while i < len(myList)and num != myList[i]:
i += 1
if i >= len(myList):
print("Number not in list.")
els... |
c1ac69faeaf1dba50451445ef92769f49dd2b84d | Simran0401/Python-Django-LPU | /Python Basics Assignment/fifthprg.py | 424 | 4.03125 | 4 | """
Q5. Write a program to compute roots of a quadratic equation when
coefficients a, b and c are known(entered by user).
"""
import cmath
a = float(input("Value of Cofficient a: "))
b = float(input("Value of Cofficient b: "))
c = float(input("Value of Cofficient c: "))
d = (b ** 2) - (4 * a * c)
root1 = (-b-cmath.... |
d1f8cbe9dd6fed25ecb6fa3ece9357eb31a94d38 | go4ble/403Section | /urlsort_test.py | 905 | 3.828125 | 4 | """
Usage: python urlsort_test.py [-g | -t]
-g: Generate a file of URLs, testurls.txt
-t: Test that the file output.txt is sorted correctly
"""
import sys
import string
import random
import urlsort
def url_generator(size=20, chars=string.ascii_lowercase + string.digits):
return ''.join(random.choice(chars) for x in... |
cd6b016f81b6d94bca01ccdd3e379bef5b4674ca | pymft/mft-01 | /S02/convert_string_to_number.py | 109 | 3.6875 | 4 | val = "12"
res = val * 2
# print(res)
num = int(val)
print(num)
print(type(num))
res2 = num * 2
print(res2) |
d667591095096fef7d6f10e62540e317b8ed433f | wow01022634/udemy_python_quickstart | /3_Data_Type/3-1_List.py | 154 | 3.53125 | 4 | countries = ['uk','usa','france','swiss']
#countries.append('iceland')
countries.insert(0,"spain")
print(countries)
del countries[0]
print(countries) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.