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 |
|---|---|---|---|---|---|---|
6db5e6869bcca1f0cedc0307354eb14a89bc59ca | Pankajkumarsingh28/Python_selfStudy | /Compare_String.py | 214 | 3.71875 | 4 | str1=' I am Pankaj Kumar '
str2='I AM PANKAJ KUMAR'
print(str1)
print(str1.lstrip())
print(str1.rstrip())
str=str1.strip()
if str.lower()==str2.lower():
print("String are same")
else:
print("String are different")
|
972a6e2f9c046e745613f6d0d40f2bfae1077cf1 | Otes4444/100daysofcode | /projectile_2.py | 509 | 3.6875 | 4 | # python prgram to solve for projectiles
# formular to find intial velocity v0 =((acceleration due to gravity)*(time of flight )) / (2*sine of launch angle*angle of the initial velocity)
# g = acceleration due to gravity (9.80 m/s2)
# t = time of flight (s)
# θ = angle of the initial velocity from the horizontal plane... |
f23933a6fe309a493719382207c307b2269cbc2f | JayWebz/PythonExercises | /Module10/project1 - ChildHeightCalcGUI/hw10project1.py | 3,369 | 4.34375 | 4 | #! /usr/bin/python
# Exercise No. 1
# File Name: hw10project1.py
# Programmer: Jon Weber
# Date: Nov. 5, 2017
#
# Problem Statement: Write a program function that returns
# the expected height of a child, based on it's gender and height of parents.
#
#
# Overall Plan:
# 1. Greet User and prompt f... |
bfadef36e211fb74bc5191806e7e20577889683e | JayWebz/PythonExercises | /final/project3 - EmployeeDbCRUDapp/emp.py | 1,513 | 4.25 | 4 | class Employee:
"""employee is an object that creates and manipulates data about a particular employee such as calculating pay, printing employee info, ."""
# Initialize attributes
def __init__(self, firstName, lastName, employeeID, status, payRate):
self.firstName = firstName
self.lastName = lastName
self.e... |
5c8978b9860f2cba173eafa34cc0315bd0fe7a12 | JayWebz/PythonExercises | /Module3/project4 - EpactCalc/hw3extraCredit.py | 1,264 | 4.40625 | 4 | #! /usr/bin/python
# Exercise No. extra credit
# File Name: hw3extraCredit.py
# Programmer: Jon Weber
# Date: Sept. 10, 2017
#
# Problem Statement: Write a user-friendly program that
# prompts the user for a 4-digit year and then outputs the value of the Gregorian epact for that year
#
# Overall Plan... |
cd446e7ed3da381d0ad861dfebed7769a61ac211 | JayWebz/PythonExercises | /Module4/project2 - CalcSumGUI/hw4project2.py | 2,298 | 4.5 | 4 | #! /usr/bin/python
# Exercise No. 2
# File Name: hw4project2.py
# Programmer: Jon Weber
# Date: Sept. 17, 2017
#
# Problem Statement: Create a Graphical User Interface
# for a program that calculates sum and product of three numbers.
#
# Overall Plan:
# 1. Create a window for objects and print welcome... |
35621ed7d9d2dfdae93b1fba45b942a3a668efac | JayWebz/PythonExercises | /final/project3 - EmployeeDbCRUDapp/record.py | 1,308 | 4.3125 | 4 | class Employee:
"""employee is an object that creates and manipulates data about a particular employee such as calculating pay, printing employee info, ."""
# Initialize attributes
def __init__(self, firstName, lastName, employeeID, status, payRate):
self.firstName = firstName
self.lastName = lastName
self.e... |
cbf8c33ae5acc311c6fe5f08f53651da8af81290 | rlarsby/CS50x-Introduction-to-Computer-Science | /pset7/houses/roster.py | 815 | 3.71875 | 4 | from cs50 import SQL
import cs50
import csv
import sys
import sqlite3
# check command-line arguments
if len(sys.argv) != 2:
print("Usage: python roster.py 'house'")
sys.exit(1)
#set the command-line argument for which house
house = sys.argv[1]
#connect to database
connection = sqlite3.connect('students.db')
... |
13ffe9a8e769f756db3350f54d5b42110095b138 | almas06/SecondYear-ComputerEngineering-LabAssignments-SPPU | /DSL Assignments/GroupB_Assignment-14.py | 1,772 | 3.796875 | 4 | """Write a Python program to store first year percentage of students in array. Write
function for sorting array of floating point numbers in ascending order using
a) Selection Sort
b) Bubble sort and display top five scores."""
def getPercentage(n,percent_arr):
for i in range(0,n):
print("Enter the perc... |
11360a67b32279f0808e38f2d2f6cdb874a98063 | jr2bg/pathfinding_algorithms_python | /A_star/algos.py | 22,390 | 3.546875 | 4 | # requerimos un grid de m x n
# m filas, n columnas
# Dijkstra usa min heaps
import heapq
import csv
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import sys
sys.setrecursionlimit(10000)
import copy # copia de la instancia
# clase del nodito
# a partir de la información de la fila + colum... |
43898ef9598a6816e18dd12dfd9c8b5cb82dcc75 | songbaozi/practiceForOffer | /test.py | 1,032 | 3.671875 | 4 | # print("哈哈,很开心,我们的笔记本又可以用了,真的很开心,能够愉快的敲代码了,我很开心,试了一下,感觉很爽,这个笔记本花费了我6000多元,我要好好利用这个笔记本")
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def findPath(self,root):
onepath = ''
ret = []
self.dfs(root,onepath... |
8bb8bf301eed59ce951c288ea755f2762827fcb6 | TimothyVirgil/leetcode | /Python/leet007.py | 962 | 3.765625 | 4 | '''
LeetCode #7: Reverse Integer
Code by Timothy Payne Jr.
Started on: July 13, 2021
Finished on: July 14, 2021
'''
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
rev_str = ''
if x < 0:
str_x = str(-x)
for a... |
f1ab2b0e2354994285b55472628704fa8dc7a636 | atlas09/sea-c45-python | /hw/hw11/mailroom.py | 5,174 | 3.796875 | 4 | donor_list = [
<<<<<<< HEAD
['Bill Gates', 1.00, 10.00, 100.00],
['John Doe', 2.00, 4.00, 6.00],
['Jane Doe', 3.00, 6.00, 10.00]
]
def print_intro():
"""
"""
=======
["Bill Gates", [1.00, 11.00, 111.00]],
["Elon Musk", [2.00]],
["Paul Allan", [3.00, 6.00, 9.00]]
]
def main_menu():
>>... |
20c3bc4640bc015b6426a243a70c38ec5f6a5a84 | jmvx/python-challenge | /challenge1/challenge1.py | 132 | 3.53125 | 4 | #!/usr/bin/env python
# http://www.pythonchallenge.com/pc/def/map.html
message = "map"
for a in message:
print chr(ord(a)+2), |
a934665b4945be80329cc74f6aa1a6f8732b3f3a | anaclaralcruz/Teste_NAVI | /questao1.py | 334 | 3.6875 | 4 | # Autora: Ana Clara Loureiro
# Data: 19/12/2020
# Versao 1.0
#########################################################
# Teste de Python - NAVI
# Questao 1
def retorna_multiplos ():
lista = []
for i in range (1, 5000001):
# MMC(2,49,37) = 2*49*37 = 3626
if (i % 3626 == 0):
lista += [i]
return lista
print (... |
64ee1ff39d3caa75d629b897670a7cbae4420169 | dima2019python/python-master | /catepillar_one_player.py | 3,157 | 3.90625 | 4 | import random
import turtle as t
def outside_window(caterpillar):
left_wall = -t.window_width() / 2
right_wall = t.window_width() / 2
top_wall = t.window_height() / 2
bottom_wall = -t.window_height() / 2
(x, y) = caterpillar.pos()
outside = \
x < left_wall or \
x > right_wall or... |
6db0b5b97d346c7a4bc61582466d30b546e322b8 | malayilneil/Emergency-Department-Project | /Emergency Department Project.py | 1,376 | 3.9375 | 4 | # Lab 09: Emergency department triage of acute cardiac ischemia
# Your name
# Your email
# prompts
welcome_msg = 'Welcome to the Emergency Department Decision Support System'
q1 = 'Q1: Is there ECG evidence of acute Myocardial Infarction (MI)? (Y/N) '
q2 = 'Q2: Is there ECG evidence of acute Ischemia? (Y/N) '
... |
65735090625e636d5cc70421041a96aee59690a9 | chetangaur/Competitive-Coding-python- | /Sort Colors Leetcode.py | 1,256 | 3.90625 | 4 | # class Solution:
# def sortColors(self, nums: List[int]) -> None: # method 1 --> t=O(n2)
# ini_index=0
# for i in range(0,3):
# length=len(nums)
# for j in range(0,length):
# if(nums[j]==i):
# ... |
fc13f4d27de043a4a815e7d603e4c6be5b1f07a7 | GodspeedyJulian/9.11- | /2.py | 290 | 3.703125 | 4 | UpperCaseLetters = 0
Digits = 0
UserID = input("Your User ID: ")
for i in range(len(UserID)):
if 65<=ord(i)<=90:
upercase += 1
elif 0 <=int(i)<= 9:
digit += 1
if upercase == 3 and digit == 4:
print('valid user ID')
else:
print('invalid user ID')
|
7c604bb4a3525b3a1a3ab308a5144cc474e3d41a | ghyeon0/OOAD-Project | /CustomerControlUI.py | 1,076 | 3.578125 | 4 | from CustomerControl import CustomerControl
import os
class CustomerControlUI:
def __init__(self):
self.customer_control = CustomerControl()
def show(self):
os.system('cls' if os.name == 'nt' else 'clear')
print("1: 고객 추가")
print("2: 고객 삭제")
num = int(input("번호 입력: "))... |
529f61734e6e9ed59d994b63d49465f002983b2b | dalakada/TwiCSv2 | /data/conll_to_csv.py | 6,292 | 3.515625 | 4 | import json
import pandas as pd
def iob2(tags):
"""
Check that tags have a valid BIO format.
Tags in BIO1 format are converted to BIO2.
"""
for i, tag in enumerate(tags):
if tag == 'O':
continue
split = tag.split('-')
if len(split) != 2 or split[0] not in ['I', ... |
bb3d67cdadb626a31892f239dfca66509eb9ee21 | Avyakt-Agrawal/Calculator | /calculator2 (1).py | 8,534 | 3.515625 | 4 | import time
import math
import speech_recognition as sr
import pyttsx3
r=sr.Recognizer()
def SpeakText(command):
engine=pyttsx3.init()
engine.say(command)
engine.runAndWait()
def speak(MyText):
try:
with sr.Microphone() as source2:
r.adjust_for_ambient_noise(source2,duration=0... |
111dea4c5694e88f7f2e556dfc53e7a47222a56c | danielmerchant/euler | /problem_2.py | 581 | 3.734375 | 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. """... |
b0e6c4002bdf6f2cfb172b9299e2420a500ec4d4 | selden-lin/python_huffman_tree_decompressor | /huffman.py | 17,386 | 3.984375 | 4 | """
Code for compressing and decompressing using Huffman compression.
"""
from nodes import HuffmanNode, ReadNode
# ====================
# Helper functions for manipulating bytes
def get_bit(byte, bit_num):
""" Return bit number bit_num from right in byte.
@param int byte: a given byte
... |
47afa6d5a685538591e4915cb64fbab18e417690 | scottbing/SB_5410_HW4.1 | /Hwk41/TextProcessing/venv/SB_5410_Hwk4.1.py | 9,699 | 3.640625 | 4 | # BSSD Homework 4.1
# Scott Bing
# Text Manipulation
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from tkinter.filedialog import askopenfilename
from PIL import Image, ImageDraw, ImageTk
import tkinter.font as font
import string
import re
#global books dictionary
books = ... |
bbb0073e1b3428369ff3d1bb07067c9a54762724 | jamestis/CIS4930Project1 | /MRU_Cache.py | 1,678 | 3.765625 | 4 | from collections import OrderedDict
class MRU_Cache:
current_capacity = 0
# initialising capacity
def __init__(self, capacity: int):
self.cache = OrderedDict()
self.capacity = capacity
self.current_memory_used = 0
# we return the value of the key
# that is queried in O(1) a... |
c5b432f90e574cca2a34f68ce366b78f8117ca5c | LaunchCodeEducation/candidate-testing-assignment-data-analysis | /candidatetesting.py | 773 | 3.921875 | 4 | # TODO 2: modify your quiz app to ask 5 questions
# TODO 1.2a: Assign question, correct_answer, and candidate_answer
question = ""
correct_answer = ""
candidate_answer = ""
questions = ""
correct_answers = ""
candidate_answers = ""
def ask_for_name():
# TODO 1.1: Ask for candidate's name
return "What is your nam... |
3500d9ca5849300b7319d73c1bc248c761f4dbc9 | jackdoe/detective | /html/examples/30-love-tester.py | 304 | 3.84375 | 4 | def love_test(a,b):
sum = 0
for c in a+b:
print(c + ': ' + str(ord(c)))
sum += ord(c)
print('sum is:' + str(sum))
return sum % 100
while True:
nameA = input("first name: ")
nameB = input("second name: ")
print("love match: " + str(love_test(nameA,nameB)))
|
51eb42b6be88fa312002a18ba1d0594574b2501f | PuchoDeepLearningLabs/tensorflow_end2end_speech_recognition | /experiments/utils/labels/phone.py | 1,395 | 3.953125 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
def phone2num(phone_list, map_file_path):
"""Convert from phone to number.
Args:
phone_list: list of phones (string)
map_file_path: path ... |
360005388208f8f1d8a6f09c6928cd4e07aa47d9 | RenatoCesarF/Loopyng | /TKinter/TK_play.py | 1,220 | 3.75 | 4 | 5# Aqui ficará a função de play-pause do programa, todos os pedais
# vão usar ela.
#
# Ela ira receber um parametro "nome_tape" pra saber o que estará
# pausando e tocando
#
# O tk inter não tem um bom reprodutor de sons e por isso estarei usando
# o pygames.mixer pra fazer a nossa reprodução
from pygame import mi... |
0953cb8f2e7fcb4b3abbf3c16f26ac12d8319ae4 | tiashasarkar26/Python_Codes | /batch_5pm/design/database_in_python/data_fetch.py | 344 | 3.796875 | 4 | import sqlite3 as sql
db = sql.connect('grras.db')
c = db.cursor()
cmd = 'select * from student'
c.execute(cmd)
data = c.fetchall()
print("Data of Student Table : ")
for item in data :
print(*item)
cmd = 'select * from fees'
print("Data of Fees Table ")
c.execute(cmd)
data = c.fetchall()
for item in d... |
03a3ad448aee9969a851721c09f02e54770accc3 | PierreQuinton/hermit_crab | /graph.py | 2,010 | 3.640625 | 4 | # -*- coding: utf-8 -*-
class Graph:
"""Representaion of a Graph of pages"""
def __init__(self):
self.graph = {}
def addNode(self, name):
"""
:param name: name of the Node
"""
if self.graph.get(name) == None:
self.graph.update({name:set()})
def addC... |
a45bdaba001d089b9e4799f46ba9a1eeb03db2a2 | BHill96/TXSTproblemSolvers | /shuffleProblem.py | 3,608 | 4.0625 | 4 | import copy
import csv
import time
# Inserts every number between 1 and maxNumber into myList in reverse order
# i.e. 5, 4, 3, 2, 1
def populateList(myList, maxNumber):
for number in range(1, maxNumber + 1):
myList.append(number)
# Removes every other number and appends it to the bottom starting with the ... |
a65636109444caef8f54358730b0a1280e401297 | wylunbelievable/Enron-mini-project | /datasets_questions/explore_enron_data.py | 1,756 | 3.609375 | 4 | #!/usr/bin/python
"""
Starter code for exploring the Enron dataset (emails + finances);
loads up the dataset (pickled dict of dicts).
The dataset has the form:
enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict }
{features_dict} is a dictionary of features associated with that pers... |
a7ecdbb0d8bc1b9d878a51b19725288a29075ecc | vishrutjai/Codechef | /QUALPREL.py | 1,557 | 3.5625 | 4 | def merge(l1,l2):
l3 = []
p1 = 0
p2 = 0
m = len(l1)
n = len(l2)
while p1 < m and p2 < n:
if l1[p1] < l2[p2]:
l3.append(l1[p1])
p1 += 1
elif l1[p1] > l2[p2]:
l3.append(l2[p2])
p2 += 1
else:
l3.append(l1[p1])
... |
0d6b953101006576a0a753f828384ed40a7837e3 | vishrutjai/Codechef | /STRPALIN.py | 583 | 3.609375 | 4 | a = input()
for x in range(a):
str1 = raw_input()
str2 = raw_input()
if str1 == str2:
print 'Yes'
elif len(str1) == 1 and len(str2) == 1:
if str1 == str2:
print 'Yes'
else:
print 'No'
else:
flag = 0
for x in range(1,len(str1)+1):
... |
8574eeeb8bfb296fb6ca9b8483c74417eed3bbc1 | vishrutjai/Codechef | /CMB02.py | 293 | 3.75 | 4 | def palindrome(x):
n = str(x)
str1 = ''
for i in range(len(n)-1,-1,-1):
str1 += n[i]
if str1 == n:
return True
else:
return False
a = input()
for h in range(a):
num = input() + 1
while palindrome(num) != True:
num += 1
print num |
fe2877f719c966c36b857f5fa3ce62ef92b69bec | vishrutjai/Codechef | /SPIT3.py | 543 | 3.546875 | 4 | string = raw_input()
flag1 = flag2 = flag3 = flag4 = 0
count = 0
count1 = 0
for x in string:
if x.isalpha() == True:
count += 1
if count == 5:
flag1 = 1
if x.isdigit() == True:
flag2 = 1
elif x.isupper() == True:
flag3 = 1
elif x.islower() == True:
flag4 =... |
9289067a64fc72bfe87bff0c5bb0309b7d242db5 | vishrutjai/Codechef | /CHEFSTLT.py | 429 | 3.515625 | 4 | a = input()
for x in range(a):
s1 = raw_input()
s2 = raw_input()
count = 0
for i in range(len(s1)):
if s1[i] != s2[i] and s1[i] != '?' and s2[i] != '?':
count += 1
count1 = 0
for i in range(len(s1)):
if s1[i] != s2[i] or (s1[i] == '?' and s2[i] == '?'):
... |
4558ab5b956ed344e9fa5f2ec23aa3955647b27f | vishrutjai/Codechef | /PRPALIN.py | 493 | 3.96875 | 4 | def palindrome(n):
string = str(n)
a = string[::-1]
if string == a:
return True
else:
return False
def isprime(n):
flag = 0
for x in range(2,n):
if n % x == 0:
flag += 1
if flag != 0:
return True
else:
return False
n = input()
while Tr... |
b4e541d923761551ece478eb520c77b89b994f0b | avoss19/Project-Euler | /Euler009.py | 335 | 3.5 | 4 | # Project Euler
# Problem 9 - Special Pythagorean triplet
# https://projecteuler.net/problem=9
# Created by Andrew Voss
def solution():
for z in range(0, 1000):
for y in range(0, z):
for x in range(0, y):
if(x+y+z==1000) and ((x*x)+(y*y)==(z*z)):
return x*y*... |
0032ce9256309136ce677f80e443ebac6aa34b6d | dpcfury/crawl | /module_test/dpc/reg/re_test.py | 342 | 3.734375 | 4 | # -*_ coding:utf-8 -*-
import re
print re.search(r"\d+", "my age is 23 and my height is 175cm", re.I).group()
for item in re.findall(r"\d+", "my baby is 4 years old and my dad is 47 "):
print item
str1 = "my baby is 4 years old and my dad is 47 "
print re.sub(r"\d+", "secret", str1)
for item in re.split(r" ", ... |
79b5a5c3b94fdf2963046a5bf4dbd8d28c957b04 | dpcfury/crawl | /module_test/dpc/exception/random_test.py | 426 | 4.0625 | 4 | # -*- coding:utf-8 -*-
import random
num = random.randint(0, 100)
while True:
try:
guess = int(raw_input("Please Enter a num 1~100:"))
except ValueError as e:
print "please input a num"
continue
if guess > num:
print "guess Bigger", guess
elif guess < num:
print... |
bfbff103805627cf8edd4cee9256d48761d26969 | BranSmit/Project-Euler-Solutions | /P1-10/P7.py | 638 | 3.9375 | 4 | # 10001st prime
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
# What is the 10 001st prime number?
primes = [2]
def isPrime(n): # This only works if the primes fed to it are in acending order, pretty much just for use in nthPrime()
for... |
dfe948c710776e7d17f4a6e57dce25e78910606b | Howie21/ProblemSolvingWS | /ProblemSolving/ProblemSolvingII.py | 1,052 | 4.09375 | 4 |
import math
#Prime Number
def primeCheck(x):
sta = 1
for i in range(2,int(math.sqrt(x))+1):
if(x % i == 0):
sta = 0
print("Not Prime")
break
elif(sta==1):
print("Prime")
return sta
#Fibonacci
def print_single_integer(list):
for n... |
26b3396784199082230b7a341a2e22e1a113d6c3 | Slackd/python_learning | /PY4E/list_calcs.py | 319 | 4 | 4 | largest = None
print('Before: ', largest)
for itervar in [12, 40, 55, 65, 73, 18, 100]:
if largest is None or itervar > largest:
largest = itervar
print('Loop:', itervar, largest)
print("Largest:", largest)
total = 0
for itervar in [3, 4, 5, 6, 7, 8, 100]:
total += itervar
print("Total:", total)
|
48df7ef8f1638b25aa1c405fa7f941792d5d6029 | Slackd/python_learning | /PY4E/05-iterations.py | 665 | 4.28125 | 4 | #! /usr/bin/python3
# Write another program that prompts for a list of
# numbers as above and at the end prints out both the maximum
# and minimum of the numbers instead of the average.
userNums = input("Enter Numbers Separated by spaces: ")
inputNums = userNums.split()
for i in range(len(inputNums)):
inputNum... |
91a712961cbd6bfd8c8ec3de6629d178d6e0b62e | Slackd/python_learning | /First/if_else.py | 616 | 4.34375 | 4 | is_male = False
is_tall = True
if is_male and is_tall:
print("You are a tall male")
elif is_male and not (is_tall):
print("you are a short male")
elif not (is_male) and is_tall:
print("you are not a male, but are tall")
else:
print("you are neither male not tall or both")
num1 = input("Enter 1st N... |
0b1a34ec4b9912285391c0bba0d301780f7807f9 | Akshay-s-raut/Python | /Fun/text_to_morse_code.py | 1,295 | 3.65625 | 4 | import time
dot = 0.3
dash = dot*3
space = dot*5
print("Text to Morse code converter")
code= {'a': '._', 'b':'_...' , 'c':'_._.', 'd':'_..', 'e':'.' , 'f':'.._.' , 'g':'__.' , 'h':'....' , 'i':'..' , 'j':'.___' ,
'k':'_._', 'l':'._..' , 'm':'__' , 'n':'_.' , 'o':'___' , 'p':'.__.' , 'q':'__._' , 'r':'._.' , '... |
672cadcefde4110d328bb3921750b7e262ae373b | Akshay-s-raut/Python | /Maths tools/deltaY_interpolation.py | 579 | 3.515625 | 4 | n=int(input('Enter number of values '))
y=list()
for i in range(0,n):
s=float(input())
y.append(s)
def ncr(n,r):
numerator=1
denominator1=1
denominator2=1
for i in range(1,n+1):
numerator=numerator*i
for i in range(1,r+1):
denominator1=denominator1*i
for i in range(1,(n-r... |
dffa174c36b7c06d54fe78c662733374e7526b42 | Akshay-s-raut/Python | /Maths tools/minterms.py | 1,933 | 3.734375 | 4 | print('Convert any Boolean expression to Sop')
print('#Note: take conjugate of "A" as "a" ')
print()
exp=input('Enter the expression: ')
def sop(exp):
terms =[i.lstrip().rstrip() for i in exp.split('+')]
counts=dict()
counts_for_n=dict()
for i in terms:
for j in i:
counts[j] = co... |
608c5a0254ff212be008f81322bfddb3a29fc244 | Nurs312/practic_tasks | /student.py | 1,096 | 3.921875 | 4 | class Student:
__university = 'Politechnical'
__city = 'Bishkek'
def __init__(self, firstname, lastname, faculty, year_of_enterance):
self.firsname = firstname
self.lastname = lastname
self.faculty = faculty
self.year_of_enterance = year_of_enterance
def __get_student_i... |
119cb132fd2efe6ec6e3a7774258a73a30276200 | alex-snoralex/tensorflow | /Celsius2Fahrenheit/BasicModel.py | 1,562 | 3.765625 | 4 | # https://colab.research.google.com/github/tensorflow/examples/blob/master/courses/udacity_intro_to_tensorflow_for_deep_learning/l02c01_celsius_to_fahrenheit.ipynb
from Celsius2Fahrenheit.Formula import celsius_2_fahrenheit
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import logging
logg... |
aa8ce6129b8af85be3819daa8996faaaf5b8dae7 | kyojinatsubori/RoadToRedCoder | /Snishiki/Other Contests/第一回アルゴリズム/F.py | 284 | 3.71875 | 4 | S = input()
words = []
memo = 0
flag = 0
for i in range(len(S)):
if S[i].isupper():
if flag == 0:
memo = i
flag = 1
else:
words.append(S[memo:i+1])
flag = 0
words = sorted(words, key=str.lower)
print("".join(words))
|
6c7fa33ff966a9ea1d102f5f93a128138ef18162 | kyojinatsubori/RoadToRedCoder | /kyoji/第一回アルゴリズム検定/F.py | 269 | 3.6875 | 4 | s=input()
words=[]
flag=0
memo=0
for i in range(0,len(s)):
if s[i].isupper():
if flag==0:
flag=1
memo=i
else:
flag=0
words.append(s[memo:i+1])
words = sorted(words, key=str.lower)
print("".join(words)) |
fc6db8b8252ed6172a67c5a64162e600748e1bca | kyojinatsubori/RoadToRedCoder | /Snishiki/ABC/ABC079/B.py | 195 | 3.75 | 4 | N = int(input())
memo = []
for i in range(N+1):
if i == 0:
memo.append(2)
elif i == 1:
memo.append(1)
else:
memo.append(memo[i-1] + memo[i-2])
print(memo[N])
|
86d1bd41d5682d09eaa8356a0dcde8c978b11210 | Voidivi/Python-1 | /Pig Latin Translator.py | 1,847 | 4.40625 | 4 | #!/usr/bin/env python3
# Assignment Week 6 - Pig Latin Translator
# Author: Lyssette Williams
# global values for the program
ay = 'ay'
way = 'way'
vowels = ['a','e', 'i', 'o', 'u']
punctuations = '''!()-[];:'",<>./?@#$%^&*_~'''
# decided to add some formatting stuff to make it more readable
def display():... |
8e64202b2839a1bb4fbac75509efcc4109443262 | 11/superdoku | /scripts/sudoku_solver/sudoku.py | 2,936 | 3.71875 | 4 | from collections import namedtuple
class Cell:
def __init__(self, num=0):
self._num = num
self._values = set(range(1,10)) if num == 0 else None
def __repr__(self):
return str(self.num)
def is_fillable(self):
return len(self._values) == 1 and self._num == 0
def fill(s... |
686065f3bf2dc1d694e45ec79f1d0199afa57a4f | jwin4740/python_hamilton_hangman | /hangman.py | 3,643 | 3.90625 | 4 | from random import randint
import time
WORD_LIST = ["Alexander Hamilton", "My Shot", "The Story of Tonight", "The Schuyler Sisters", "Farmer Refuted",
"Right Hand Man", "Helpless", "Satisfied", "Wait for It", "Stay Alive", "Ten Duel Commandments",
"Meet Me Inside", "That Would Be Enough"... |
2a5bbebe132d67a01830fcda9865073610126073 | 00dbgpdnjs/webscrapping | /3_movie_img_scraping/1_get_img_url.py | 461 | 3.5 | 4 | # Print all (movie's) img url on "res" [daum]
# < Basic Frame >
import requests
from bs4 import BeautifulSoup
# This link : site to work
res = requests.get(
"https://search.daum.net/search?w=tot&q=2020%EB%85%84%EC%98%81%ED%99%94%EC%88%9C%EC%9C%84&DA=MOR&rtmaxcoll=MOR")
res.raise_for_status()
soup = Beauti... |
bf54df5fee81c8d638cbb25c699fce89e362e065 | crazyministr/ShipExpress | /utils/decorators.py | 301 | 3.53125 | 4 | # -*- coding: utf-8 -*-
import time
def timeit(func):
"""
Time of execution
"""
def timed(*args, **kwargs):
start = time.time()
result = func(*args, **kwargs)
end = time.time()
print func.__name__, end - start
return result
return timed
|
60f76c7cd769d9a479634c8bb6e47175a7179b6b | wallace123/adventofcode | /2019/day1.py | 823 | 3.609375 | 4 | #!/usr/bin/python3
import math
INPUT1 = 'data/day1'
TEST1 = '14\n'
TEST2 = '1969\n'
TEST3 = '100756\n'
with open(INPUT1) as f:
data = f.read()
def parse1(data):
mass = []
mydata = data.split('\n')
del mydata[-1]
for line in mydata:
#print(line)
mass.append(int(line.strip()))
r... |
d43d936ae167bc5a4f654efe4efdc94a06b480a9 | wallace123/adventofcode | /2021/day7.py | 1,244 | 3.59375 | 4 | #!/usr/bin/python3
class Crabs:
def __init__(self):
self.puzzle = self._parse_input()
self.fuel_list = []
self.min_fuel = 0
def _parse_input(self):
with open('data/day7.txt', 'r') as infile:
content = infile.read().rstrip()
return [int(n... |
2e9ffcc1f047853d2950569caa3ab30838aa40f1 | kelz877/WeekTwo | /pooltable2.py | 2,713 | 3.78125 | 4 | import json
import datetime
class PoolTable:
def __init__(self, number = 0, start = 0, end = 0, total_time = 0, available = True):
self.number = number
self.start = ""
self.end = ""
self.total_time = ""
self.available = True
def TableInfo(self):
return f"""
... |
124eed092ae60542ddd37e168d0f0c1211d2e1fe | Paris18/Python-Codes | /problem10.py | 1,349 | 4 | 4 | '''Given an n x n matrix, where every row and column is sorted in non-decreasing order. Find the kth smallest element in the given 2D array.
For example, consider the following 2D array.
10, 20, 30, 40
15, 25, 35, 45
24, 29, 37, 48
32, 33, 39, 50
The 3rd smallest element is 20 and ... |
f5b22ec6f30c9d286bc75a37f5001c493abe6b58 | Maria-Lasiuta/geegs_girls_lab3 | /ex3(3).py | 363 | 4.15625 | 4 | #Calculate number of distinct characters in a string using a for loop.
def unique_count(word):
k=list()
b = word.split()
b = ''.join(b)
for x in b:
if x not in k:
k.append(x)
return len(k)
enter=input()
print('унікальних символів:',unique_count(enter))
... |
2cb3cf3b87d0068c7291eb80c7be10675218e57d | Maria-Lasiuta/geegs_girls_lab3 | /lab 3/5(3).py | 376 | 4.15625 | 4 | #Check if the number is prime
def is_prime(n):
if n > 1:
for i in range(2, (int(n/2)+1)):
if n%i == 0:
return f'{n} is not a prime number'
else:
return f'{n} is a prime nummber'
else:
return f'{n} is a prime number'
n = in... |
5e5e915e6ae134fd4430aff09c999ca10b182fc0 | marcrichardson/learning-python | /upper_lower.py | 374 | 3.78125 | 4 | def up_low(s):
upper_count = 0
lower_count = 0
for i in s:
# print(i)
if i.isupper():
upper_count = upper_count + 1
if i.islower():
lower_count = lower_count +1
lower_output = 'lower count is {}'.format(lower_count)
output = 'upper count is {}'.format(u... |
2ee0f61cbd96521fbd0aa71f12e54243b4b1a54e | rajatsharma98/CS677 | /HW/lyndon97_3_3_7.py | 2,670 | 3.59375 | 4 | '''7. what are the top 5 most popular items for each day of the week?
does this list stays the same from day to day?'''
import os
import pandas as pd
wd = os.getcwd()
input_dir = wd
file = os.path.join(input_dir, 'BreadBasket_DMS_output.csv')
df = pd.read_csv(file)
# out_file = os.path.join(input_dir, 'res_1.csv')
# ... |
43140f4f108e16977423a21c3f5c3e4eb093346a | rajatsharma98/CS677 | /HW/lyndon97_8_2_1.py | 1,760 | 3.609375 | 4 | '''
Implement a Naive Bayesian classifier. For each week, your
feature set is (µ; σ) for that week. Use your labels (you will
have 52 labels per year for each week) from year 1 to train your
classifier and predict labels for year 2. Use Gaussian Naive
Bayesian (this is the default).
implement a Gaussian naive bayesian... |
7e428a0ee50b20a8d6b227201e78386fa1e4e4b1 | tptorres/algorithms | /LC/two_city_scheduling.py | 280 | 3.5625 | 4 | def two_city_scheduling(costs):
costs.sort(key=lambda cost: cost[0] - cost[1])
res = 0
for i in range(len(costs) // 2):
res += costs[i][0] + costs[i + len(costs) // 2][1]
return res
print(two_city_scheduling([[10, 20], [30, 200], [400, 50], [30, 20]]))
|
c8b498c94f201043beb306187fe2ed5a1c6bc23b | tpb261/hackerRank | /strings/easy/Got_anag_palin.py | 359 | 3.640625 | 4 | #!/usr/bin/python3
s[]=["aaabbbb", "cdefghmnopqrstuvw", "cdcdcdcdeeeef"]#input()
odd_count = 0
for c in range(ord('a'), ord('z')+1):
# print(chr(c), s.count(chr(c)), odd_count)
if(1 == s.count(chr(c)) % 2):
odd_count+=1
if(odd_count > 1):
break
#print(odd_count)
if(1 >= odd_count):
... |
8e052d665d6f65500c7ec0abcc96a925f5445cba | sbhdhr/python-scripts | /AI-ASGNMT-1 - Copy/q.py | 1,959 | 3.734375 | 4 | from turtle import Screen, Turtle
import random
N = 10 # N by N grid
LENGTH = 60 # each grid element will be LENGTH x LENGTH pixels
def showMatrix(turtle_object, sparse_matrix):
rows = len(sparse_matrix)
if rows == 0:
return
columns = len(sparse_matrix[0])
turtle_object.penup()
for ... |
873e22eefd0deff3a630c3e50cc5b9a6f4d1ea4c | phamthienduc13/chapter03 | /venv/Quarter of the Year.py | 551 | 4.09375 | 4 | user_month = int(input('Enter a month between 1-12: '))
if user_month < 1 or user_month > 12:
message = "Error. Please re-enter the month"
else:
message = "Month " + format(user_month) + " is in the"
if user_month >= 1 and user_month <= 3:
message += " first"
elif user_month >= 4 and user_month ... |
5cc53dcdf71cd3632d516f6e0c3cf5205268849f | ImQuasiParticle/PythonPrograms | /BinToInt.py | 200 | 3.890625 | 4 |
def binToInt(n):
return int(n,2)
print("Enter the number of Test Cases")
t = int(input())
while t:
print("Enter a Binary Number")
a = int(input())
print(binToInt(str(a)))
t = t-1 |
6f2de80d60c6475976b2c0cba5b422603cab3cd6 | r78/euler | /problem001/1.py | 217 | 3.609375 | 4 | #!/usr/bin/env python
#print sum(filter(lambda x: x % 3 == 0 or x % 5 == 0, range(3, 1000)))
def sum_m(n, mul):
return (n - (n % mul) + mul) * (n / mul / 2.0)
n = 999
print sum_m(n, 3) + sum_m(n, 5) - sum_m(n, 15)
|
4ae76eeee25d37e786eda9fea0dc14163c77a8fa | epotyom/interview_prepare | /coding/sorts/quicksort.py | 1,154 | 4.28125 | 4 | def sort(data):
"""
Quicksort function
Arguments:
data(list): list of numbers to sort
"""
sortIteration(data, 0, len(data)-1)
def sortIteration(data, first, last):
"""
Iteration of quicksort
Arguments:
data(list): list to be sorted
first(int): first element of iteration
last(int): l... |
71c83c3de72d963afdff7f84dd6d5f2377371314 | Nagaraja007/nlpchatbot | /all_triples.py | 1,124 | 3.765625 | 4 | # Python script to load in a CSV of sentences and use module features.py
# to extract triples for each class-label defined in the the sentences CSV
import nltk
from nltk import word_tokenize
import csv
import sys
import features # module to extract feature from a line of text
# Read in a list of sentences in a CSV... |
6cf899001b40166198f5cf59395329fdeaa33a23 | parasurama/advent_of_code | /puzzle6.py | 790 | 3.640625 | 4 | import pandas as pd
import csv
# read puzzle input and break codes into column
codes = []
with open('puzzle_inputs/input6.txt') as f:
reader = csv.reader(f)
for row in reader:
codes.append([x for x in row[0]])
print(codes)
# convert code to dataframe
df = pd.DataFrame(codes)
print(df)
###############... |
0db6560dc02ba4ce3c4c5ba9a46d5a77bd7273be | sweaterfuzz/evolveu_exercises | /tdd/test_our_math.py | 282 | 3.5625 | 4 | # Begin tdd
import unittest
import my_math
class TestDates(unittest.TestCase):
def test_multiply(self):
a=3
b=4
self.assertEqual(a*b,my_math.multiply(a,b))
a=-4
b=5
self.assertEqual(a*b,my_math.multiply(a,b))
a=4
b=0
self.assertEqual(a*b,my_math.multiply(a,b)) |
be32e45a5622eb378a409226def82cc57acce46f | EduardoPacheco12/Banco-Wtic | /ChangeInformation.py | 2,418 | 3.859375 | 4 | import os,sys
import MainScreen
import UserSettings
#ALTERAR INFORMAÇÕES PESSOAIS
def alteracao_informacoes(nome_cliente):
while(True):
abrir_senha = open(f'{nome_cliente}/senha.txt','r')
senha_antiga = abrir_senha.read()
abrir_senha.close()
print("<!>ALTERAR INFORMA... |
802511942fe61c69de571ccec21fca13fc581f1b | 19Ivan9/lesson_3 | /lesson3.py | 700 | 3.90625 | 4 | print('tack1')
if __name__ == '__main__':
name = 'ivan'
day = ' SATURDAY '
name = name.capitalize()
day = day.strip()
day = day.lower()
day = day.capitalize()
rez = 'Good day {}! {} is a perfect day to learn some python'.format(name, day)
print(rez)
print('tack2')
first_nam... |
820dca361b752699d098b0d9b59615971ecdc524 | yohannabittan/iterative_hasher | /iterative_hasher.py | 2,778 | 4.3125 | 4 | #written by Yohann Abittan
#this program uses hashlib to either produce hashes which have been hashed iteratively a given number of times
#or to test wether a given hash matches a password after a number of iterations of hashing
import hashlib
def encryptMd5(initial):
encrypted = hashlib.md5()
encrypt... |
dafd3c9b049d8f6562211aae86cfc31ae74f51ad | yibwu/leetcode | /src/reconstruct_binary_tree.py | 1,173 | 3.6875 | 4 | # -*- coding:utf-8 -*-
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# 返回构造的TreeNode根节点
def reConstructBinaryTree(self, pre, tin):
return self.helper(pre, 0, len(pre) - 1, tin, 0, len(tin) - 1)
def helper(self, ... |
7d3dc8be05f2ff8bbe421c5bdb15bcac3c3289ab | yibwu/leetcode | /src/reverse_words_in_a_string_151.py | 868 | 3.640625 | 4 | class Solution(object):
def reverse_words(self, s):
"""
:type s: str
:rtype: str
"""
s = s.strip()
s = s[::-1]
result = ''
start = 0
in_word = False
i = 0
while i < len(s):
if s[i] == ' ':
if not in_... |
710522478d98cb1b96466eecc0f36aca0784e687 | yibwu/leetcode | /src/battleships_in_a_board_419.py | 904 | 3.703125 | 4 | class Solution:
def count_battleships(self, board):
"""
:type board: List[List[str]]
:rtype: int
"""
rows = len(board)
cols = len(board[0])
count = 0
for i in range(rows):
for j in range(cols):
if board[i][j] == 'X':
... |
467292834dd7b17696a751c16112e62679cc0be4 | yibwu/leetcode | /src/1344.py | 289 | 3.703125 | 4 | class Solution:
def angleClock(self, hour: int, minutes: int) -> float:
hour_degree = ((hour % 12) * 5 + minutes * 2.5 / 30) * 6
minute_degree = (minutes % 60) * 6
diff = abs(hour_degree - minute_degree)
return diff if diff < 180 else (360 - diff)
|
9ba7dc0545009a07ab1a1d5fb591ba294f0ed0f0 | yibwu/leetcode | /src/sqrt_69.py | 548 | 3.609375 | 4 | class Solution:
def my_sqrt(self, x):
"""
:type x: int
:rtype: int
"""
left, right = 1, x
while left <= right:
mid = left + (right - left) // 2
if mid < x / mid:
left = mid + 1
elif mid > x / mid:
ri... |
702ffdd274922aa5f2bf26801b821eeba3cce49b | yibwu/leetcode | /src/LCA_235.py | 1,924 | 3.734375 | 4 | # Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def lowest_common_ancestor(self, root, p, q):
"""
:type root: TreeNode
:type p: TreeNode
:type q: ... |
cc23cb72292c0ed0f897014c8f7c162aabffffff | yibwu/leetcode | /src/Kth_largest_element_in_an_array_215.py | 1,419 | 3.546875 | 4 | class Solution(object):
def findKthLargest(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: int
"""
ret = self.quick_sort(nums, k, 0, len(nums) - 1)
return ret
def quick_sort(self, nums, k, left, right):
if left < right:
... |
26cf14b04dd117f05576f451cfba3c16c7a3cfa4 | yibwu/leetcode | /src/surrounded_regions_130.py | 2,903 | 3.703125 | 4 | class Solution:
def solve(self, board):
"""
:type board: List[List[str]]
:rtype: void Do not return anything, modify board in-place instead.
"""
visited = set()
connected_component = []
target = "O"
i = 0
while i < len(board):
... |
22aa5328f679a94d381d12c7e96fb4054ba04be5 | yibwu/leetcode | /src/307.py | 2,293 | 3.515625 | 4 | class TreeNode:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
class NumArray:
def __init__(self, nums: List[int]):
self.nums = nums
self.root = self.buildSegmentTree(nums, 0, len(nums)-1)
def buildS... |
413b798fdce4ad0e4ff18656b3a762313f1afa89 | pythonkurs/pjohansson | /scripts/getting_data.py | 517 | 3.5 | 4 | """Downloads escalator service data of the NYC subway system and calculates the
fraction of those having the status of 'Repair'."""
from pjohansson.session2 import download_data, get_outage_data, count_repair
raw_data = download_data()
outage_data = get_outage_data(raw_data)
num_repair = count_repair(outage_data)
pr... |
021f2c013c76fbd157f2106dab39c82ce4e49d88 | GesukaLeo/First_Class | /addTwo.py | 234 | 3.984375 | 4 | # A program to add two numbers
# First Define a function
def sum(a,b):
sum=a+b
# Return the value of sum
return sum
# Enter the values to be added
sum1=sum(50,30)
sum2=sum(6,4)
# Finally print sum
print(sum1)
print(sum2)
|
44410cec78b72c1629b622cfb02217fa8adb5710 | Khalida02/Week1 | /w3school/3.python_variables/5.py | 136 | 3.71875 | 4 | #multiple variables
x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
x = y = z = "Orange"
print(x)
print(y)
print(z) |
1817ccf74ed79881b17d5e029cffa926ee282e93 | chrismvelez97/GuideToPython | /techniques/exceptions/value_error.py | 989 | 4.625 | 5 | # How to handle the value error
'''
The value error is when your
program is expecting a certain
value type back such as a number
or a string and you get the other.
For example, we'll be using a
calculator that can add, but
get a value error if we type letters
in place of numbers.
The following is ... |
07885e568c95f23da65fdf0b6c9cf70c65674a3f | chrismvelez97/GuideToPython | /techniques/conditionals/multiple_If_statements.py | 412 | 3.90625 | 4 | # How to use multiple if statements
requested_toppings = ["mushrooms", "extra cheese"]
'''
The following code checks multiple if statements to see if any of them will
run
'''
if "mushrooms" in requested_toppings:
print ("Adding mushrooms")
if "extra cheese" in requested_toppings:
print (... |
6dfde392607bfe8accf5baa0e097e7ee838717da | chrismvelez97/GuideToPython | /techniques/files/storingData/saving_user_data.py | 730 | 4.1875 | 4 | # How to save user data
'''
Using the json.dump() and json.load()
techniques we just learned about, we
can actually save user data to be
used at a later time.
'''
import json
username = input("Hello! What is your name?\n\n")
path = "/home/chrismvelez/Desktop/GuideToPython3/techniques/files/s... |
64c2d50ebe0d127df0170b3834507467c89340d0 | chrismvelez97/GuideToPython | /data_types/dictionaries.py | 1,541 | 4.90625 | 5 | # How to use dictionaries
'''
Dictionaries are special forms of containers that do NOT have indices. They
can start off empty and have values added later
Instead, they have key and value pairs. To access a value you use the key.
The keys must be strings, and the values can hold anything f... |
f837053b00cd472b1097c4f4e72e4e7b053e0100 | chrismvelez97/GuideToPython | /techniques/classes/default_modifying_attributes.py | 1,751 | 4.625 | 5 | # Default values and Modifying attributes
class Character():
"""
This class will model a character in a videogame
to show the different things we can do with classes.
"""
def __init__(self, name):
'''
You can see we have attributes we didn't require
in ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.