blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
ce12d0bff493879ce3a5b0be8d119b6f411abfba | jeckjeck/pythonkurs | /inlamning2.py | 1,718 | 3.625 | 4 | # Programmeringstek cklund
# 2017-06-06
# scriptet har en klass med metoder som läser in fyra meningar och skriver ut dem som en dikt
class Dikt: # Skapar klass då vi har flera metoder som är lik varann
def __init__(self):
"""Denna metod körs automatiskt när dikt... |
d7601439236de680d7be8dec537e5547e0bf27f0 | UniBus/Server | /data_management/modules/gtfs/server/citydb.py | 1,536 | 4.03125 | 4 | #! /usr/bin/python
## This module creates a mySQL database
#
# It take one parameter, as
#
# create_db $dbName
#
import csv
import MySQLdb
import sys
import string
import os
def create_db(dbhost, dbuser, dbpass, dbname):
print "Create a MySQL database."
try:
#create database if it doesn't exi... |
fe46ad7776361a6476373fa89db1c3633996a245 | uiandwe/TIL | /algorithm/LC/202.py | 582 | 3.53125 | 4 | # -*- coding: utf-8 -*-
import math
class Solution:
def isHappy(self, n: int) -> bool:
d = set()
while True:
n = self.cal(n)
if n in d:
return False
elif n == 1:
return True
d.add(n)
def cal(self, n):
ret ... |
8f3b82edf1184d92c1713399957fba7235a0b8cf | PawelGilecki/python | /list overlap.py | 296 | 3.5 | 4 | import random
c = random.sample(range(1, 100), 15)
d = random.sample(range(1, 100), 12)
print(c)
print(d)
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
new = []
for element in c:
if element in d:
new.append(element)
print(new) |
c981fcbbe86e834cde49392c5fb850d95d4495d9 | IrisNotSiri/sort-practise | /main.py | 2,094 | 4 | 4 | #bubble sort
def bubble_sort(nums):
if nums is None:
return None
for n in range(len(nums)-1):
for n in range(len(nums)-1):
if nums[n] > nums[n+1]:
nums[n], nums[n+1] = nums[n+1], nums[n]
return nums
def insertion_sort(nums):
if nums is None:
return None
for i ... |
d4a2b559824ee4acfd061604d24643653eb2f183 | hubert-cyber/ExamenEnPython | /AlgoritmoDeVacunacionCovid-19-HLT.py | 611 | 3.5625 | 4 | #Vacunacion contra el covid-19
#Datos de entrada
sexo='femenino'
sexo= 'masculino'
edad=int(input("Ingrese su edad → "))
sexo=(input("Ingrese su sexo → "))
#proceso
print()
if edad >= 70 :
vacunaS="Tipo C"
if sexo== 'masculino' :
print(vacunaS)
vacunaS="Tipo C"
if sexo== 'femenino':
... |
8995c9c420f3869841374b53f2b7397298f0f6f6 | a100kpm/daily_training | /problem 0191.py | 1,293 | 3.6875 | 4 | '''
Good morning! Here's your coding interview problem for today.
This problem was asked by Stripe.
Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
Intervals can "touch", such as [0, 1] and [1, 2], but they won't be considere... |
e04e437ec5cba5579097fa35f2ed1dbcff1812c3 | FerumFlex/python-pinterest | /pinterest/comment.py | 4,253 | 3.578125 | 4 | #!/usr/bin/env python
import json
class Comment(object):
""" A class representing a pin Comment structure used by the pinterest API
The pin Comment structure exposes the following properties:
comment.id
comment.text
comment.type
comment.created_at
"""
def __init__(self, **kw... |
0a124068690b1e9d56bc84b924e070fb1502e4a7 | mariaelizasa/aed | /ic/Pairs.py | 193 | 3.96875 | 4 | minimo, maximo = input("Digite dois números para definir o intervalo:").split()
for numero in range(int(minimo), int(maximo) + 1):
if numero % 2 == 0:
print("Numero par: ", numero) |
b8ddb7a54446b104570f4fbc75631004578595de | Grace-Ya-Wen/Finite-Differences | /functions_part2.py | 11,438 | 3.796875 | 4 | import numpy as np
import matplotlib.pyplot as plt
import math
class Boundary(object):
"""
Class that stores useful information on boundary or initial conditions for a PDE mesh.
Attributes:
condition (str): Type of boundary condition e.g. dirichlet, neumann, robin.
function (fu... |
ef6e06b9fcd35193ae568874d98094010bc9764e | BluePinetree/BasicDeepLearning | /Lab8/Stack.py | 239 | 3.53125 | 4 | import tensorflow as tf
with tf.Session():
x = [1, 4]
y = [2, 5]
z = [3, 6]
#Pack along first dim
print(tf.stack([x,y,z]).eval())
print(tf.stack([x,y,z], axis=-1).eval()) #-1은 제일 마지막 축을 잡는다
|
15f3360432a5f48e7edcdfa07834490236c067a6 | DataNewbie1997/TambahMundur | /TambahMundur.py | 1,518 | 3.53125 | 4 | def tambahMundur (x,y):
try:
print('Masukan angka 1:',x)
if x > 359999:
print('Invalid input!')
mundur = 0
while x > 0:
a = x%10 #INI UNTUK MENCARI DARI ANGKA PALING BELAKANG
mundur = (mundur*10) + a # INI H... |
ae05f3903d996612c7c286f044ffbcff012a837b | WilliamRitson/letter-positon-frequency | /letter_counting.py | 1,286 | 4.1875 | 4 | import csv
ALPHABET = 'abcdefghijklmnopqrstuvwxyz'
MAX_LETTER_POSITION = 12
A_VALUE = ord('a')
def is_letter_in_nth_position(word, letter, n):
return n < len(word) and word[n] == letter
def create_letter_table(word_list, max_letter_position=MAX_LETTER_POSITION):
"""
Uses a list of words to create a table... |
5825fa53978a56811f315e64b4f618307178e3b1 | 5l1v3r1/python-basic | /deleting dictionary items in python.py | 360 | 4.28125 | 4 | # we can delete an item of dictionary or entire dictionary using del keyword.
stu={
101:"rahul",
102:"raj",
103:"arpit"
}
print("before deletion:")
print(stu)
print(id(stu))
print()
del stu[102]
print("after delition:")
print(stu)
print(id(stu))
print()
del(stu)
print(stu) #this will g... |
c7755617042d24d5b8c90ba1e6a393997b4ecb11 | TahaKhan8899/Coding-Practice | /LeetCode/MaxHeap.py | 2,333 | 3.953125 | 4 | class MaxHeap:
def __init__(self, items=[]):
# we don't use index 0 in a heap for easier indexing
self.heap = [0]
for i in items:
self.heap.append(i)
self.floatUp(len(self.heap)-1)
# PUBLIC
# append to the end, then float it up to the top
def push(s... |
8ade764213e6d1b518feed2ba769c6184a0eda3c | nour20-meet/meetyl1201819 | /personal_project.py | 780 | 3.9375 | 4 | from turtle import *
import turtle
import random
import math
class Ball(Turtle):
def __init__(self,x,y,dx,dy,r,color):
Turtle.__init__(self)
self.shape("circle")
self.shapesize(r/10)
self.r = r
self.color(color)
self.penup()
self.dx = dx
self.dy = dy
self.goto(x,y)
def move (self, screen_widht, ... |
079000049517b1aca1d08785f4eeeca83dc5ddd0 | shelibenm/processingsheli | /lesson1_saturation.pyde | 731 | 3.96875 | 4 |
barWidth = 1
# TODO-Change The barWidth to 20
def setup():
#TODO- use the barWidht variable instead of the number 20
size(20 * 32, 360)
colorMode(HSB, width, height, 100)
noStroke()
def draw():
#TODO-replace the 1 in the WhichBar variable with the mouseX value
whichBar = 1 / ba... |
08eb277d93271bd3b55405d11718e6924f854356 | shiksagodess/ComputerLanguages | /CS3120/tuples.py | 410 | 4.28125 | 4 | #This program create tuples, lists and uses slice
#here we are creating tuples
a=("one","two","three")
b=("four","five","six","seven")
c=(1,2,3,4,5,6,7)
print(a)
print(len(a))
print(b)
print(len(b))
print(a+b)
#This shows slice
print(c[1:])
print(c[2:4])
list = list(b)
print(list)
print(list[-2])
print(list[:3])
li... |
8bde01781b912d9c7d3248259128b1912fa98d23 | noblejoy20/python-tutorial-college | /prelims-parttwo/zeller.py | 479 | 3.828125 | 4 | a=int(input("Enter the month of the year: "))
b=int(input("Enter the day of the month: "))
c=int(input("Enter the year of the century: "))
d=int(input("Enter the century: "))
if(a<=2):
c=c-1
a=a+10
w=(13*a-1)//5
x=c//4
y=d//4
z=w+x+y+b+c-2*d
r=z%7
if(r==0):
print "Sunday"
elif(r==1):
print "Monday"
elif... |
26379839fcce7249228ead3eba4fc01edbf7f400 | kenchose/Python | /Python/Python Fundamentals/Type List/type_list.py | 994 | 3.875 | 4 | def identitylist(lst):
newStr = ''
total = 0
for elem in lst:
if isinstance(elem, int) or isinstance(elem, float):
total += elem
elif isinstance(elem, str):
newStr += elem + ' '
if newStr and total:
print "The list you entered is of mixed type"
pri... |
cb958071f97d324d8b49791bea94cdb6062b8e22 | chengxxi/SWEA | /D2/4866.py | 2,037 | 3.921875 | 4 | # 4866. 괄호검사 [D2]
for test_case in range(1, int(input())+1):
brackets = input()
def check_bracket(string):
d = {')' : '(', '}' : '{', ']' : '['} # 괄호 쌍 딕셔너리
stack = [] # 빈 스택 생성
for i in range(len(string)): # 문자열 내에서 반복 수행
if string[i] in '({[': # 열린 괄호라면
st... |
e7414f7c98028ae161f82a38f4e43fd6f83aef79 | tuliba1996/Testonline_python | /challenge.py | 228 | 3.734375 | 4 |
# print out the integer numbers from 30 to 300
listofnumber = range(30,301)
for i in listofnumber:
if (i%7 == 0 and i%13 == 0 ):
print "a-z", i
else:
if (i%7 == 0):
print "abc", i
if (i%13 == 0):
print "xyz", i
|
aa073424dda40ac53ae13d964b769a2287245806 | ohadstatman/Data_portfolio | /first1.py | 280 | 3.546875 | 4 | import re
file = open("actual-data-1.txt")
lst=list()
for line in file:
if re.search("[0-9]+",line):
x = re.findall("[0-9]+",line)
lst.append(x)
numbers =[]
for l in lst:
for num in l:
numbers.append(int(num))
print(sum(numbers))
|
d50ef7a9522a97add9379b1beac5df74183df3f7 | thesauravs/NLP | /tokenize_TSS.py | 966 | 4.03125 | 4 | import re
#tokenize function creates a list of distinct words in corpus
#parameter for this function is the file path
#it also changes all words to lower case before creating the list
def tokenize(filename = 'test.txt'):
with open(filename, 'r') as file:
words = []
all_words = []
#Ex... |
9b0d49b425db42a74940f08611dc068bb3bbefe3 | udhayprakash/PythonMaterial | /python3/10_Modules/27_socket_programming/first.py | 602 | 3.5625 | 4 | #!/usr/bin/python
import socket
import sys
# creating a socket
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error as error:
print(f"Failed to create a socket. {repr(error)}")
sys.exit()
print("socket created")
host = "localhost"
port = 9999
try:
remote_ip = socket.gethos... |
18b5eda56753ca024aff52e6d78bf07cf28a3be3 | humachine/AlgoLearning | /leetcode/Done/282_ExpressionAddOperators.py | 2,796 | 3.953125 | 4 | #https://leetcode.com/problems/expression-add-operators/
''' Given a string that only contains digits 0-9 and a target, add any of the arithmetic operators (+-*) between digits so as to evaluate to the 'target'. Return all such possibilities.
Inp: "123", 6
Out: ["1+2+3", "1*2*3"]
Inp: '232', 8
Out: [... |
f5345f97d514149ea5deb0d8abe4bacf4ee7d7a7 | HoaiBach/LinearOEC | /ES.py | 6,638 | 3.84375 | 4 | '''
This is an efficient implementation of Evolutionary Strategy (ES).
Written by M.R.Bonyadi (rezabny@gmail.com)
'''
import sys
from random import normalvariate as random_normalvariate
import numpy as np
from random import normalvariate as random_normalvariate
from math import log
from AbstractEA import AbstractEA
... |
e14357b795e9aa4f42b70607ecd2cb124e52b0c4 | nickitaliano/matching-commonsense-twitter-sentiment-analysis | /source-code/parse-tweet/raw_to_plain.py | 1,996 | 3.703125 | 4 | # file name is slang.txt
data = open("slang.txt","r")
# file including all tweets
tweets = open("tweets.txt","r")
# output file with resultant plain text
output = open("plaintext.txt","w")
# making dictionary from slang.txt
dict = {}
for line in data:
try:
x = line.split(":")
dict[x[0]]=x[1].replace... |
68684f6face69c2dedd634f22bdaf3fc00ca1b8c | Alan-Flynn/Python-Labs | /prime.py | 474 | 3.90625 | 4 | # Name: Your Name
# Student ID: 012345678
# File: prime.py
############################################################################
# ask for a number
n = int(input("Please enter a positive integer: "))
i = 2
factorisable = False
while not factorisable and i <= n**0.5:
if(n % i) == 0:
... |
44f72d83ac09b4ba3673f72528061eed5e5b8f73 | m-attand/class-work | /ex5_1.py | 333 | 3.703125 | 4 | #ex5_1
score = []
while True:
try:
score = input('Enter a number: ')
if score.strip() == 'done':
break
elif float(score):
score.append(float(score))
else:
print('error')
except:
print('error')
if len(score) > 0:
print('total: %d, Count: %d, Average: %f' % (sum(score),
len(score),(sum(score/... |
f698b64e13bfa3920d11937ca12f54338eda48fe | sangam92/https---github.com-sangam92-data_structure | /queue.py | 566 | 4.09375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 21 11:41:51 2020
@author: sangam
"""
class Queue:
def __init__(self):
self.queue=[]
def insert(self,dataval):
self.queue.append(dataval)
def remove(self):
self.queue.pop(0)
qu = Qu... |
60638264f791d0971d7ff76a19f5c121606c7ac1 | wajid-shaikh/Python-Examples | /2 conditions and loops/for_loop_exapmle1.py | 223 | 3.984375 | 4 | # sum fromo 1 to 10
# 1 + 2 + 3 + ... + 10
# total = 0
# for i in range(1, 11):
# total = total + i
# print(total)
n = int(input("enter number = "))
total = 0
for i in range(1, n+1):
total = total + i
print(total) |
d70120c6f76d4874364560d55e39872877ee9242 | T882200/python_learning | /pythontutcs.py | 171,693 | 4.375 | 4 | #~~Learn to program 1
# Programming involves listing all the things that must happen to solve a problem
# When writing a program first determine step-by-step what needs to happen
# Then convert those steps into the language being Python in this situation
# Every language has the following
# 1. The ability to accept in... |
0c9d884be92fc5be09579b9b6863de610dacbed9 | saurabh190802/septocode | /Day 10/SaurabhSatapathy_day10.py | 664 | 3.71875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Sep 30 10:53:09 2021
@author: saurabh satapathy
"""
def check_string(s): #defining the function check
c=0
alphabet = "abcdefghijklmnopqrstuvwxyz"
for char in alphabet:
if char in s:
... |
2badb70ca36701549b24fdf84d14a0cb45a9317b | rimzimt/Hashing-2 | /18_longest_palindrome_set.py | 1,035 | 3.75 | 4 | # S30 Big N Problem #18 {Easy}
# Given a string consisting of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.
#This is case sensitive, for example "Aa" is not considered a palindrome here.
# Time Complexity : O(n) n= length of string
# Space Complexity ... |
0a7b343ad60867887813511935c5fbb174ef9d2b | mfalcirolli1/Python-Exercicios | /ex105.py | 701 | 3.796875 | 4 | # Analisando e gerando Dicionários
def analise(*n, sit=False):
"""
-> Analisar notas de vários alunos
:param n: Notas
:param sit: Situação geral dos alunos
:return: Dicionários com várias informações
"""
dic = {}
dic['total'] = len(n)
dic['maior'] = max(n)
dic['menor'] = min(n)... |
32e4e71745daebd102617145cb0c49200d5cf9e7 | DennisWanjeri/alx-higher_level_programming | /0x07-python-test_driven_development/4-print_square.py | 463 | 4.40625 | 4 | #!/usr/bin/python3
"""Print square"""
def print_square(size):
"""prints a square with character '#'"""
if type(size) is not int:
raise TypeError("size must be an integer")
elif (size < 0) is True:
raise ValueError("size must be >= 0")
elif type(size) is float and (size < 0) is True:
... |
4877e4cd7aced1842078ffabf1decc0ba16dfd21 | arpitbhl/spoken-english-to-written-english | /spokenEng2WrittenEng/convertor.py | 4,189 | 3.875 | 4 | # Helper Functions
# Function checkCommas: checks if word has comma at front or at last or at both if true then return front,word and last
def checkCommas(word):
start = ""
last = ""
if(len(word) > 1):
if word[-1] == ',' or word[-1] == '.':
last = word[-1]
word = word[:-1]
... |
b01acf242b0e4967aa93f384fb70207c49e138dc | ironboxer/leetcode | /python/9.py | 1,141 | 3.859375 | 4 | """
https://leetcode-cn.com/problems/palindrome-number/
9. 回文数
判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。
示例 1:
输入: 121
输出: true
示例 2:
输入: -121
输出: false
解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。
示例 3:
输入: 10
输出: false
解释: 从右向左读, 为 01 。因此它不是一个回文数。
进阶:
你能不将整数转为字符串来解决这个问题吗?
"""
class Solution:
def isPal... |
c3e32db548468917f51cc13c4d36e1b7438a6fce | rishika028/nq_ga | /nq_ga.py | 8,475 | 3.953125 | 4 | #!/usr/bin/env python3
"""Solving the n-Queens problem using genetic algorithms."""
import datetime
import math
import random
import sys
import time
class Queen:
def __init__(self, row, col):
self.row = row
self.col = col
def safe(self, other):
if other.row == self.row and other.... |
f18acb55efa2f8c2846161cbad98eacbd51cb2a4 | ReeceNich/Python-School | /181010 Image Editor/181010 Photo Editor.py | 4,186 | 3.90625 | 4 | from Image_Library import *
menu_list = {
1: "Rotate 90 clockwise.",
2: "Rotate 90 anti-clockwise.",
3: "Custom rotation.",
4: "Print a histogram.",
5: "Quit"
}
def menu(options):
print("--== Welcome to the Image Manipulator 3000! ==--")
... |
96eab88f7b126f6a7e7a8dd0122206060627a186 | lim1017/Python | /functions.py | 1,911 | 4.53125 | 5 | def prints_hello_world():
print('Hello world from Python')
prints_hello_world()
def prints_something(something):
return something + ' from Python'
print(prints_something("passed in to python function"))
# If you pass wrong number of arguments like two or three arguments to this function then Python will thr... |
cc1d8e5a6be6b3b185433e5e6a8021726032a3d2 | Roc-J/python-3.5 | /python3实验/d_1.py | 2,285 | 4.09375 | 4 | #3-4.py
#本练习要求:定义一个类,完成指定功能。
class Student: #定义一个学生类
def __init__(self,name,num,chn,math,eng,phy,chem,bio):
#定义构造函数
self.name=name
self.number=num
self.chn=chn
self.math=math
self.eng=eng
self.phy=phy
self.chem=chem
self.bio=bio
#计算平均分... |
dee59e3dc215cffe0011872e34e751aa93cd3ae1 | manoranjanmishra/Code | /MY_CODE/prime.py | 18,560 | 4.34375 | 4 | #computing a prime number findprime(). This function computes the n-th prime number, n is an argument of the function.
#And a function isprime() , which checks if a number is prime. Added another pair of functions which generate the n-th prime number, and prime factor finds out the (smallest)prime factors of a number b... |
796373948c0df9894307e91d845da13db3ee2201 | shaon-data/Multivariate_Linear_Regression_scratch | /MVLR.py | 16,845 | 3.75 | 4 | # -*- -*-
"""
Author: Shaon Majumder
This is multivariate linear regression implementation from scratch
"""
import matplotlib.pyplot as plt
import numpy
## Statistical Function
def list_multiplication(dm1,dm2):
if length(dm1) == length(dm2):
return [b*c for b,c in zip(dm1,dm2)]
elif length(dm1) == 1 or length(dm2) ... |
28e9063c22c1c5bf38b35d26de2eabbb1903876a | nivedita81/LeetCode | /reorder_linked_list.py | 2,145 | 4.1875 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, val):
self.val = val
self.next = None
class Solution:
def __init__(self):
self.head = None
self.next = None
def pushList(self, new_data):
new_node = ListNode(new_data)
new_node.next = s... |
15ddc8f902d022aee22747c3d27e0b957865c826 | DamManc/workbook | /chapter_4/es96.py | 460 | 4 | 4 | # Exercise 96: Does a String Represent an Integer?
def is_integer(a):
new_int = a.strip()
if ((a[0] == '+' or a[0] == '-') and a[1:].isdigit()) or a.isdigit():
return True
else:
return False
def main():
int = input('Enter a integer: ')
if is_integer(int):
print('Your inpu... |
b694e256a9a57e99bbe352dfd034c0c383500a0b | SnehaAS-12/Day-14 | /day14.py | 3,679 | 4.53125 | 5 | #Design a simple calculator app with try and except for all use cases
def calculate():
try:
def add(num1, num2):
return num1 + num2
def subtract(num1, num2):
return num1 - num2
def multiply(num1, num2):
return num1 * num2
def divide(num1, num2... |
860bf2201a2a6c027246817615d39f23680bca37 | SaitoTsutomu/leetcode | /codes_/0706_Design_HashMap.py | 339 | 3.578125 | 4 | # %% [706. Design HashMap](https://leetcode.com/problems/design-hashmap/)
class MyHashMap(dict):
def put(self, key: int, value: int) -> None:
self[key] = value
def get(self, key: int) -> int:
return dict.get(self, key, -1)
def remove(self, key: int) -> None:
if key in self:
... |
c249f55355a3d83bfc2020c93d33af3cbe229e28 | x-jeff/Python_Code_Demo | /Demo2/Demo.py | 575 | 3.625 | 4 | a=[1,2,3,4,5,6,7,8]
for i in a :
print(i)
for i in a :
if i % 2 == 0 :
print(i)
for i in a:
print(i)
print("end")
for i in a:
print(i)
print("end")
b=15
if b==12:
print("b=12")
elif b<12:
print("b<12")
elif b>12 and b<20:
print("12<b<20")
else :
print("b>=20")
def addNum(a,b... |
b4fdb7c3f5a45aab78753d04dd6ecade9eb260f1 | diegothuran/neural | /test-XOR.py | 769 | 3.5 | 4 | """
Obs: Este script é baseado na versão do livro http://neuralnetworksanddeeplearning.com/, com a devida autorização do autor.
Código de teste para diferentes configurações de redes neurais.
Adaptado para o Python 3.6
Uso no shell:
python test.py
Parâmetros de rede:
2º param é con... |
b53574cc3fb4984ff5610e76aea3eca122cd3cc0 | siverka/codewars | /ValidateCreditCardNumber/validate_credit_card_number.py | 1,497 | 4.375 | 4 | """
https://www.codewars.com/kata/validate-credit-card-number
In this Kata, you will implement The Luhn Algorithm [https://en.wikipedia.org/wiki/Luhn_algorithm],
which is used to help validate credit card numbers.
Given a positive integer of up to 16 digits, return true if it is a valid credit card number, and false if... |
271d4bd9e90ea83b897afbc00c16a7c78f2c12f9 | williamfu24/CS372-AI- | /Project4/project4.py | 11,683 | 4 | 4 | #William Fu
#AI Project 4
#
#NOTES:
#Takeing more then pile is just taking all
#pile1 = 1 as opposed to your example where pile1 = 0
import random
def main():
random.seed()
print("pile1 = 1 not pile1 = 0 | pile2 = 2 not pile2 = 1 | pile3 = 3 not pile3 = 2\n")
print("How many in pile 1?")... |
704e2153c5bd51201388c971da0c063a9f9c6bdf | youhavethewrong/google-code-jam | /python/africa-2010/credit.py | 852 | 3.703125 | 4 | """
"""
import sys
def check_pair(tot, index, iteml):
for i in range(len(iteml)):
#print "Checking if %s + %s = %s" % (item, i, tot)
if (index != i and int(iteml[index]) + int(iteml[i]) == int(tot)):
return i
return -1
def find_match(credit, itemc, iteml):
for i in range(ite... |
c6ce40a0f8d135ebbe4b043eb5880c21e2474c52 | iamanshika/Faulty-machine-Data-Analysis | /Exports/Faulty Machine Maintenance.py | 6,235 | 3.765625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sb
# ## Data Exploration
# In[2]:
#importing the csv file in dataframe
df = pd.read_csv("maintenance_data.csv")
df
# In[3]:
df.head()
# In[4]:
#Understanding data domai... |
bf1968378635ebc25250c3d2032c67f25bbf5999 | ParkerCS/ch00-variables-VladoVladVlaVlV | /ch00_problem_set_1.py | 4,399 | 3.890625 | 4 | #SECTION 1 - MATH OPERATORS AND VARIABLES (20PTS TOTAL)
import math
#PROBLEM 1 (From Math Class to Code - 2pts)
# Print the answer to the math question:
# 3(60x^2 + 3x/9) + 2x - 4/3(x) - sqrt(x)
# where x = 12.83
x = 12.83
your_answer = 3*(60*x*x+(3*x/9))+2*x-((4/3)*x)-math.sqrt(x)
print(your_answer, "")
#LEE - use p... |
b683c9897e4e056f63642d6558bb197030d6f15f | BalawalSultan/Mario-Mini-Game | /player.py | 2,005 | 3.671875 | 4 | class Player:
def __init__(self):
self.max_health = 15
self.health = self.max_health
self.attack_power = 2
self.defense = 1
self.health_potion_ammount = 3
self.health_potion_power = 5
self.x = 0
self.y = 0
# increases the players stat... |
7003167d2036b1d79093b16ee0d9a6ac288d993a | C109156209/midterm | /25.py | 247 | 3.78125 | 4 | while True:
s=input("檢測的字串(end結束):")
if(s=="end"):
print("檢測結束")
break
s=list(s)
c=input("檢測的單一字元:")
print("字元%s出現的次數為:%s" %(c,str(s.count(c))))
|
9d976ac0721bd261907fafaba93414d1ee023ac7 | sijapu17/Advent-of-Code | /2021/2021-22.py | 12,135 | 3.5625 | 4 | #Advent of Code 2021 Day 22
import re
f = open('C:/Users/Simon/OneDrive/Home Stuff/Python/Advent of Code/2021/2021-22.txt')
contents = f.read()
inp = contents.splitlines()
class Cuboid():
def __init__(self,x0,x1,y0,y1,z0,z1):
self.x0=min(x0,x1)
self.x1=max(x0,x1)
self.y0=min(y0,y1)
... |
3d074d9899f0af54a5f8786f2d6a38d5fbe6b0f0 | ethunk/python_challenges | /ex4.py | 561 | 3.71875 | 4 | cars = 100
space_in_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capactiy = cars_driven*space_in_car
average_passenger_per_car = passengers/cars_driven
print ("There are,", cars, "cars available.")
print ("There are only", drivers, "drivers available")
print ("T... |
72e08ca09ec3eb848d1cf7ab9042c8f8c8cf36ab | namnamgit/pythonProjects | /fibonacci.py | 114 | 3.609375 | 4 | #sequência de fibonacci
a, b, c = 0, 1, 0
while a < 100:
print(a, end=', ')
c = a
a = a + b
b = c
input()
|
3d28ca7d0a8e5b6b5872a4155700439be7090d93 | Sundarmax/assignment | /workspace/test.py | 836 | 3.8125 | 4 |
def create_dict():
a = [1,2,3]
b = [4,5,6]
c = {}
i = 0
while i < len(a) and i < len(b):
c[a[i]] = b[i]
i+=1
print("dict",c)
def remove_duplicates():
a = [1,2,3,4,1,2]
temp = []
for item in a:
if item not in temp:
temp.append(item)
#print("u... |
4a1f845b0e129be3a66b5a029854f0134647161c | SergioKronemberg/CursoBlueMod1 | /aula9/ex2.py | 81 | 3.734375 | 4 | n = input("digite um numero positivo:")
print("o numero tem", len(n), "digitos")
|
f8f8f016b1c5e9ce71b416ca0acb157aa4612695 | matsmartens/coma-hex | /hex/PlayerController.py | 1,517 | 3.59375 | 4 | from random import *
class PlayerController:
def __init__(self):
self._currentPlayer = 1
self._currentPlayerType = "human"
self._playerIdentity = 0
self.mode = "human"
# generate random player number
def chooseFirst(self):
se... |
058018bfad650c880a4d38df359580bdd12a6bf8 | przemo1694/wd | /zad12.py | 239 | 3.859375 | 4 | for y in range(1,11,1):
for x in range(1,11,1):
if(y*x)>= 10:
print (y*x , " ",end='')
elif(y*x)== 100:
print (y*x , " ",end='')
else:
print (y*x , " ",end='')
print("") |
ec5509918dc172b9a4e3cd0350f82ac52679d15b | udaypandey/BubblyCode | /Python/RevereNumber.py | 240 | 3.96875 | 4 | # Read a number from the keyboard
# Print reverse number
# For eg for 1234567, 7654321
num = int(input("Enter a number: "))
sum = 0
while num > 0:
remain = num % 10
sum = sum * 10 + remain
num = num // 10
print(sum) |
33869fa1bb72093a4a7154a10fde8c7543632b67 | Ahn-seongjun/How-to-Python | /multi for.py | 178 | 3.765625 | 4 |
for y in range(3):
for x in range(5):
print(x,end='')
print()
a=0
for i in range(3):
for j in range(4):
a+=1
print(a, end="\t")
print() |
67915c237f3b6632cb53c70ae92c040056b83dd0 | Sourabh-Kishore-Sharma/Megahack-DualSpecs | /visualize.py | 5,343 | 3.5 | 4 | #!/usr/bin/env python3
import pandas as pd
import matplotlib.pyplot as plt
from pandasql import sqldf
sql=lambda q: sqldf(q,globals())
import re
from PIL import Image
import os
from PyPDF2 import PdfFileReader, PdfFileWriter
bank = input("Enter Bank: ").lower()
df = pd.read_csv(str(bank)+".csv")
c = input("Would you... |
691ab566c15b9f6e58c16e90d4f884acb235ad45 | albertisfu/devz-community | /linked-list/linked-list.py | 3,214 | 4.1875 | 4 | # Alberto Islas
# Linked List and remove duplicates of a linked list
#Node Class
class Node:
def __init__(self, data):
self.data = data
self.next_node = None
#LinkedList Class
class LinkedList:
def __init__(self):
self.head = None
#append new elements to linked list method
... |
f2e70f0c150d1b47a33317b2df430b5aaa752da3 | i150251/Python-tkinter-GUI-basic-example | /main.py | 15,352 | 3.546875 | 4 | import tkinter as tk
from tkinter import *
from tkinter import messagebox
from matplotlib import pylab
from pylab import plot, show, xlabel, ylabel
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
from collections import defaultdict
from pprint import pprint
... |
d9efba93e5ae91967d45061d4a281af3fea3e0ee | cpita/TicTacToeAI | /core/policies.py | 6,060 | 3.515625 | 4 | import numpy as np
import random
from core.models import NeuralNetwork
class Policy:
def __init__(self, env):
"""Initialize Policy by saving the environment as an instance variable and assigning it a turn"""
self.environment = env
self.turn = None
self.model = None
def sampl... |
7c940724f574a955fe8d85b60d7a84e7c4b45a74 | ramyasutraye/Guvi_Python | /set3/21.py | 175 | 3.953125 | 4 | n=int(input("Enter the n value:"))
a=int(input("Enter the a value:"))
d=int(input("Enter the d value:"))
sum = 0
for i in range(0,n):
sum+= a
a+= d
i = i + 1
print(sum)
|
81daa8cb68d4a32340825345c86d011fee09b239 | hyuhyu2001/Python_oldBoy | /src/Day001/variable.py | 1,975 | 3.640625 | 4 | #-*- coding: UTF-8 -*-
#变量variable与常量constant
PAI = 3.1415926
x=2
y=3
z=x+2
print id(x)
x=5
print x+y
print 'z:',z
print id(z)
print 'x:',x
print id(x)
#运算 优先级(先乘除,再加减)
print 1+1*3/2
print 3/2 #只能等于1,如果想运算准确,需要把3改为浮点数3.0
print 1+1*3.0/2
print (1+1)*3.0/2
print (1+1)*3/2
print 2**32 #求多少次方
print 9.... |
3c5b6c7f8dfb18069c0c9dc4542270a047110d0d | MrHamdulay/csc3-capstone | /examples/data/Assignment_6/shrdan007/question4.py | 1,110 | 3.65625 | 4 | # histogram output of marks
# Danielle Sher
from collections import Counter
marks = input("Enter a space-separated list of marks:\n")
marklist = marks.split()
symbol_list = []
for i in marklist:
if int(i) < 50:
symbol_list.append('F')
elif 50 <= int(i) < 60:
symbol_list.append('3')
elif 6... |
8939eb5fbec2b210d7f7a4bde004f8fc5ba12a6c | singto4/Building-a-recommender-system | /Program.py | 5,220 | 4.03125 | 4 | #Dataframe manipulation library.
import pandas as pd
#Reading The Data:
movies_data = 'movies.csv'
#Setting max-row display option to 20 rows.
pd.set_option('display.max_rows', 20)
#Defining additional NaN identifiers.
missing_values = ['na','--','?','-','None','none','non']
#Then we read the data into ... |
4b473d85c85f8398a6fe1ddf9467a0b9e9da954a | burman05/Square-Collector | /main.py | 3,030 | 3.921875 | 4 | import pygame
# Keyboard Constants
from pygame.locals import *
# Import Coin
from getcoin import Coin
# Create Screen
pygame.display.init()
# Set Dimensions of the display
# Get "Surface Object" to Draw on
screen = pygame.display.set_mode((800, 600))
# Pygame works based on these Surface Objects
# Rendered sprite... |
7ef470027cc0c7e9a7f9001b020346793cb606ba | captainmoha/MITx-6.00.1x | /Week 4/exceptions.py | 250 | 3.734375 | 4 | def divide(x, y):
try:
result = x / y
except ZeroDivisionError,e:
print "Division by zero! " + str(e)
except TypeError:
divide(int(x), int(y))
else:
print "result is " + str(result)
finally:
print "Excuting finally clause" |
4ecf0f0372429ba70ca2e16c5961c353eb47ad75 | hikoyoshi/hello_python | /example_3.py | 367 | 3.953125 | 4 | #!-*- coding:utf-8 -*-
print "算算看你有沒有過重"
w = input("請輸入體重:\n")
h = input("請輸入身高(cm):\n")
bmi = w /((h/100.0)**2)
print "你的bmi是",bmi
if bmi<18.5:
print ("過輕")
elif bmi>=18.5 and bmi <24:
print ("正常體重")
elif bmi>24 and bmi <27:
print ("有點過重")
else:
print ("小胖該減肥了......") |
2fac602b7f7cda44ac5446f422095c77e57e0f01 | hejackson/46-simple-python | /simple.py | 16,379 | 3.59375 | 4 | #!/usr/local/bin/python3
import re
import functools
import os
import time
import random
import requests
import itertools
import sys
import bs4
def max_new(a, b):
if a > b:
return a
elif b > a:
return b
else:
return a
def max_of_three(a, b, c):
"""
Either a, b or c is max... |
f9bf7663c3321f1d6e774b96c99b219f081bdade | wanggalex/leetcode | /LinkedList/141_LinkedListCycle.py | 790 | 3.765625 | 4 | # coding: utf8
"""
题目链接: https://leetcode.com/problems/linked-list-cycle/description.
题目描述:
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
"""
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x)... |
f95f8f312f9f606854955b9dd7ab94640e7574c6 | mcbunkus/scripts | /sym | 3,595 | 4.375 | 4 | #!/usr/bin/env python3
"""
sym v0.1
A small utility for integrating or differentiating functions. sym uses 'operators'
to decide what to do with an expression. For example:
sym 't => 2t' will integrate '2 * t'
sym 't -> 2t' will differentiate '2 * t'
The arrows in the expression are the operators. The... |
0860c50def3055383f6f1443979a85b632a17f53 | sean578/advent_of_code | /2020/day_22.py | 3,537 | 3.703125 | 4 | from collections import deque
import copy
import sys
def load_input(filename):
deck1, deck2 = [], []
on_deck_2 = False
for line in open(filename).readlines():
if len(line.strip()) == 0:
on_deck_2 = True
elif line.strip()[0] == 'P':
pass
else:
if ... |
b8d716b39ec8ebeffbc2bde487b28b7087d4f793 | DanMayhem/project_euler | /003.py | 560 | 3.734375 | 4 | #!python
"""
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
"""
class PrimeFactors():
def __init__(self, x):
self.x = x
self.pfp = 1
def __iter__(self):
return self
def __next__(self):
y = self.x / self.pfp
if y == 1:
raise StopIteratio... |
51e8275f23404b234cd369541a4a20b07c3a9c25 | moxiaoyu007/only_path_in_a_DAG | /Monlypath.py | 4,385 | 3.515625 | 4 | from collections import defaultdict
from heapq import *
import sys
import numpy
from numpy import *
def dijkstra_raw(edges, from_node, to_node):
# edges : ( from_node, to_node, weight of links (j,i))
g = defaultdict(list) #build a dict whose values are lists as a default value.
for l,r,c in edges... |
dc618dd665ad06dc8e97ec003b3c2d7b8f5f28a1 | brunozupp/TreinamentoPython | /exercicios/exercicio075.py | 512 | 4.0625 | 4 | if __name__ == '__main__':
tupla = ()
for i in range(0,4):
valor = int(input("Digite um número inteiro = "))
tupla += (valor,)
# A)
print(f"Apareceu o número 9 um total de {tupla.count(9)} vezes")
# B)
print(f"O número 3 foi digitado inicialmente na posição {tupla.index(3)}"... |
46dc064a1e708ccda5e29c3e8ad7e13d25236de4 | ConorODonovan/online-courses | /Udemy/Python/Data Structures and Algorithms/LinkedList/class_SingleLinkedList.py | 8,876 | 3.96875 | 4 | class SingleLinkedList:
def __init__(self):
self.start = None
def display_list(self):
if self.start is None:
print("List is empty")
return
else:
print("List is: ")
p = self.start
while p is not None:
... |
811c339cca06d7413cb70f755c8bcbe676579227 | hayabalasmeh/data-structures-and-algorithms. | /data_structures_algorth/challenge_linked_list_insertion/linked_list_insertion.py | 3,300 | 3.96875 | 4 | # Building the class
# class Node:
# def __init__(self,value = ''):
# self.value = value
# self.next = None
# def __str__(self):
# return str(self.value)
# class LinkedListInsertion:
# def __init__(self):
# self.head = None
# def append(self,value):
# ... |
77722a2b2a66358bc2a2284a8ba0e8cb209d3c79 | Yang-Jianlin/python-learn | /python数据结构与算法/sixth_chapter/P-6.34.py | 775 | 3.765625 | 4 | from sixth_chapter.stack import ArrayStack
def comp(num1, num2, e):
if e == '+':
return num1 + num2
if e == '-':
return num1 - num2
if e == '*':
return num1 * num2
if e == '/':
return num1 / num2
# 后缀表达式已经将计算的优先顺序排好,
# 只需要将后缀表达式的数字逐个入栈,直到遇到符号,
# 将前栈顶两个元素运算放回栈顶即可
def c... |
eebbc5dd0eed26afeb039df5dbfd474fb2df66c7 | curiosaurus/CTL | /Assignment 2/adivbytwo.py | 210 | 3.828125 | 4 | st=input("Enter the String of As And Bs with no. of As divisible by 2 : ")
counta=sum(map(lambda x : 1 if 'a' in x else 0, st))
if (counta%2==0):
print("Valid String")
else:
print("Invalid String") |
b6faaebf5e26709b93edc84ff87231eb8388771b | jinaur/codeup | /1901.py | 104 | 3.53125 | 4 | N = int(input())
def myfunc(n) :
print(n)
if n == N :
return
myfunc(n-1)
myfunc(1) |
55deb2bc11f2ed6161f2f3ec58e542096081d8c1 | NathanialNewman/ProjectEuler | /problems/1-9/9.py | 952 | 4.21875 | 4 | # Author: Nate Newman
# Source: Project Euler Problem 9
# Title: Special Pythagorean Triplet
# Description: There exists exactly 1 Pythagorean triplet for which
# a + b + c = 1000
# Find the product a*b*c
import time
# Determines if set of 3 values form a Pythagorean Triple
def pythagTriplet(a, b, c):
tri... |
e8757510f01e318dba95862d835874c69e97286d | Jiezhi/myleetcode | /src/11-ContainerWithMostWater.py | 1,828 | 3.875 | 4 | #!/usr/bin/env python
"""
https://leetcode.com/problems/container-with-most-water/
https://leetcode.com/explore/interview/card/top-interview-questions-hard/116/array-and-strings/830/
Created on 2018-12-13
Updated at 2022/01/04
@author: 'Jiezhi.G@gmail.com'
Reference: https://leetcode.com/problems/container-with-mos... |
604526bdbb537df949e8bfac65ed59cd7c263041 | codingstudy-pushup/python | /top/Sort_Searching/MeetingRoom2.py | 1,363 | 3.515625 | 4 | import heapq
from typing import List
class Solution:
def solve_1(self, intervals):
intervals.sort(key=lambda x: x[0])
heap = []
for i in intervals:
if heap and heap[0] <= i[0]:
# pop, push
heapq.heapreplace(heap, i[1])
else:
... |
7f96569b515fc1a70a68a2caa626e3f0811a3a9b | monique-tukaj/curso-em-video-py | /Exercises/ex050_soma_pares.py | 343 | 3.921875 | 4 | '''Desenvolva um programa que leia seis numeros inteiros e mostre a soma apenas daqueles que forem pares.
Se o valor digitado for impar , desconsidere-o. '''
s = 0
for a in range(1, 7):
num = int(input('Digite o {} numero inteiro: '.format(a)))
if num % 2 == 0:
s += num
print('O somatorio dos numeros p... |
0b572774c376a7c215b7024501110c45747c3589 | Anton-Naumov/Programming-101-with-Python | /week10/Money_In_The_Bank/client_test.py | 2,358 | 3.671875 | 4 | import unittest
from client import Client
from exceptions import InvalidPassword
class ClientTests(unittest.TestCase):
def setUp(self):
self.test_client = Client(1, "Ivo", 200000.00,
'Bitcoin mining makes me rich', "ivo@abv.bg")
def test_client_id(self):
se... |
c814f25b53bea705dc854d37b9fbd7f156bd4190 | othienoJoe/Weekly-Blog | /tests/test_article.py | 861 | 3.5 | 4 | import unittest
from app.models import Articles
class ArticlesTest(unittest.TestCase):
def setUp(self):
self.new_article = Articles('CNN',
'A West Virginia city is taking a Tesla patrol car for a test drive',
'Emma Raducanu defeats Leylah Fernandez in all-teen US Open final',
... |
26119cb51ff5ea445c75344e9812935be35776b5 | verdastelo/wgc | /gglPy/minutes.py | 132 | 3.609375 | 4 |
minutes = 42
seconds = 42
seconds_in_a_minute = 60
total_seconds = (minutes * seconds_in_a_minute) + seconds
print(total_seconds)
|
3c515bbc6f41270aefd40b85f24c2aa8e153c9c9 | OlliePoole/FYP | /Python/Assignment-1/CreditCardProblem.py | 2,091 | 3.875 | 4 | '''
Created on 16 Oct 2012
@author: Ollie Poole
'''
def getValidInput():
num = str(input("Enter the eight digit credit card number: "))
while len(num) != 8:
num = str(input("Incorrect input, please try again: "))
return num
#This function returns valid input only and will keep asking the user for... |
cbbf316aa63fdc9825c50185fd345a053cc9010e | Sunshine-Queen/Test | /day17/私有属性.py | 806 | 3.84375 | 4 | class People(object):
def __init__(self, name):
self.__name = name
def getName(self):
return self.__name
def setName(self, newName):
if len(newName) >= 5:
self.__name = newName
else:
print("error:名字长度需要大于或者等于5")
xiaoming = People("dongGe")
xiaomin... |
faf09587c4362ec77b55ceb8a41feed7016d20d0 | chipjacks/presidents-and-assholes | /common.py | 8,125 | 3.5625 | 4 | """Deck, Player, and Table classes used by client and server to play Warlords
and Scumbags card game.
"""
from random import shuffle
import logging
# Constants
HOST = 'localhost'
PORT = 36716
TABLESIZE = 7
LOBBYSIZE = 35
def setup_logging(to_file=False):
FORMAT = '%(filename)s: %(message)s'
# To log to file,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.