blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
dfad73acc6165cbe14436d9b9ce5e94eab436e0e | DanJamRod/mis3640 | /session12/sumall.py | 249 | 4.25 | 4 | def sumall(*nums):
""" Takes any number of arguments and returns their sum
"""
sum = 0
for num in nums: # For every number, add it to the sum
sum += num
return sum
print(sumall(1))
print(sumall(1,2))
print(sumall(1,2,3)) |
94238edc711e5850612ca3dfd610452e5d985ec9 | ehoney12/comp110-21f-workspace | /exercises/ex02/count_letters.py | 320 | 4.09375 | 4 | """Counting letters in a string."""
__author__ = "730240245"
# Begin your solution here...
i: int = 0
search: str = input("What letter do you want to search for?: ")
word: str = input("Enter a word: ")
while i < len(word):
how_many: int = word.count(search)
print("Count: " + str(how_many))
i = len(word) |
91b2604ae13360e543f109045f78f4515b32ba15 | sebagraff/pythonfunctions | /funtions.py | 9,819 | 3.78125 | 4 | def sumoftwo(a,b): # from http://www.codeabbey.com/index/task_view/sum-of-two
suma= a + b
return suma
def suminloop(lista): # http://www.codeabbey.com/index/task_view/sum-in-loop
for i in lista:
return sum(lista)
def sumsinloop (list1,list2): #http://www.codeabbey.com/index/task_view/sums-in-loop
... |
bed3f4450de26ff6e2cc78fd66f73a7bb961ab3a | nikhilslounge/language-learning | /src/parse_evaluator/parse_evaluator.py | 6,981 | 3.5 | 4 | #!/usr/bin/env python
# ASuMa, Mar 2018
# Read parse data in MST-parser format, from reference and test files
# and evaluate the accuracy of the test parses.
# See main() documentation below for usage details
import platform
import getopt, sys
def version():
"""
Prints Python version used
"""
pri... |
7fb6b04fdd00b313819c3d64a3172226716f0b8b | Aasthaengg/IBMdataset | /Python_codes/p03828/s275597986.py | 490 | 3.53125 | 4 | from fractions import math
n=int(input())
#first generate all primes uptil N
def chk_prime(n):
sq=int(math.sqrt(n))
for i in range(2,sq+1):
if n%i==0:
return False
return True
primes=[]
for i in range(2,n+1):
if chk_prime(i):
primes.append(i)
#print(primes)
ans=1
mod=10**9+7
... |
17d15609cfd97d02a7107ea7e5b1bc79bea43c03 | rbrtasmth/Project_Euler | /Python/p2.py | 770 | 4.03125 | 4 | # Each new term in the Fibonacci sequence is generated by adding the previous two terms.
# By starting with 1 and 2, the first 10 terms will be:
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
# By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.... |
f5ef3a1e324d0fd7ff6c37f50a90c0c2c95d0de5 | spanickroon/Rss-Reader | /rssreader/format_conversion/conversion_pdf.py | 2,561 | 3.515625 | 4 | """Pdf conversion module"""
import os
import requests
import logging
from fpdf import FPDF
class PdfConversion():
"""A class that converts to Pdf"""
def __init__(self, list_news_dict: list) -> None:
self.list_news_dict = list_news_dict
self.pdf = FPDF()
self.pdf.add_font('DejaVu', '', ... |
0e5fc69256de44812bd11df417d964e37405d7c0 | enajeeb/python3-practice | /PythonClass/answer_files/exercises/iPhone.py | 381 | 3.6875 | 4 | # coding: utf-8
from apple import Product
class iPhone(Product):
def __init__(self):
# To call a superclass method, use the super() function and provide your class name and a pointer to yourself.
parent = super(iPhone, self)
parent.__init__('iPhone', 200)
def price(self):
base_price = super(iPhone, self).p... |
b490d84e50b0db71d64f6e393a3b1e43cc41be2f | gerardorosas236/CYPluisRM | /libro/ejemplo2_2.py | 271 | 3.703125 | 4 | SUE = float(input("Ingrese su sueldo: "))
if SUE<1000:
print("Su sueldo es inferior a $1000, por lo tanto tiene un aumento del 15%")
AUM = SUE * 0.15
NSUE = SUE + AUM
print(f"Su sueldo total con el 15% de aumento es {NSUE}")
print("Fin Del Programa....")
|
eab73bc6d83b91f4bcc301d3aec701bf1b49ddc5 | gabriellaec/desoft-analise-exercicios | /backup/user_068/ch169_2020_06_21_21_19_00_528785.py | 516 | 3.84375 | 4 | def login_disponivel(nome, lista):
i=1
if nome not in lista:
return nome
else:
for x in range(len(lista)):
while nome in lista:
nome = nome +str(i)
if nome in lista:
nome= nome[:-1]
i+=1
return nome
... |
424673594ccb4d713b4b09285c0a5340ce824599 | Safintim/computer-science | /leetcode/104_maximum_depth_of_binary_tree.py | 382 | 3.671875 | 4 | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def max_depth(self, root: TreeNode) -> int:
def traverse(root, level):
if not root:
return level
return max(traverse(root.left, level + 1), t... |
76edc8421684950bbf2929b116cb6ccca43b6fb8 | Hk4Fun/algorithm_offer | /leetcode/array/easy/485. Max Consecutive Ones.py | 3,109 | 3.9375 | 4 | __author__ = 'Hk4Fun'
__date__ = '2018/3/28 19:07'
'''题目描述:
Given a binary array, find the maximum number of consecutive 1s in this array.
Example 1:
Input: [1,1,0,1,1,1]
Output: 3
Explanation: The first two digits or the last three digits are consecutive 1s.
The maximum number of consecutive 1s is 3.
Note:
The input... |
071dcc4bc84e395385a2b231b3a0bb57a887e0df | arbalest339/myLeetCodeRecords | /microsoft1.py | 814 | 3.640625 | 4 | class item:
def __init__(self, dis, cost) -> None:
self.dis = dis
self.cost = cost
def __lt__(self, o: object) -> bool:
if self.dis < o.dis:
return True
elif self.dis == o.dis and self.cost < o.cost:
return True
elif self.dis == o.dis and self... |
bb899015c41a789df1930d9cd5a143b882fce59b | isabelbrandin/learning-by-doing | /repupg-7.py | 94 | 3.625 | 4 | first = []
name = input("Vad heter du? ")
for i in range(50):
first.append(name)
print(first) |
2b0196e911b45edbe115ad4589c28c5ff3957098 | softwareengineer10349/python-scripts | /autoIndentCode.py | 6,405 | 3.703125 | 4 | import re
import fnmatch
import os
import sys
import copy
if(len(sys.argv) != 3):
print "You did not enter 2 paramaters. This function requires 2 paramaters to be entered"
print "Usage: autoIndentCode.py filename_to_be_read filename_to_write_to"
sys.exit()
try:
fo = open(sys.argv[1], "r")
except:
p... |
4e183a17abec3abc4be5e6f7e1cc6c3d8ef8ea78 | simeonpanayotov/Tetris | /tests/shape_tests.py | 867 | 3.5 | 4 | import unittest
import shapes
class SquareShapeBoxPositioning(unittest.TestCase):
def test_square_boxes_form_square(self):
square = shapes.Square(0, 0)
self.assertEqual(square.blocks[0].x, 0)
self.assertEqual(square.blocks[0].y, 0)
self.assertEqual(square.blocks[1].x, 1)
s... |
fc418cbf3b539fb0a2e3fa1441026b2b92a715e9 | kleber-costa/computacao-UFF | /fundamentos-de-programacao/aula_03/abono_salarial.py | 389 | 3.6875 | 4 | '''
Abono Salarial
'''
salario = float(input("Diga seu salário atual: "))
tempo = int(input("Diga quantos anos completos tem de serviço: "))
if tempo <= 1:
print("Seu salário se mantém o mesmo: {:.2f}".format(salario))
else:
if tempo <= 10:
salario = salario * 1.10
else:
salario = salario ... |
f38767e91412d205fc348a19ab36f34b96ccba0a | azahiri/Project-Arteen-Jenny | /run_analysis.py | 8,596 | 3.671875 | 4 | # General:
import tweepy # To consume Twitter's API
import pandas as pd # To handle data
import numpy as np # For number computing
import pickle # For pickling data
# For plotting and visualization:
from IPython.display import display
import matplotlib.pyplot as plt
import seaborn as sns
'... |
afe4b233e3e1f3dd783cded8bea7dfa5233d9f85 | Aasthaengg/IBMdataset | /Python_codes/p03474/s806766721.py | 263 | 3.765625 | 4 | #33 2020/07/14
A, B = input().split(' ')
A = int(A)
B = int(B)
S = input()
if not '-' in S:
print('No')
else:
S = S.split('-')
if '-' in S[0] or '-' in S[1]:
print('No')
elif len(S[0]) == A and len(S[1]) == B:
print('Yes')
else:
print('No')
|
69ee56427b322bdf8d8439c84c960c22a75b7a08 | samyuktahegde/DS_Algo | /DS/Stack/implementtwostacksusingarray.py | 1,135 | 3.65625 | 4 | class two_stacks:
def __init__(self, n):
self.size = n
self.array = [None]*n
self.top1 = -1
self.top2 = self.size
def push1(self, x):
if self.top1<self.top2-1:
self.top1 = self.top1+1
self.array[self.top1] = x
else:
print('Stac... |
95aeb9380f51612baa3492bb022379263be02bdf | ryangchung2/ICS3U-Unit4-03-Python | /exponents.py | 816 | 4.53125 | 5 | #!/usr/bin/env python3
# Created by Ryan Chung Kam Chung
# Created in December 2020
# Program does exponents with for loops
def main():
# Function does exponents with for loops
print("I will give you the square of every positive number up to",
"the inputted number")
# Input
number_string ... |
772ae67942d146be26d3a4a552e89fe6eb292fd7 | Sigmanificient/XCrypt | /example.py | 409 | 3.78125 | 4 | # Import xcrypt file [./xcrypt.py]-
# used for generating a valid key file.
import xcrypt
# Define the message to encrypt and decrypt.
message = input("Message: ")
# Build the key and return key file name.
key = xcrypt.make_key()
encrypted: str = xcrypt.encode(key, message)
print("\nEncrypted:", encrypted... |
c75e12155af3b725ae2d59f7c2d97755dbb474d3 | NVIDIA/gbm-bench | /3rdparty/fast_retraining/experiments/libs/conversion.py | 3,069 | 4.0625 | 4 | import pandas as pd
def _get_nominal_integer_dict(nominal_vals):
"""Convert nominal values in integers, starting at 0.
Parameters:
nominal_vals (pd.Series): A series.
Returns:
d (dict): An dictionary with numeric values.
"""
d = {}
for val in nominal_vals:
if val not i... |
213a3f7923bb00017bfbd65c36ff16ae705bfe4d | olivervalmas/ADSCoursework | /Q6/gpqk41_q6.py | 1,198 | 3.84375 | 4 | def merge(left, right):
result = []
while len(left) > 0 or len(right) > 0:
if len(left) > 0 and len(right) > 0:
if left[0] <= right[0]:
result.append(right[0])
right = right[1:]
else:
result.append(left[0])
left = ... |
9ccd228b05a4017ef61e86d9f8d5e5c13b8ce07d | yuzhecd/al_py | /Search/Binary_flow.py | 720 | 3.578125 | 4 | def binary_flow(alist, target):
left, right = 0, 1
while alist[right] < target:
left = right
right *= 2
if right >= len(alist):
right = len(alist) - 1
break
while left + 1 < right:
mid = left + (right - left) // 2
... |
77ace22a8387dd662456f7c123d7608afad478dd | stheakanath/westcoastpizza | /generator.py | 918 | 3.65625 | 4 | # Sony Theakanath
# West Coast Pizza Student Special Order Random Generator
# Thank you based Denero
import random
def get_random(lst):
return random.randint(0, len(lst) - 1)
def pick_random(toppings):
first_top, second_top = get_random(toppings), get_random(toppings)
while second_top == first_top:
second_top ... |
93ebbdb80fd9082e51431dc5efc4968944945c32 | ugoood/BigMass | /Python_Study/Pywork/xiang_py_code/six_one_ErrorsExceptions.py | 641 | 3.8125 | 4 | # -*- coding:utf-8 -*-
'''
Created on 2017年2月10日
@author: xiang
'''
# Error & Exceptions
'''
1. Syntax Errors no need to explain
2. Exceptions
'''
# Handling exceptions
# while True:
# try:
# x = int(input("please enter a number"))
# break
# except ValueError: # CAUSION: ValueError
# ... |
26a750563d625ae325ce72b4c7876ba75540c4b7 | Neo-sunny/pythonProgs | /PythonScripting/LogicalExp.py | 1,203 | 4.4375 | 4 | """
Demonstration of logical expressions.
"""
# Boolean values are True and False
value1 = True
value2 = False
print(value1, value2)
print("")
# Logical NOT
print("Logical NOT")
print("===========")
print(not value1)
print(not value2)
print("")
# Logical AND
print("Logical AND")
print("===========")
print(value1 a... |
812cc1299bae70ebfa5ff9c4c8e4af80a356f296 | l0neaadil/Python_for_beginner | /48_join.py | 379 | 4.46875 | 4 | # The join() method takes all items in an iterable and joins them into one string.
# A string must be specified as the separator.
# syntax: string.join(iterable)
list = ['hope', 'is', 'a', 'good', 'thing']
print(list)
print(' '.join(list))
print('_'.join(list))
# Note: When using a dictionary as an ... |
6e915b7bb751115462e634c85a049991b4dc5091 | LarissaMidori/curso_em_video | /exercicio058.py | 1,322 | 4.28125 | 4 | ''' Melhore o jogo do DESAFIO 28 onde o computador vai “pensar” em um número entre 0 e 10. Só que agora o jogador vai tentar adivinhar até acertar, mostrando no final quantos palpites foram necessários para vencer. '''
from random import randint
'''
tentativas = 0
jogador = 0
print(f'==== Advinhe o nº entre 0 e 10 ===... |
cd9ab17dc4911aa5be982c8cecf2ce28bc8459ab | arkan565/cursoNate | /clase_2/test_input.py | 91 | 3.53125 | 4 |
test_usuario=int(input("Dime un numero:"))
test_usuario=test_usuario+2
print(test_usuario) |
cd8b33d346643c9f37cb19859855509afc6bf1be | niralikabli/DataVisualisation_Drinks_Database | /Drinks.py | 1,599 | 3.875 | 4 | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Drinks dataset visual analysis
WHO alcohol consumption data:
article: http://fivethirtyeight.com/datalab/dear-mona-followup-where-do-people-drink-the-most-beer-wine-and-spirits/
original data: https://github.com/fivethirtyeight/data/tree... |
00644cf12fe24e24ce94d597f69ce06b95fff2fb | MrHamdulay/csc3-capstone | /examples/data/Assignment_4/smpsyd001/ndom.py | 861 | 3.5625 | 4 | def ndom_to_decimal(num):
if num >60:
a=int(num/100)
b=int((num-a*100)/10)
c=int(num-a*100-b*10)
num=a*36+6*b+c
return num
elif num >6:
b=int(num/10)
c=int(num-b*10)
num=6*b+c
return num
elif num<=6:
return num
d... |
e1f4b0f07faa780c238af3764a6dbea37da85d09 | jun2077681/BAEKJOON | /11091/11091_0.py | 242 | 3.515625 | 4 | a = int(input())
for i in range(a):
s = input().lower()
x = ''
for i in range(97,97+26):
if(s.find(chr(i)) == -1):
x = x+chr(i)
if(x is ''):
print('pangram')
else:
print('missing '+x)
|
46f2f5fc3c7fe9a7c46f14135b369b430e54fbda | wagnergarcez/instruct | /task.py | 1,288 | 3.671875 | 4 | #!/usr/bin/env python3
'''
Author: Wagner Garcez
Date created: 14/03/2019
Python Version: 3
'''
import sys
import json
try:
import requests
except:
import urllib.request
def parse_json(json, all_websites, count):
for data in json:
# add websites in list
all_websites.append(dat... |
a1d4391dc4f6bfa4060957c9d06d3cf8a0a686c9 | cristian-bedoya/AirBnB_clone | /console.py | 5,773 | 3.53125 | 4 | #!/usr/bin/python3
""" Module for command interpreter
"""
import cmd
from models.base_model import BaseModel
from models.user import User
from models.state import State
from models.city import City
from models.amenity import Amenity
from models.place import Place
from models.review import Review
import models
from mode... |
7b71334e907937972d883710281a5df918223ed7 | DanSGraham/code | /Centre_College/CSC_117/CSC_117_Python_Files/fib.py | 390 | 4.09375 | 4 | #
#Fibonacci Sequence
#
#Author: Daniel Graham
#
def main():
n=input("Which number of the Fibonacci Sequence do you want to compute? ")
firstNum=1
secondNum=1
#n-2 because first two are given as variables already
for i in range (n-2):
cNum=firstNum+secondNum
firstNum=se... |
74abd2f3999d4188cfa195d6b70edd0642b37230 | zsmountain/leetcode | /python/3sum_closest.py | 1,185 | 4.03125 | 4 | '''
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
For example, given array S = {-1 2 1 -4}, and target = 1.
The sum that is closest to the ta... |
ace40ea1294072b483fdc07413fdbc8ef98e37c8 | clairefischer/npfl104 | /hw/python/array123.py | 480 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 20 16:27:13 2019
@author: clairefischer
"""
#9
def array123(nums):
if 1 in nums:
for i in range(len(nums)):
if nums[i]==1 and i<=(len(nums)-3):
if nums[i+1]==2 and nums[i+2]==3:
return True
else:
return Fals... |
ff8b7360a1819b4244d37b23fadb61af6bd9bf62 | tinoe-G/demo-cul | /user_input.py | 272 | 3.953125 | 4 | #please type your username here
def name():
name=input("enter your name :").title()
print("hello",name)
#enter a name less than 10
if len(name)>10:
print("please type a name less than 10 char ")
else:
print("welcome",name.title())
name() |
155077f3db6cb6492d53f066357fb6f6a828f907 | Alkhithr/Mary | /think-python/chapter14_files/sed.py | 1,111 | 3.90625 | 4 | # Write a function called sed that takes as arguments a pattern string, a replacement string, and two filenames;
# it should read the first file and write the contents into the second file (creating it if necessary).
# If the pattern string appears anywhere in the file, it should be replaced with the replacement string... |
2d64c1e6d7e80717de4126bfd27de1614d741334 | abhishekxix/Programs | /python/forloops.py | 173 | 3.890625 | 4 |
for item in range(5,10,2): #This is an object and not a list
print(item)
prices = [10, 20, 30]
sum = 0
for price in prices:
sum += price
print(f'Total = {sum}')
|
3aa6043b2edf37bf1138fa0d21b2ee241d121c57 | refmitchell/dcidb-supplemental-repository | /occ_sim/util/treatment.py | 7,710 | 3.515625 | 4 | """
treatment.py
Module contains the full class definition for a Treatment.
"""
import numpy as np
class Treatment():
"""
A Treatement is a specification for a simulation scenario.
"""
def __init__(self):
"""
Constructor
"""
self.__initial_cues = []
self.__conf... |
96aa0b0e50519960ff0b1d328c372b6c9f816485 | desaivaibhav95/Object-Oriented-Programming-Python- | /Linked Lists/Inserting_and_deleting_a_node.py | 3,697 | 4.65625 | 5 | # Adding a node at the front of a linkedlist
# Let's call a function push which adds an element at the front of the list. The push must receive a pointer to the head pointer,
# because push must change the head pointer to point to the new node.
class Node:
def __init__(self, data): # initializing the node... |
81d2e65c6fee8748ea88d789fd5dba8260d9b7f1 | rahulmahajann/leetcode | /interview-bit/reverse_bit.py | 441 | 3.921875 | 4 | A=3
a=('{:032b}'.format(A))
b=list(a)
# print(a)
b.reverse()
c=''.join(b)
# print(c)
print(int(c,2))
# print(list(a))
# ans=0
# def binaryToDecimal(n):
# num = n
# dec_value = 0
# base = 1
# temp = num
# while(temp):
# last_digit = temp % 10
# temp = int(temp / 10)
# ... |
c5eaf0c94fc0f52310cdb975260181b4f5c4fbe8 | NovaStrikeexe/FtermLabs | /131 b part.py | 528 | 3.9375 | 4 | max_y = float(input("input y line: "))
if max_y > 0.278:
"""y = []
x = 9
while x < 10:
y.append(5 * x / (x * x + 81))
x += 0.01
print(max(y))"""
print("You used the max function! It will not work!")
else:
x = int(input("Input epsi... |
12f1dc25839f93fc337543a1efe4d02aee854533 | joysjohney/Luminar_Python | /PythonPrograms/regularExpression/mobile.py | 216 | 4 | 4 | # Validate mobile number
from re import *
rule="/d{10}"
mobno=input("Enter mobile number : ")
matcher=fullmatch(rule,mobno)
if(matcher !=None):
print("Valid mobile no")
else:
print("Invalid mobile no!") |
8f5a1bfd1cf44066f79a6df0f4fa06886f4bf626 | ranakh23/holbertonschool-machine_learning | /supervised_learning/0x07-cnn/3-pool_backward.py | 1,229 | 3.6875 | 4 | #!/usr/bin/env python3
""" This module contains the function pool_backward. """
import numpy as np
def pool_backward(dA, A_prev, kernel_shape, stride=(1, 1), mode='max'):
"""
Performs back propagation over a pooling layer of a neural network.
"""
A_sh = A_prev.shape
kh, kw = kernel_shape
m, h_... |
2b18d63ed8837a2c64d0602a384a9704298f38b7 | Vidyaa123/toolkitten | /summer-of-code/week-01/wk1-hackathon-submissions/soc01h-cc-vidyaa-shyam.py | 1,443 | 4.03125 | 4 | ##### Civilisation III
#### Week 1 Continent Counter Hackathon #####
import numpy as np
# 11*11 static array
counter = 0
# Array to check if the tile is visited or not
checked = np.zeros((11,11), dtype=bool)
# create a 11*11 static world
multd = [[0,1,1,0,0,0,1,1,0,0,0],
[0,0,0,0,0,0,1,1,0,0,0],
[0,1,1,1,1... |
fa4ffcbacdf271a41e14dedc2a39a50489f3a044 | SaurabhPal25081995/Full-Python-Course | /Problem 3.py | 1,051 | 4.21875 | 4 | """Problem Statement:-
You visited a restaurant called CodeWithHarry, and the food items in that restaurant are sorted,
based on their amount of calories. You have to reserve this list of food items containing calories.
You have to use the following three methods to reserve a list:
Inbuild method of python
List name [... |
7b917d5cba732b1654ba10e7d3b2094a4f61eb7e | lsb530/Algorithm-Python | /파이썬챌린지/14.csv파일읽기와쓰기/117.수학퀴즈맞추기.py | 737 | 3.515625 | 4 | import random
score = 0
name = input("What's your name?: ")
matrix = [[0] * 2 for i in range(2)]
for i in range(2):
num1 = random.randint(10, 50)
num2 = random.randint(10, 50)
question = f"{num1}+{num2}="
guess = int(input(question))
answer = num1 + num2
if guess == answer:
score += 1
... |
5e383c614a677ea9b9d638dd864087da32d9fc57 | choiy20/my-first-coding | /Assignment-4.py | 461 | 3.5 | 4 | # diamond_list=["00100","01110","11111","01110", "00100"]
# for i in diamond_list:
# print(i)
#아래 도형 구현하기
# 00100
# 01110
# 11111
# 01110
# 00100
# 힌트: 반복문 for loop 중첩해서 사용하기
for a in range (1,6):
a = a - 3 #3번째를 기준으로 위로 갈수록 줄어들고 아래로 갈수록 줄어듬
if a < 0:
a = -a #음수를 양수로 맞춰주기
print("0" * a + "1" *... |
bc0562a2729921697bf889dfc318efdf59ce89fe | alancyao/fun-times | /Algorithms/word_radix_sort.py | 834 | 4.125 | 4 | #!/usr/bin/env python3
from data_structures.trie import *
""" Problem description:
You are given a permutation of the english alphabet (all lowercase) and a list of words. Sort the list of words alphabetically according to the permutation of the english alphabet.
"""
""" Some variables for testing """
permutation = "... |
923ad379f8af7a4c2c9d6ab9bcb0b7ef09c5c09c | Keerthanavikraman/Luminarpythonworks | /oop/emplo_using_stsatic.py | 472 | 3.65625 | 4 | class Employee:
company_name="white rabit"
def setval(self,name,empl_id,salary,department):
self.name=name
self.empl_id=empl_id
self.salary=salary
self.department=department
def printval(self):
print(self.name,self.empl_id,self.salary,self.department,Employee.company_... |
6d9f8ae60c4387a521238461cbac2cc303fd5982 | uathena1991/Leetcode | /Medium/rotate list.py | 776 | 3.75 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def rotateRight(self, head, k):
"""
:type head: ListNode
:type k: int
:rtype: ListNode
"""
if not hea... |
bc9ac41635b6cfa64da5d690d9dfc187c1acd98c | UWPCE-PythonCert-ClassRepos/Self_Paced-Online | /students/rmart300/grid_maker/grid_maker.py | 1,076 | 4.21875 | 4 | """
grid_maker by Ross Martin
UW Python210 Lesson 2 Assignment
contains three methods to generate custom sized grids
"""
def make_first_grid():
size = 8
halfsize = int(size/2)
print_grid2(2,halfsize)
def print_grid(size):
"""function to print 2x2 square grid: size param determines height and width of ... |
7943ed2184696dac72f940baf4cf8d284883b5eb | Savitha-python23/python-classes | /funday2.py | 859 | 3.9375 | 4 | # def fun(s=100, a=200): # key value key value # will work
# return s,a
# fun()
#--------------------------
# def fun(s=100,a): # key value parameter error wont work
# return s,a
# fun()
#-----------------------------
# def fun(a,s=100): # parameter key value will work if we give value 1 when we call fun(1)
# retur... |
bf68eee0209a99eb980bd07c3c84fbdd6959746a | injoon2019/AI_Never_Loose_Tic-Tac-Toe | /a3.py | 5,672 | 4.375 | 4 | # CMPT 310
# Assignment 3
# Author: Injun Son
# Date: July 3, 2020
# a3.py
import random
import copy
# get idea of implementing game structure from https://github.com/kaustubh990/Python-Tic-Tac-Toe/blob/master/Tic-Tac-Toe.py
#board
board = ["-" , "-" , "-",
"-" , "-" , "-",
"-" , "-" , "-... |
e6ef48974333a933f1da5f42a27c6ba93d3ce5bd | ekinkaradag/data-structures | /test.py | 8,367 | 3.5 | 4 | from Lib.Node import SingleLinkNode
from Lib.LinkedList import LinkedList
from Lib.Stack import Stack
from Lib.Queue import Queue
from Lib.Tree import BinaryTree
import os
import sys
import filecmp
class bcolors:
GREEN = '\033[92m'
RED = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
cla... |
18fe75720f732a798702e9497aaa03ce5d065d4c | lpython2006e/student-practices | /14_Tran_An_Thien/Bai_1.8.py | 262 | 3.671875 | 4 | # Generate the output like: A(5), B(3), C(1) with input like ABBAAACB
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
check_string = "ABBAAACB"
for char in chars:
count = check_string.count(char)
if count >= 1:
print(char, count)
|
9b75c0a19805c683d82d362cfd3946b8f2a6cdb2 | ev-create/Aprendendo_python | /aprendendo_python/codigos_python.py | 766 | 3.828125 | 4 | cadastro = {
'nome' : ['João', 'Ana', 'Pedro', 'Marcela'],
'cidade' : ['São Paulo', 'São Paulo', 'Rio de Janeiro', 'Curitiba'],
'idade' : [25, 33, 37, 18]
}
print("len(cadastro = ", len(cadastro))
print("\n cadastro.keys() =\n", cadastro.keys())
print("\n cadastro.values() = \n", cadastro.keys... |
396f2c1a6203c9f5b197c5fbdaad99f5f38f3fce | Meugenn/workbot | /functions.py | 399 | 3.625 | 4 | def fuzzy_search(string1, string2):
#String1 - name of task; String2 - input string; Returns True, if strings are similar, else False
count = 0
for symbol1 in string1.lower():
for symbol2 in string2.lower():
if symbol1 == symbol2:
count += 1
if (count / len(string2... |
a4249aa38622a8abe02ec45ab95df2ab301ff9f2 | mottaquikarim/pydev-psets | /pset_classes/wedding_guests/p1.py | 811 | 4 | 4 | """
Weddings I - Guest List
"""
# Imagine for this problem set that you are planning a wedding.
# A) Define a class called "Guest" to help you manage all the information about each invitee. This should initially include instance attributes for the guests's name, phone, and an optional "invite_sent" that defaults to... |
0e9b1de76f7e17bfda85bfe56f8934a82b945684 | dangconnie/algorithms | /sum_numbers.py | 869 | 4.03125 | 4 | # Sum Numbers (Requires numbers.txt)
# numbers.txt has a bunch of random numbers and the goal of this challenge is to sum all the digits of all the numbers to come up with the final result.
# You can open a file and read its contents using the "open" keyword. By default, readlines will put the filelines into a list. T... |
ea03c2d0e81924081b7664a2dca28fe7565bff8d | parvathy25/assignment-2 | /que10.py | 320 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 24 14:08:26 2020
@author: HP
"""
def palindrome(str):
#print (len(str)/2)
#print (int(len(str)/2))
for i in range(0, int(len(str)/2)):
if str[i] != str[len(str)-i-1]:
return "Not Palindrome"
return "Palindrome"
palindrome("malayalam")
|
3640790ef940270b6e4fce0664f7257e650f8a85 | andretgsilveira/Univespy | /insertionSort.py | 313 | 3.875 | 4 | def insertion_sort(lst):
for i in range(1, len(lst)):
elem = lst[i]
cont = i - 1
while cont >= 0 and elem < lst[cont]:
lst[cont + 1] = lst[cont]
cont -= 1
lst[cont + 1] = elem
lista = [1, 5, 4, 2, 3, 1, 7, 9, 33, 12]
insertion_sort(lista)
print(lista) |
25dc01b6ca7252bdfc03a9d1e1734a63087c7a35 | MrHamdulay/csc3-capstone | /examples/data/Assignment_5/hrssha001/question4.py | 784 | 4.25 | 4 | #Question 4 assignment 5 program to draw a graph
#Shane Horsley
#14 April 2014
import math
equation = input("Enter a function f(x):\n")#get equation
for y in range (10,-11,-1): #range of graph
for x in range (-10,11):#domain of graph
x_string="("+str(x)+")" #in order to substitute values of domain in to t... |
f3cb9ac9cba9e0a2362545a389654218d69fef95 | tab1tha/Beginning | /bool.py | 344 | 3.953125 | 4 | #this program is meant to experiment the use of boolean values,indentation,if else and import in python
nam=input( "what is the name of your daughter?:")
import string
name=string.capwords(nam)
value =bool(name)
if value==True:
print("your daughter "+name+" is in safe hands")
else:
name=input( "what is the na... |
4cc5b857ee4dfa24bb76b4cf358ea2dd9ff54ac3 | cleberzavadniak/prime-scramble | /mercafacil/prime_scramble/decrypt.py | 1,299 | 3.5 | 4 | from .constants import * # NOQA
from .tables import prime_numbers
def decrypt_sequence(source):
"""
Given a `source` sequence, returns a generator that
yield decrypted values for each correspondent item in
that sequence.
"""
# "Listify" parameters **IS** an official recommendation
# and,... |
66251da06b1a08656a9f20d7c8fde9ff0b9d7dc4 | RyanNSJ/DataSciProjects | /DataQuestArchive/data-cleaning/Challenge_ Cleaning Data-102.py | 763 | 3.796875 | 4 | ## 3. Exploring the Data ##
import pandas as pd
avengers = pd.read_csv("avengers.csv")
print(avengers.columns)
print(avengers.head(5))
## 4. Filtering Out Bad Data ##
import matplotlib.pyplot as plt
true_avengers = pd.DataFrame()
avengers['Year'].hist()
true_avengers = avengers[avengers["Year"]>1959]
## 5. Conso... |
b8235df3821a2cfe8b3791e31e9d6bd4fb9d39d3 | gottun510/tdd_vending-machine-4 | /tests/test_vending.py | 1,644 | 3.5 | 4 | # from unittest import TestCase
from vending_machine.hoge.coin import Coin, VendingMachine
class TestVendingMachine():
def test_check_coin(self):
machine = VendingMachine()
assert machine.check_coin(Coin(50)) == True
assert machine.check_coin(Coin(40)) == False
def test_treat_coin(se... |
d1ccef564394b67f0d06cc27db65bae6e1bb073b | corgiTrax/leetcode | /0036_valid_sudoku.py | 1,288 | 3.546875 | 4 | class Solution:
# @param board, a 9x9 2D array
# @return a boolean
def isValidSudoku(self, board):
#total of 9+9+9 lists
row_list = [[] for i in range(9)]
col_list = [[] for i in range(9)]
grid_list = [[] for i in range(9)]
#build lists
for i in range(9):
... |
5503c2759e0612cd13476ba84ca3abfde05455d0 | phriscage/coding_algorithms | /fibonacci/fibonacci.py | 1,015 | 4.34375 | 4 | #!/usr/bin/python2.7
"""
a fibonacci number can be easily calculated recursively, but this is not
efficient so we'll use memory instead.
1, 1, 3, 5
"""
_fibs = {0:0, 1:1}
def fib_optimized(number):
""" calculate the fibonacci number utilizing memory
Args:
number (int): number
Return... |
e9a63cedf63eba2005d41a9d339f2556b9a4a886 | YoussefIIbrahim/Computer-Graphics | /ErrorDiffusionUniformQuantization/uniformQunatization.py | 800 | 3.53125 | 4 | import numpy as np
from PIL import Image
def quantize(image, levels, maxCount=255, displayLevels=256):
im = np.array(image)
returnImage = im
if displayLevels is None:
# by default don't re-expand the image
displayCount = levels
elif displayLevels > 0:
displayCount = displayLev... |
ef1798bc97b6e059155b484fcced2cb754243fd1 | AriaOnTheString/computationalphysics_N2013301020076 | /ex8_ch3.7/pendulum1.py | 3,778 | 3.53125 | 4 | import math
import matplotlib.pyplot as plt
from matplotlib import animation
g=9.8
#calculate the trajectory
def DampedDriven(omega0,theta0,q,FD,omegaD,l,T):#q is related to damping force, while FD and omegaD is related to the driving force. the length of the rod is l.T is the interest time.
dt=0.001
t... |
630a6791075c044b6ee534cb722459db0d282b24 | zagara2/HackerRankSolutions | /SecondLargestNumber/secondlargestnumber.py | 232 | 3.9375 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
n = int(raw_input())
myarr = raw_input()
numlist = [int(x) for x in myarr.split()]
numlist = set(numlist)
numlist = list(numlist)
numlist.sort()
print numlist[-2] |
5ea3452d313d35ce6cd5c2242e662ddb4fcd971b | adamafriansyahb/algorithm-practice | /time_conversion.py | 765 | 3.71875 | 4 | def result(hour, minute, second):
return hour + ':' + minute + ':' + second
def my_function(s):
x = s.split(':')
y = list(x[2])
hour = int(x[0])
minute = x[1]
second = y[0] + y[1]
determiner = y[2]
if (determiner == 'P'):
if (hour == 12):
hour = str(hour)
... |
63dc623e20d6ef833d213d949e7a96f34032faaf | Zli123123/Waterloo-CCC | /waterloo1.py | 136 | 3.640625 | 4 |
b = int(input(""))
p = 5 * b - 400
print(p)
if p == 100:
print(0)
if p > 100:
print(-1)
if p < 100:
print(1)
|
83e5e6b32185456eabce8ed81c08ad4797569b97 | jwendl1/python | /mstomin.py | 1,766 | 3.984375 | 4 | #Import the GUI module
from Tkinter import *
import tkMessageBox
#Create the class to hold our GUI
class App(object):
def __init__(self):
#Define the Tkinter window
self.root = Tk()
#Set window size
self.root.minsize(width=300,height=50)
self.root.maxsize(width=300,height=11... |
b5753edd7400bb8ed09c6084484250dce9c6ceb0 | ennukim/leetcode | /intToRoman.py | 482 | 3.65625 | 4 | def intToRoman(num):
string = ""
nums = [1, 4, 5, 9, 10, 40, 50, 90,
100, 400, 500, 900, 1000]
symbol = ["I", "IV", "V", "IX", "X", "XL",
"L", "XC", "C", "CD", "D", "CM", "M"]
i = 12
remainder = num
while remainder:
quotient = remainder // nums[i]
remaind... |
a985955e33fe9429b9391876f9659d398344de80 | ahmedtufailtanzeem/automatingboringstuff | /projects/string_projects/bullet_point_adder.py | 451 | 4.0625 | 4 | import pyperclip
# Add's a * to a new line separated list
# Sample text
'''
Lists of animals
Lists of amphibians by region
Lists of birds by region
Lists of cats
'''
# Copy text from clipboard
text = pyperclip.paste()
print(text)
# Append '* ' in front of each list item
lines = text.split('\n')
for index in range(l... |
e9e0e7e5ea9c8e5c5298ab02badd0d8135346ccf | jaishivnani/Python-Practice-Problems | /6. Chapter Tuples in Python (Immutable)/12_checkingifallelementssame.py | 146 | 3.59375 | 4 | '''
'''
def check(sampleTuple):
return all(i==sampleTuple[0] for i in sampleTuple)
tuple1 = (45, 45, 45, 45)
print(check(tuple1))
|
4b8b5134bc776b37445b111cb724d845a3ae06fd | azhuox/leetcode-python | /11_container_with_most_water/solution.py | 1,119 | 3.765625 | 4 | """
Problem:
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai).
n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0).
Find two lines, which together with x-axis forms a container, such that the container contains the most ... |
5aa5e748c6d174a7cafb6dc85f26b998d2c4fd62 | ralonsobeas/UD3 | /ORM_SQLAlchemy_AsierSuarez/ejer4_4.py | 1,960 | 3.53125 | 4 | def delete():
from sqlalchemy import create_engine
from ejer4tablas import Olimpiada, Deporte, Deportista, Evento, Equipo, Participacion
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///database.db')
Session = sessionmaker(bind=engine)
session = Session()
... |
4506b7ccb1542b13d542e1d7179a62fc667ae2f7 | pulinghao/LeetCode_Python | /数组和链表/724. 寻找数组的中心索引.py | 864 | 3.734375 | 4 | #!/usr/bin/env python
# _*_coding:utf-8 _*_
"""
@Time :2021/1/28 10:13 下午
@Author :pulinghao@baidu.com
@File :724. 寻找数组的中心索引.py
@Description :
"""
class Solution(object):
def pivotIndex(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
leftSum = [0]
r... |
577f449f040cc120f71cd4106f1248d9f239487e | Sondren1288/simple-maths | /Python/cross_multiply.py | 201 | 3.921875 | 4 | def cross_multiply(x1:float, x2:float, y1:float):
"""
Given a fraction that looks like
a/b = c/d, returns d = bc/a, as shown below
x1 x2
y1 output
"""
return (y1 * x2) / x1
|
e80f7cf0a62f74ad2697cb1d6dc59b3ea3e9c9cb | Heqingquan/Leetcode-python | /Serialize and Deserialize Binary Tree.py | 1,979 | 3.78125 | 4 | import queue
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Codec:
def serialize(self, root):
"""Encodes a tree to a single string.
:type root: TreeNode
:rtype: s... |
40b9ca53e77b62ff901ef39b1e3a1dee77bd0c84 | rheehot/ProblemSolving_Python | /baekjoon_15657.py | 459 | 3.515625 | 4 | '''
Problem Solving Baekjoon 15657
Author: Injun Son
Date: August 27, 2020
'''
N, M = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
def back_tracking(cur_num, max_num, result, prev):
if cur_num==max_num:
for i in result:
print(i, end=" ")
print("")
els... |
761cd7baf40edc5639ec51d71e3de9625a3161fe | rajeevj0909/FunFiles | /Towers - OO.py | 6,647 | 3.640625 | 4 | #import time
class tower():
def __init__(self, src, aux, dest, counter, reciept, disks):
self.src = src
self.aux = aux
self.dest = dest
self.counter=counter
self.reciept=reciept
self.disks=disks
def towers(self):
for disk in range(self.disks)... |
2508d594c8ad62a5d7ab106deb100049b8c9bd50 | vish1/code | /python/client.py | 2,466 | 3.625 | 4 | from __future__ import division
from circuitous import Circle
c = Circle(10)
print u'Tutorial for Circuitous\N{trade mark sign}'
print 'Version %d.%d'% Circle.version
print 'A circle with a radius of', c.radius
print 'has an area of', c.area()
print
## Academic Friends ####
from random import random, seed
from ppri... |
eea1125bdabe5c26687ad20c23b67488ba18caf2 | diegoaspinwall/Unit-2 | /warmup3.py | 292 | 4.21875 | 4 | #Diego Aspinwall
#9-15-17
#warmup3
num = int(input('Input an integer: '))
if num%3==0 and num%2==0:
print(num, 'is divisible by 2 and 3')
elif num%3==0:
print(num, 'is divisible by 3')
elif num%2==0:
print(num, 'is divisible by 2')
else:
print(num, 'is divisible by neither 3 or 2')
|
6cd3095cd91bdf876a433bb92b06197b727d4ee0 | WillMc93/dailyprogrammer | /Easy/ThreeSUM-323.py | 697 | 3.609375 | 4 | challenge_input1 = [4,5,-1,-2,-7,2,-5,-3,-7,-3,1]
challenge_input2 = [-1,-6,-3,-7,5,-8,2,-8,1]
challenge_input3 = [-5,-1,-4,2,9,-9,-6,-1,-7]
# Algorithm almost directly from wikipedia
def threesum(inp):
output = set() # container for the output
inp.sort() # sort the input so we aren't looking everywhere
for idx in ... |
f1ab2d4513759c418a8639ac9f4bf8778973fe87 | bigbag01/leetcode | /树/101.对称二叉树.py | 2,606 | 3.609375 | 4 | #
# @lc app=leetcode.cn id=101 lang=python3
#
# [101] 对称二叉树
#
# https://leetcode-cn.com/problems/symmetric-tree/description/
#
# algorithms
# Easy (49.14%)
# Likes: 570
# Dislikes: 0
# Total Accepted: 84.4K
# Total Submissions: 170.5K
# Testcase Example: '[1,2,2,3,4,4,3]'
#
# 给定一个二叉树,检查它是否是镜像对称的。
#
# 例如,二叉树 [1,... |
d02e25547912df2f7951fe7b08cc4bd8292db922 | herculeshssj/python | /caelum-py-14-cap13/programa.py | 3,029 | 3.65625 | 4 | from collections import UserDict, defaultdict, Counter, deque, namedtuple
from collections.abc import MutableSequence
import csv
class Funcionario:
def __init__(self, nome, cpf, salario):
self._nome = nome
self._cpf = cpf
self._salario = salario
@property
def salario(self):
... |
839dd7168182ad508a811f6f334e3588b3f89b27 | Abhaysharma53/DU_MOR | /program_12.py | 369 | 3.984375 | 4 | a = input("enter the String which you want to check : ")
l = list()
count = 0
for i in range(len(a)):
l.append(a[i])
lcopy = l.copy()
l.reverse()
print(l)
print(lcopy)
#another for comparison
for i in range(len(l)):
if(l[i] == lcopy[i]):
count=count+1
if(count == len(l)):
print("string is palindrom... |
7abc6fc640fc3f77b4bc6b7e6d781925e2f8b22f | Na-Nazhou/AoC-2019 | /day4pt2.py | 786 | 3.796875 | 4 | #!/usr/bin/env python3
# python3 day4pt2.py 357253 892942
import sys
def main():
start = int(sys.argv[1])
end = int(sys.argv[2])
count = 0
for i in range(start, end + 1):
double = False
repeatcount = 0
nondecrease = True
string = str(i)
for j in range(1, 6):
... |
42d3e6452adfb1543312de6943d410c8ea6f5626 | Summer1006/Emotion-Words-Python | /Emotion Words-Excel Uploading.py | 540 | 3.578125 | 4 | import xlrd
Emowords = xlrd.open_workbook('C:\\Users\\niehu\\OneDrive - University of St. Thomas\\MsDS\\A - NPL\\Emowords - Python Practice.xlsx')
sheet = Emowords.sheet_by_index(0)
sheet.cell_value(0, 0)
#print the number of rows and the number of columns
print(sheet.nrows)
print(sheet.ncols)
#extract the colum... |
fdc2b648796be3b08af97e003ede1865a634fd23 | alissonjaques/simulador-de-automatos | /Simulador de Autômatos/src/estado.py | 2,133 | 3.890625 | 4 | #!/usr/bin/env python
"""
A classe Estado possui campos e métodos que representam o estado de um autômato.
"""
__author__ = "Alisson Jaques"
__copyright__ = "Copyright 2021, Projeto Autômatos"
__credits__ = ["Alisson Jaques"]
__license__ = "GPL"
__version__ = "1.0.0"
__maintainer__ = "Alisson Jaques"
__email__ = "... |
2e804f052d01e9ddfff02e9ee1c5f0befa50910b | viniciuspolux/UFPB | /IP/Lista-6/Comando de Repetição (while) – Lista de Exercícios 02/3.py | 188 | 4.03125 | 4 | cont=50
res=0
while (cont > 0):
numero=(int(input("Digite um número: ")))
if numero % 3 == 0:
res+= numero
cont -= 1
else:
cont -= 1
print(res)
|
bb1c36a792dd042b864e35a66260edbbfd3e0d25 | kagfupanda/pythonfp | /week8/8_6.py | 1,119 | 4.125 | 4 | #8_6.py
#Author Siddharth Srinivasan
import math
def main():
try:
while True:
max = eval(input("Enter a number to display the prime numbers before it: "))
if max > 0 and type(max) == int:
break
print("Ther is no prime n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.