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 |
|---|---|---|---|---|---|---|
ecb6437c2be58f3711c8a6a2da3b0090aacb3918 | Abdullahtahir2022/AI-project-1 | /Final_Game_Code_Arsalan/new.py | 7,418 | 3.734375 | 4 | # This is our main file
import arcade
SPRITE_SNAIL = 0.114
SPRITE_SCALING_COIN = .25
COIN_COUNT = 50
# Set how many rows and columns we will have
ROW_COUNT = 10
COLUMN_COUNT = 10
# This sets the WIDTH and HEIGHT of each grid location
WIDTH = 60
HEIGHT = 60
# This sets the margin between each cell
# and on the edges o... |
ef1e48a71bbe88e75427c832a53c90e11891b96e | Tuppr/School-Stuff | /lab4/lab4_ungraded.py | 907 | 4.03125 | 4 | # Lab 4 UNGRADED exercises
# These exercises are for practice only
import math
def evenNumbers(x):
for i in range(x+1):
if i%2==0:
print (i)
def factorial(f):
x= f!
return
def randNumbers(r):
#ADD CODE HERE (you don't have to return anything)
return
#############... |
98003205be48b6e188fb3da15ebaa68b4cfaf0ab | Airo833/11HOME | /hm11.py | 5,978 | 3.640625 | 4 | from random import randint
class Cards:
def __init__(self, name, count_name):
self.name = name
self.count_name = count_name
self.result = []
self.finish = 0
self.count = 0
def creat_card(self):
for x in range(3):
n = 0
a1 = randint(0, 2)
... |
89a00a3d4866f6f84fc6e2ea4846a38dc4732f67 | WeiweiVivianWang/AMLHW2 | /preprocessing_rent.py | 6,127 | 3.578125 | 4 | #!/usr/bin/env python
"""preprocessing_rent.py
1) Fetch Data from URL
2) Filter Rows where y = NA
3) Split Data into X and y
4) Split Data into Training and Test Subsets
5) Recode Missing Values
6) Select Relevant Features
7) Impute Missing Values
8) Encode Categorical Features as One-Hot
9) Convert Data from Pandas D... |
e85c18c5e19bbf2580d60aaaa213a6c71a01564e | rubramriv73/daw1.2 | /prog/python/tareas/ejerciciosSecuenciales/ej18_iniciales.py | 796 | 3.78125 | 4 | '''
@author: Rubén Ramírez Rivera
18. Pedir el nombre y los dos apellidos de una persona y mostrar las iniciales.
'''
print('\n *** PROGRAMA QUE MUESTRA LAS INICIALES DEL USUARIO *** \n')
#Pedimos al usuario su nombre completo
name = input('Introduce tu nombre: ')
surname1 = input('Introduce tu primer apellido: '... |
787dc5e851fba1bf8819f643da671ec4b0b06462 | rubramriv73/daw1.2 | /prog/python/tareas/ejerciciosSecuenciales/ej16_coches.py | 1,518 | 4.25 | 4 | '''
@author: Rubén Ramírez Rivera
16. Dos vehículos viajan a diferentes velocidades (v1 y v2)
y están distanciados por una distancia d. El que está detrás
viaja a una velocidad mayor. Se pide hacer un algoritmo para
ingresar la distancia entre los dos vehículos (km) y sus
respectivas velocidades (km/h) y con esto... |
71aaf25131020ba822111659bb2594904b4f8e63 | rubramriv73/daw1.2 | /prog/python/tareas/ejerciciosSecuenciales/ej15_intercambio.py | 888 | 4.28125 | 4 | '''
@author: Rubén Ramírez Rivera
15. Dadas dos variables numéricas A y B, que el usuario
debe teclear, se pide realizar un algoritmo que intercambie
los valores de ambas variables y muestre cuanto valen al
final las dos variables.
'''
print('\n *** PROGRAMA QUE INTERCAMBIA EL VALOR DE 2 VARIABLES *** \n')
#Ped... |
06229198275e4f2fc588cae0d73eda90f29da10e | borisnorm/leetcode-1 | /algorithms/121.Best_Time_to_Buy_and_Sell_Stock/Best_Time_to_Buy_and_Sell_Stock.py | 819 | 3.734375 | 4 | class Solution:
# @param prices, a list of integer
# @return an integer
def maxProfit(self, prices):
if not prices:
return 0
buy_price, profit = prices[0], 0
for price in prices:
buy_price = min(buy_price, price)
profit = max(profit, price - buy_pr... |
ff12eb44ce367d5a77b2653b26cf14b3e7dffe94 | mouha003/Election_Analysis | /PyPoll.py | 3,465 | 4.0625 | 4 | #The data we need to retrieve.
#1. The total number of votes cast
#2. A complete list of candidates who received votes
#3. The percentage of votes each candidate won
#4. The total number of votes each candidate won
#5. The winner of the election based on popular vote.
# Open the data file.
# Write down the names of a... |
718ebb2daf0753bcaeeef1bfc6c226f320000859 | zenvin/ImpraticalPythonProjects | /chapter_1/pig_latin_ch1.py | 926 | 4.125 | 4 | ## This program will take a word and turn it into pig latin.
import sys
import random
##get input
VOWELS = 'aeiouy'
while True:
word = input("Type a word and get its pig Latin translation: ")
if word[0] in VOWELS:
pig_Latin = word + 'way'
else:
pig_Latin = word[1:] + word[0] + 'ay'
p... |
c7a770695af754727b36fa81fcf71d867201becf | Soundaryachinnu/python_script | /moduletest.py | 478 | 3.609375 | 4 | import hello
# hello.print_func("test");
arg1 = raw_input('Enter the first number :');
arg2 = raw_input('Enter the second number :');
# v1 = hello.mathfunc(arg1);
# v2 = hello.mathfunc(arg2);
# v1.funcadd(float(arg2));
# v1.funcsub(float(arg2));
# v1.funcmultiply(float(arg2));
# v1.funcdivide(float(arg2));
v1 = hello... |
d436073bd316bd56c8c9958785e0bb18476944a7 | Soundaryachinnu/python_script | /classobj.py | 1,360 | 4.125 | 4 | #!/usr/bin/python
class Parent: # define parent class
parentAttr = 100
def __init__(self):
print "Calling parent constructor"
def parentMethod(self):
print 'Calling parent method'
def setAttr(self, attr):
Parent.parentAttr = attr
def getAttr(self):
print "Parent attribu... |
5590709b6ea4e6339c8f37664d889441944944bb | richarddevilla/catch_up_three | /recursion.py | 2,190 | 4.0625 | 4 | import sys
def recursive_min(nested_list):
"""
the function takes a list of integers or another list of integers
it then check the list and return the smallest integer
:param nested_list:
:return:
"""
low_number = 99
for item in nested_list:
if not isinstance(item, list):
... |
fb4cbbe90200adc17bf7386e4b3e6ff2695a16f2 | shikhasingh1797/Files | /data.py | 375 | 3.703125 | 4 | my_file=open("data.txt","r")
file1=open("delhi.txt","w")
file2=open("shimla.txt","w")
file3=open("other.txt","w")
for data in my_file:
if "delhi" in data:
file1.write(data)
elif "shimla"in data:
file2.write(data)
else:
file3.write(data)
file1.close()
file2.close()
file3.close()
file1... |
e8a1cedb5d6e9c70ab379ff6905a72ca8b35f58e | ZMLin2020/auto | /PO-master/Chapter5/5-subTest.py | 442 | 3.53125 | 4 | # coding:utf-8
import unittest
class NumbersTest(unittest.TestCase):
def test_even(self):
"""
使用subTest上下文管理器,区分细小的变化
取模运算,返回除法的余数,但是参数是0到5的整数,没必要单独写方法
"""
for i in range(0, 5):
with self.subTest(i=i):
self.assertEqual(i % 2, 0)
if __name__ == '__m... |
034a46b66a4138ad20dce39310baf00594d8e2b7 | PierreOhl/parity_games_solving | /trees.py | 8,801 | 4.09375 | 4 | from copy import deepcopy
class node_in_infinite_tree:
'''
node_in_infinite_tree:
- height_of_tree = height of the tree -1 (number of parameters)
- depth = depth_of_node (root has depth 0, corresponds to [])
- degree of tree
- value is a list of size <= height
-> now... |
dbc88a77ad72449f8c67706e76fd95601f776696 | kaiforward/GalacticIndex | /language.py | 2,233 | 3.921875 | 4 | import random
def get_language():
# IMPORTS MY LANGUAGE TEXT FILE WHICH CONTAINS A LIST OF FICTIONAL "VERBS"
lines = []
with open('language1.txt') as language:
for line in language:
lines.append(line.strip())
return lines
def get_language2():
# IMPORTS MY LANGUAGE TEXT FILE W... |
ab1cb540c545147f7d6c89c797276b1054869312 | IsaacBarden/IntroToPython | /7-Loops-CarGame.py | 518 | 4.0625 | 4 | car_started = False
while True:
command = input("> ").lower()
if command == "start":
if car_started:
print("Car is already started!")
else:
print("Car is started.")
car_started = True
elif command == "stop":
if car_started:
print("Car s... |
4a94a88a0853481aa124551c1ee968763bf6d9c9 | IsaacBarden/IntroToPython | /11-Functions.py | 838 | 3.90625 | 4 | #The ol' FizzBuzz
def FizzBuzz(number):
return_val = ""
if number % 3 == 0:
return_val += "Fizz"
if number % 5 == 0:
return_val += "Buzz"
if len(return_val) == 0:
return_val += str(number)
return return_val
end_num = 1
for i in range(end_num):
print(FizzBuzz(i+1))
prin... |
395d767a6f95ef5919a965c38f26953d1d120bdc | akudaibergen/labsOfwebka | /week8/3i.py | 92 | 3.75 | 4 | a=int(input("Number is "))
b=0
for i in range (1,a+1):
if a%i==0:
b=b+1
print(b) |
0035a2f4e83a584d6191d2a6b1aa7a337c2573c2 | akudaibergen/labsOfwebka | /week8/5e.py | 342 | 3.625 | 4 | ok=False
a=[]
n=(input("Number of array: "))
for i in range(int(n)):
a.append(int(input()))
for i in range(int(n)):
if i>0:
if a[i] > 0 and a[i - 1] > 0:
ok = True
break
elif a[i] < 0 and a[i - 1] < 0:
ok = True
break
if ok==True:
print("YES")
... |
8a05a58c5954c8db14c56eccb1fb30df76f3b4cf | akudaibergen/labsOfwebka | /week8/3m.py | 117 | 3.75 | 4 | a=int(input("Number is "))
d=0
for i in range (a):
b=int(input("Number i: "))
if b==0:
d=d+1
print(d) |
4bbbe0124e07e48dd096c482f968b1b3caf14e9d | BallboyDev/programming-by-language | /Python/stack.py | 520 | 3.734375 | 4 | num = int(input())
stack = []
for i in range(num):
order = input()
if(order.count("push")):
num = order.split()[1]
stack.append(num)
elif(order.count("pop")):
if(not len(stack)):
print(-1)
continue
print(stack.pop())
elif(order.count("size")):
print(len(stack))
... |
1a3a702f335289a3ad06552c28e4665953fee18d | BallboyDev/programming-by-language | /Baekjoon/Baekjoon2920.py | 154 | 3.640625 | 4 | strg = input().replace(" ", "")
if(strg == "12345678"):
print("ascending")
elif(strg == "87654321"):
print("descending")
else:
print("mixed")
|
82616c0b3f6924711b9dea9bbaae6d18bd88b4e3 | BallboyDev/programming-by-language | /Python/stack_bin.py | 439 | 3.640625 | 4 | """============================================
파일이름 : stack_bin.py
함수기능 : 스택을 활용한 10진수를 2진수로 변환 프로그램
최종수정 : 2016-11-29
copyright ⓒ 2016 S.W.Yang All Rights Reserved
============================================"""
def push(a):
stack.append(a)
stack = []
a = int(input())
while(a != 0):
push(a%2)
a = a // 2
st... |
6a03fcf64d68f403a064bcd65dba9d12591c05c1 | tejasai97/Data_Analysis | /Pandas/Series.py | 1,164 | 3.859375 | 4 |
# coding: utf-8
# In[2]:
import numpy as np
import pandas as pd
# ### Creating a Series
#
# You can convert a list,numpy array, or dictionary to a Series:
# In[3]:
labels = ['a','b','c']
my_list = [10,20,30]
arr = np.array([10,20,30])
d = {'a':10,'b':20,'c':30}
# ** Using Lists**
# In[4]:
pd.Series(data=m... |
2f62cc7a94443a01fb6b3c5c060ac7bd78521c30 | Ersy/Dice-Roll | /Dice.py | 1,021 | 3.96875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 6 23:59:36 2016
@author: Ers
"""
import random
def rollDice(n):
return (random.randint(1, 6*n))
correct = 0
running = True
while running:
try:
diceNo = int(input("Enter the number of dice "))
rounds = int(input("Enter... |
fc28439aed5eed4a43d0bf2a109274e902e0e2fa | Eran-Levy-git/backtracking | /ex11_map_coloring.py | 2,616 | 3.921875 | 4 | # ex11
# ex11_map_coloring.py
# eran_levi
from ex11_backtrack import general_backtracking
COLORS = ['red', 'blue', 'green', 'magenta', 'yellow', 'cyan']
FILE_PATH = ''
def read_adj_file(adjacency_file):
"""this function loads a text file of sudoku game into a dictionary.
:param adjacency_file: Path to text f... |
f60b812a06af2b1a20d6f8c609c5c06492fe3f8c | Arsal-Sheikh/Dungeon-Escape---CS-30-Final | /gamemap.py | 2,604 | 4.25 | 4 | class Dungeon:
def __init__(self, name, riddle, answer):
"""Creates a dungeon
Args:
name (string): The name of the dungeon
riddle (string): The riddle to solve the dungeon
answer (string): The answer to the riddle
"""
self.name = name
self... |
d1d43f9a38f4bc70f1ab1a23f531c9248733a5e1 | jay7591/Fluent-Python-1 | /Part5-Metaprogramming/property_factory.py | 3,886 | 4.15625 | 4 | def quantity(storage_name):
"""The quantity property factory
the storage_name argument determines where the data for each property is
stored; for weight, the storage name is 'weight'
"""
def qty_getter(instance):
"""
- the first arg could be named ``self``, but that would be strang... |
eb90b47a66234b4410b6d544b33c269a99243391 | jay7591/Fluent-Python-1 | /Part2-Functions-as-Objects/decorator_closure.py | 3,407 | 4.375 | 4 | """
Variable scope rules: a variable assigned in the body of a function is local.
When compiling the body of f, Python decides that vairable b is local, because
it is assigned within the function. Later, when f(3) is called, the body of
f fetches and prints the value of the local variable a, but when tryi... |
335f306864654771c5dbd4f69a43adc3bdc3c147 | jay7591/Fluent-Python-1 | /Part4-Control-Flow/iterator_sentence.py | 5,355 | 4.375 | 4 | import re
import reprlib
import random
"""
Why sequences are iterable: Whenever the interpreter needs to iterate over an object x,
it automatically calls iter(x). iter
1. checks whether the object implements __iter__, and calls that to obtain an iterator
2. if __iter__ is not defined, but __getitem__ is, Python creat... |
dc02f6f44141ec9700d75855afad9a5bbd4f13ad | HuuBaa/leetcode | /300. Longest Increasing Subsequence.py | 1,328 | 3.5625 | 4 | # Given an unsorted array of integers, find the length of longest increasing subsequence.
# For example,
# Given [10, 9, 2, 5, 3, 7, 101, 18],
# The longest increasing subsequence is [2, 3, 7, 101], therefore the length is 4. Note that there may be more than one LIS combination, it is only necessary for you to return... |
2130f2bebae84e2c5a3956c7fcdb91f74025867c | jw18362961997/primePath | /primePath.py | 4,648 | 3.796875 | 4 |
# 返回的是以该点出发的所有simple path
def find_onePaths(graph, start, path):
paths = []
if start not in graph:
paths.append(path)
return paths
path = path + [start]
'''路径数组'''
# 如果有邻接点
if len(graph[start]):
for node in graph[start]:
# 点不在路径中(避免回路),则路径中加入该点,还要对该点邻接点... |
112406526d19647ad8790706d71ea29f39a45bdd | Murilo-MC/pythonProject | /praticos/rpower.py | 242 | 3.671875 | 4 | def rpower(a, n):
'retorna a á potência n'
global counter
if n == 0:
return 1
tmp = rpower(a, n//2)
if n % 2 == 0:
counter +=1
return tmp*tmp
else:
counter +=2
return a*tmp*tmp |
74d66a530ae4b9ca0c86d78503edc4e193d25fd9 | Murilo-MC/pythonProject | /section_5/pep8.py | 1,363 | 4.09375 | 4 | """
PEP - Python Enchancement Poposal
São propostas de melhorias para a linguagem Python
The Zen of Python
import this
A idéia da PEP8 é escrevermos códigos de formas Pythonica.
[1] Utilize Camel Case para nomes de section_5:
class Calculadora / class CalculadoraCientifica
[2] Utilize nome em minúsculo separa... |
9b7ac506374c56a4d91e5ef278455e19e425f967 | xmj-7/summer-learning | /day_3numpy.py | 5,264 | 3.75 | 4 | import numpy as np
from matplotlib import pyplot as plt
import math as m
#最小最大值
a = np.array([[3,7,5],[8,4,3],[2,4,9]])
print("源输出:")
print(a)
print(np.amin(a))#直接输出最小值
print(np.amin(a,1))#1对应的是每一行的最小值
print(np.amin(a,0))#0是对应的列
print(np.amax(a))#直接输出最大值
print(np.amax(a,1))#1对应的是每一行的最大值
print(np.amax(a,... |
f55eacdf1969164609e82245855307f8afe7b99e | ju9501/iot-kite | /Python/while_1.py | 238 | 3.921875 | 4 | # list 선언
list_a =[1,2,1,2,2,2,2,2,2,3,4,5,6,3,3]
value = 2
print('-----value=2를 하나씩 지움-----')
while value in list_a:
list_a.remove(value)
print(list_a)
print('-----value=2를 모두 지움-----')
print(list_a) |
6030e8ed6694c33baf1b4a8851323c5adcfa9c79 | ju9501/iot-kite | /Python/func_2.py | 381 | 4.5 | 4 | # list 선언
list_a = [1, 2, 3, 4, 5]
list_b = list(range(1,6))
print(list_a)
print(list_b)
# 리스트 역순으로 뒤집는다.
list_reversed = reversed(list_a)
list_reversed = list(list_reversed)
# list 출력
print('list_a :',list_a)
print('list(list_reversed) :',list_reversed)
# for 문장을 이용해서 역순 참조
for i in reversed(list_a):
print(i)... |
bb8283688346fdf60c63940790ada79dd87b4647 | JonSWRI/RepurchaserApp | /src/stats/statistics/average.py | 380 | 3.546875 | 4 | from stats.statistics.statistic import Statistic
import numpy as np
'''
example of implementation of simple statistic - The standard average
'''
class Average(Statistic):
def grafter(self, items):
i = [x[1] for x in items]
mean = np.mean(i)
err = np.sqrt(np.var(i))
return (mean, err... |
93759542b0c225e8f34c311080845e34ae97f8ed | a11to1n3/OCPCO | /Ant.py | 6,480 | 3.515625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 26 19:48:49 2020
@author: duypham
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import math
def Ant_ALO(N,Max_iter,lb,ub,dim,fobj):
antlion_position = Ant_initialization(N,dim,ub,lb)
ant_position = Ant_initializatio... |
e1a9a6a5baa584bdad70d91f5ee914624177b816 | nazhot/Connect-4 | /Connect_4.py | 2,874 | 3.765625 | 4 | import os
import time
board = []
player = "O"
aiCheck = ["","","","","","",""]
for x in range(6):
board.append([" "]*7)
###################################Functions###################################
def printBoard(board):
os.system("cls")
print(" 1 2 3 4 5 6 7 ")
for r... |
b6a9354de7ee7cae6bc73e8be09098835f117719 | llorenzo-dev/Thonny | /alexandre.py | 594 | 4.0625 | 4 | lista = {
'corrdor1':["geleia", "leite", "ovo", "alface"],
'corrdor2':["picles", "chantili", "requeijao", "tomate"],
'corrdor3':["molho de tomate", "iogurte", "carne", "banana"],
}
lista = (["geleia", "leite", "ovo", "alface"],
["picles", "chantili", "requeijao", "tomate"],
["molho de tomate", "... |
cc50c6bbb858933c816c173d4c23b3f1e6a903e4 | llorenzo-dev/Thonny | /lista teste.py | 551 | 4.03125 | 4 | lista = [[1, 2, 3],[10, 20, 30],[100, 200, 300] ]
'''lista.append(1000)
lista.insert(1,40)
É possivel adcionar o 40 na lista da dezena?'''
unidade = lista[0]
unidade1 = unidade[0]
unidade2 = unidade[1]
unidade3 = unidade[2]
dezena1 = lista[1][0]
dezena2 = lista[1][1]
dezena3 = lista[1][2]
centena1 = lista[2][... |
ee76ecccf323d0929aed0e307a24e6ee3492c1e4 | llorenzo-dev/Thonny | /DSA-Python-Cap02-Exercicios 10.py | 825 | 3.859375 | 4 | # Exercício 10 - Considere a string abaixo. Imprima na tela apenas os caracteres da posição 1 a 18.
#frase = 'Cientista de Dados é o profissional mais sexy do século XXI'
frase = "Cientista de Dados é o profissional mais sexy do século XXI"
print(frase[0:18])
#COMO CONTAR QUANTAS LETRAS TEM NA FRASE?
'''Obs: Antes ... |
1a3dea1adc952a89e01e77e0ec497c8c145cf22a | sumitgouthaman/AlgorithmPlayground | /DP/PathsInGrid.py | 1,515 | 3.8125 | 4 | import unittest
from collections import deque
def paths_in_grid(grid_size):
"""Returns no of possible paths in a square grid starting from top right
corner to the bottom left corner (while moing in only left and bottom
direction)
Args:
grid_size (int): The size of grid
Returns:
... |
d9736075107c9ca1f288291a0109789e658d00c1 | 1ekrem/python | /CrashCourse/chapter10/tiy103.py | 1,962 | 4.375 | 4 | '''
10-3. Guest: Write a program that prompts the user for their name. When they
respond, write their name to a file called guest.txt.
10-4. Guest Book: Write a while loop that prompts users for their name. When
they enter their name, print a greeting to the screen and add a line recording
their visit in a file called... |
9a6a512989a683662cb0947cc5b7ad2d3ba903e7 | 1ekrem/python | /CrashCourse/chapter8/tiy86.py | 2,533 | 4.75 | 5 | """
8-6. City Names: Write a function called city_country() that takes in the name
of a city and its country. The function should return a string formatted like this:
"Santiago, Chile"
Call your function with at least three city-country pairs, and print the value
that’s returned.
"""
def city_country(cityName, country... |
98c6fcb0c32751420b55d45af86d092a20d578bf | 1ekrem/python | /CrashCourse/chapter8/tiy81.py | 350 | 3.796875 | 4 | def diplay_message():
message = "In this chapter we are learning about how the functions are used in programming"
print(message)
diplay_message()
def favorite_book(title):
print("My favorite book is {}".format(title))
favorite_book(input())
bookList = ['Kral', 'Dostum', 'Yanlizlik']
for name in boo... |
38c12c9f57e2b6cbd60deef4e291d44ca722cf44 | 1ekrem/python | /CrashCourse/chapter8/returnVal.py | 1,121 | 4.09375 | 4 | def get_formatted(firstname, lastname):
"""Return a full name, neatly formatted."""
fullName = firstname + ' ' + lastname
return fullName.title()
#musician = get_formatted("ekrem", "ersayin")
#print(musician)
#
#print("------------ NEW LINE ------------")
def get_formatted_middle(firstname, lastname, midd... |
38f7a26fd5f45b93c1d1ed6669bd362a55e2f641 | 1ekrem/python | /CrashCourse/chapter8/tiy89.py | 1,670 | 4.46875 | 4 | """8-9. Magicians: Make a list of magician’s names. Pass the list to a function
called show_magicians(), which prints the name of each magician in the list."""
def show_magicians(magicians):
for name in magicians:
print(name)
names = ['Ekrem', 'Daria', 'Pupsik']
show_magicians(names)
"""8-10. ... |
fc59b15949d5f525ad1c27cedb1fda37ef81736b | ninanee/Truth_Evaluation | /passign2.py | 9,142 | 3.609375 | 4 | # define operator
#For AND and OR. parsing until the first connnective symbol is reached.
#and the two variables around it can be identified
def forAndOrOperator(expression):
if ('AND' in expression and 'OR' in expression):
connectiveindex = min(expression.index('AND'), expression.index('OR'))
elif ('A... |
d29d5fc23ee9d057e7c940eef64b30f930a6a55d | mancbg/Intelligent-system-Goal-based-agent | /source_code/node.py | 960 | 3.640625 | 4 | class Node:
__slots__ = "state", "parent", "action", "path_cost", "depth"
def __init__(self, state, parent=None, action=None, path_cost=1):
self.state = state
self.parent = parent
self.action = action
self.path_cost = path_cost
if parent:
self.path_cost += pa... |
bff331140f62de5e2d90843dd1b643cda728be1a | guilhermeleobas/cftool | /test/scode/621D.py | 1,500 | 3.671875 | 4 | import math;
from decimal import Decimal
def expbysquaring(x, n):
if n < 0:
return expbysquaring(1 / x, -n);
elif n == 0:
return 1;
elif n == 1:
return x;
elif n%2 == 0:
return expbysquaring(x*x, n/2);
else:
return x * expbysquaring(x*x, (n-1) / 2);
def cal... |
40e6260d8df077b8ee65a4e37359605b8e6b0cbf | VenkateswarluSadam/CarParkingSlots | /Booking_slots_for _car_parking.py | 3,818 | 3.625 | 4 |
A=["FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE"]
B=["FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE"]
C=["FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE"]
D=["FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE","FREE"]
lanes=[A,B,C,D]
l... |
67993ba0812d04ddebf78dde67a37a07821cdf76 | mtourj/Intro-Python-II | /src/player.py | 1,410 | 3.65625 | 4 | # Write a class to hold player information, e.g. what room they are in
# currently.
class Player:
def __init__(self, current_room):
self.current_room = current_room
self.inventory = []
def travel(self, direction):
'''Move player in a direction toward a room.
Returns True on... |
38c62c50034df71577114671f04ebcfc631c75d6 | SeanHarveyOfiangga/Assignment-2 | /Name_Age_Address.py | 209 | 4 | 4 | Name = (input("Enter your name here: "))
Age = (input("Enter your age here: "))
Address = (input("Enter your address here: "))
print(f"Hi, my name is {Name}. I am {Age} years old and I live in {Address}.") |
82a2cc67fe0cd868980bc52aa824c0aaf6915ab5 | kornivuse/fit1d | /fit1d/fit1d.py | 2,964 | 3.546875 | 4 | """
fit1d package is designed to provide an organized toolbox for different types of
1D fits that can be performed.
It is easy to add new fits and other functionalities
"""
from abc import ABC, abstractmethod
import numpy as np
from typing import List
from fit1d.model import Model
from fit1d.outlier import OutLier
c... |
1633fbafc12ed5568ad274cb32bbd2c4dce5d548 | Scott-Dupasquier/Hex-Visualizer | /Stone.py | 3,387 | 3.953125 | 4 | # Stone object for Hex, can be black, white or no colour
import pygame
from pygame.locals import *
class Stone:
def __init__(self, window, centerx, centery, colour, row, col):
self.window = window
# For indexing purposes
self.row = row
self.col = col
... |
3e76148525270936f8e00c4bc6882c8cbc428bc1 | lj72808up/ML_Handcraft | /preproccess/HandleDatasets.py | 4,191 | 3.65625 | 4 | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
def getDataset():
data = pd.read_csv("../../datasets/census.csv")
#print(data.shape)
# 将数据切分成特征和对应的标签
# income 列是我们需要的标签,记录一个人的年收入是否高于50K。 因此我们应该把他从数据中剥离出来,单独存放。
income_raw = data['income']
features_raw = data.drop('income',axis=1)... |
cd877447cf321c61a6acf6b7327a3b0794f772d6 | AlexisU32/retoPython | /punto_3.py | 592 | 3.9375 | 4 | # 3) Algoritmo que lea dos números y nos diga cual de ellos es mayor
# o bien si son iguales (recuerda usar la estructura condicional SI)
num1 = float(input('Ingrese el primer numero '))
num2 = float(input('Ingrese el segundo numero '))
if num1 > num2:
if num1 == num2:
print('Los dos numeros ingresados ... |
9596ad38b216aba440c138b7f14706454c14bee1 | jannickle/pythonProject | /Opg1.py | 1,569 | 4 | 4 |
templist = ['p', 'r', 'o', 'b', 'e']
# list with mixed data types
templist2 = [1, "Hello", 3.4]
# nested list
templist3 = ["mouse", [8, 4, 6], ['a']]
print("----------List------------")
print(templist[0])
print(templist[1:3])
print(templist3[1][2])
templist[0] = "a"
print(templist)
templist[1:4] = ["b","c","d"]
print... |
88c9676d770f7049496aa89275ca5c652362f21a | zhongxiangpku/python_gradproj | /codepkg/data_process/geoutil.py | 567 | 3.640625 | 4 | import math
# encoding: UTF-8
EARTH_RADIUS = 6378.137
def getPointDistance(lat1, lng1, lat2, lng2):
result = 0
radLat1 = radian(lat1)
radLat2 = radian(lat2)
a = radian(lat1) - radian(lat2)
b = radian(lng1) - radian(lng2)
result = 2*math.asin(math.sqrt(math.pow(math.sin(a / 2), 2) +
... |
e544781a7dfe5664907adb93cd6cfed430dacb0d | WangDooo/Effective-Python-Specific-Ways-to-Better | /Learning/Unit_2-函数/learn_2.py | 5,849 | 3.75 | 4 | import datetime
import time
#================================================================
# 15. 了解如何在闭包里使用外围作用域中的变量
#----------------------------------------------------------------
# numbers = [8,3,1,2,5,4,7,6]
# group = {2,3,7,5} # 这个要优先排列的
# def sort_priority(values, group):
# def helper(x):
# if x in group... |
d419e7ffa7631dd44cd4e86f3f60dbaaf26db140 | thaian207/WGUPS | /main.py | 1,799 | 3.984375 | 4 | # An Nguyen
# Student ID 000397742
from datetime import datetime
from truck import Truck
# For the entire program, the Big O is O(N^2) complexity.
# User Interface with menu. Big O is O(N) complexity.
class Main:
t = Truck()
t.loadtruck()
print('-' * 40)
print('**** WGUPS Delivery Serv... |
69425a26b666a0b409ec4904ea02d700adf05847 | inarchus/EOS_Does_Python | /Day_1/file_examples.py | 1,765 | 3.96875 | 4 |
def file_operations():
# if you run this, you'll have to redownload the file
# first_file = open('first_file.txt', 'wb')
# first_file.write()
# first_file = open('first_file.txt', 'w+')
first_file = open('first_file.txt', 'r+')
print(first_file.readlines())
first_file.close()
first_fi... |
1fffa512b4ea79dd6033667137efe71cb51c714d | inarchus/EOS_Does_Python | /P2_Hangman.py | 2,094 | 3.734375 | 4 | class HangmanGame:
VICTORY = 1
DEFEAT = 2
def __init__(self, answer):
self.answer = answer.lower()
self.bad_guesses = []
self.word_blanks = ['_' for _ in answer]
def finished(self):
if not any(c == '_' for c in self.word_blanks):
return self.VICTORY
... |
77c85081ce44692b8c9e62bb85030e048e945143 | trahec/interviewPractice | /hackerrankSubmissions/WeekOfCode31/day1_beautifulWord.py | 764 | 3.890625 | 4 | #!/bin/python3
"""
https://www.hackerrank.com/contests/w31/challenges/beautiful-word
"""
import sys
def isBeautiful(w):
w_list = list(w)
if(len(w_list) > 100):
raise ValueError('Input word is larger than 100 characters')
else:
vowelSet = {"a", "e", "i", "o", "u", "y"}
for index, ... |
8b816e4924d13dad093ea03f4967cae78eb494d5 | Lyonidas/python_practice | /Challenge-4.py | 1,759 | 4.1875 | 4 | # Preston Hudson 11/21/19 Challenge 4 Written in Python
#1. Write a function that takes a number as input and returns that number squared.
def f(x):
"""
returns x squared
:param x: int.
:return: int sum of x squared
"""
return x ** 2
z = f(4)
print(z)
#2. Create a function that accepts a str... |
ceb3a00d884b1ee19687364f03d1755e7932c43d | Lyonidas/python_practice | /Challenge-6.py | 1,652 | 4.1875 | 4 | # Preston Hudson 11/25/19 Challenge 6 Written in Python
#1. Print every character in the string "Camus".
author = "Camus"
print(author[0])
print(author[1])
print(author[2])
print(author[3])
print(author[4])
#2. Write a program that collects two strings from the user, inserts them into a string and prints a new strin... |
ff684538f7eda43491ec2450ba1bffd3ce8a8722 | Blasco-android/Curso-Python | /desafio39.py | 382 | 3.96875 | 4 | from datetime import date
ano_nasc = int(input('Digite o ano de nascimento: '))
idade = date.today().year - ano_nasc
if idade == 18:
print('Deve se alistar este ano')
elif idade < 18:
tempo = 18 - idade
print('faltam {} anos para se alistar'.format(tempo))
elif idade > 18:
tempo1 = idade - 18
pri... |
8c196bc23d47a2a1578d9ebfbb198a3b5fd06d96 | Blasco-android/Curso-Python | /desafio66.py | 199 | 3.953125 | 4 | count = sum = 0
while True:
num = int(input('Digite um numero [33-STOP]: '))
if num == 33:
break
sum += num
count += 1
print(f'Entered {count} number and the sum is {sum}.')
|
44674b99523701303bc606ebcf9544139b145f58 | Blasco-android/Curso-Python | /desafio42.py | 393 | 4.03125 | 4 | r1 = int(input('Digite a primera reta'))
r2 = int(input('Digite a segunda reta'))
r3 = int(input('Digite a terceira reta'))
if r1 < r2+r3 and r2 < r3+r1 and r3 < r2+r1:
print('forma trinanguo ', end='')
if r1 == r2 == r3:
print('Equilatero')
elif r1 != r2 != r3 != r1:
print('Escaleno')
... |
95ce8565755a00896c69a2e9c74a278aa4f7973d | Blasco-android/Curso-Python | /desafio63.py | 462 | 4.09375 | 4 | print('-'*20)
print('SEQUENCIA DE FIBONACCI')
print('-'*20)
n1,n2 = 0, 1
cont = 2
nterms = int(input('How many terms: '))
if nterms <= 0:
print('Please enter a positive integer!')
elif nterms == 1:
print('Sequence Fibonacci: ', end='')
print(n1)
else:
print('Seuence Fibonacci: ')
print(n1, ',', n2... |
6b202a652158b84e15293439c6d7e754ca56083d | Blasco-android/Curso-Python | /desafio75.py | 435 | 4 | 4 | num = (
int(input('Digite um valor: ')),
int(input('Digite um valor: ')),
int(input('Digite um valor: ')),
int(input('Digite um valor: '))
)
print(f'TUPLA = {num}')
print(f'O número 9 apreceu {num.count(9)} vezes')
if 3 in num:
print(f'O número 3 está na {num.index(3)+1}ª posição')
else:
print('O numero 3 não ... |
f2a123e4e59777a984edec31409a5ae543285aa1 | Blasco-android/Curso-Python | /desafio96.py | 421 | 3.984375 | 4 | def area(a, b):
"""
-> Calcula a area de um retangulo ou quadrado
:param a: comprimento
:param b: largura
:return: sem retorno
"""
x = a * b
print(f' A area de um terreno {a} X {b} é : {x}')
def titulo():
print('-'*20)
print(f'{"Controle de Terreno":^20}')
print('-'*20)
t... |
9cd05b9e27b20535a31ceca3db2987fd97a85ae0 | Blasco-android/Curso-Python | /desafio60.py | 562 | 4.125 | 4 | # Calcular o Fatorial
'''
#Utilizando modulo
from math import factorial
print('''
#[ 1 ] Calcular Fatorial
#[ 0 ] Fechar Programa
''')
abrir = int(input('Escolha uma Opcão: '))
while abrir != 0:
num = int(input('Digite um valor: '))
print('O fatorial de {} é {}.'.format(factorial(num)))
'''
num = int(input... |
53f05ee2893c7b8aef35c4ad5a5a808b390f8850 | Rawan199812/401-data-structure | /data_structure/data_structure/tree/tree.py | 7,871 | 4.03125 | 4 | from data_structure.data_structure.stacks_and_queues.stacks_and_queues import Queue, EmptyQueueException
# class Queue:
# def __init__(self):
# self.items = []
# def enqueue(self, item):
# self.items.insert(0, item)
# def dequeue(self):
# if not self.is_empty():
# retu... |
ab0a842d98a50f55a52eeb6c22a6736259db4d0c | Rawan199812/401-data-structure | /data_structure/data_structure/queue_with_stacks/queue_with_stacks.py | 1,376 | 3.953125 | 4 | from data_structure.data_structure.stacks_and_queues.stacks_and_queues import Stack, EmptyQueueException
class PseudoQueue:
def __init__(self):
self.fisrt_stack = Stack()
self.reverse_stack = Stack()
def enqueue(self, value):
self.fisrt_stack.push(value)
def dequeue(self):
... |
086037f3f218414f361b3d118ad1a57f05142c35 | TeChNiShU27/TeChNiShU27 | /RECTANGLE.py | 112 | 3.828125 | 4 | i=3
while (i>=0):
j=1
while j<=1:
print (5,end=' ')
j=j-1
print()
i=i-1
|
198ed738f6874e16027f88c67089311b70bef403 | TeChNiShU27/TeChNiShU27 | /String_Capitalize.py | 150 | 4.15625 | 4 | str1=input("Enter a string: ")
print("Original string: ",str1)
str2=""
x=str1.split()
for a in x:
str2+=a.capitalize()+" "
print(str2)
|
fb82ac18e472afc5f36058cf00940c0d1660830a | TeChNiShU27/TeChNiShU27 | /Variable_Triangle.py | 90 | 4.03125 | 4 | num=int(input("Enter a number: "))
for i in range(1,num-6):
print("a"*i)
|
76178534554fa030e42e9f7a2d23db151b282b09 | jcalahan/ilikepy | /004-functions.py | 311 | 4.15625 | 4 | # This module explores the definition and invocation of a Python function.
PI = 3.1459
def volume(h, r):
value = PI * h * (r * r)
return value
height = 42
radius = 2.0
vol = volume(height, radius)
print "Volume of a cylinder with height of %s and radius of %s is %s" \
% (height, radius, vol)
|
453a93aee72f7fa7d35ec3eadeb85b928fe22177 | utkarsh-srivastava/python-pil | /main.py | 506 | 3.59375 | 4 | from PIL import Image
import os
read_folder_path = 'read-images'
write_folder = 'write-images'
ratio = (200,100)
def shrink_images():
for dirpath, dirnames, filenames in os.walk(read_folder_path):
print(dirpath, dirnames, filenames)
for filename in filenames:
image = Image.open(os.path.join(os.getcwd... |
a2bcbd6e2f715802b8e48529160455c066a7dc49 | friedgreenrepos/python-geo-utils | /geoutils.py | 6,868 | 3.6875 | 4 | import csv
import xmltodict
import copy
from math import hypot
def rows2list(open_file):
"""Return a list of the input file's rows."""
points = []
with open_file as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
points.append((row[0], row[1], ... |
70ed4f013209eb9a64f9cbdfafc524b56a6c9a5b | rodrigobell/programming-practice | /Python/TODO-12-dasherize-number.py | 434 | 3.875 | 4 | def dasherize_number(num):
num_s = str(num)
result = ""
for i in range(0, len(num_s)):
if int(num_s[i]) % 2 == 1:
if i == 0:
result += num_s[i] + "-"
elif i == len(num_s)-1:
result += "-" + num_s[i]
else:
result += ... |
a85654513a0f992ee635e5f30b5f14c0c19eabd5 | AniPetrosyan/EpiSchoolAssignments | /Reverse.py | 224 | 3.859375 | 4 | def my_reverse(data_list):
length = len(data_list)
s = length
new_list = [None]*length
for item in data_list:
s = s - 1
new_list[s] = item
return new_list
print(my_reverse([1,2,3,4,5])) |
7dd3c250ab98150a9c651e3ba63eb71baf9d6d1b | Sabrout/cantal_cryptocurrency | /src/network/client.py | 4,149 | 3.75 | 4 | from threading import Thread
from src.network.writer import MessageWriter
from src.network.server import Server
import socket
import queue
class Client():
"""
This class represents a network client
"""
def __init__(self, queue_receive, queue_response,
list_server, list_thread, event_h... |
5d625dc76f0b086c8925e00c3ccc17fa8045218d | MissVyas/PythonCourse | /Day5/HighestScore.py | 265 | 3.703125 | 4 | scores = raw_input("Input a list of scores ").split()
for n in range(0, len(scores)):
scores[n] = int(scores[n])
len_score = len(scores)
highest_score = 0
for score in scores:
if score > highest_score:
highest_score = score
print highest_score
|
09ec1aa8b468a8afd8dc07d359643fb0cf69b0fa | MissVyas/PythonCourse | /Day2/Lifeinweeks.py | 237 | 3.8125 | 4 | age = raw_input("What is your current age?")
remainingage = 90-int(age)
years = 365 * remainingage
weeks = 52 * remainingage
months = 12 * remainingage
print("You have "+str(years)+" years, "+str(weeks)+" week and "+str(months)+" month") |
ed6573bed1867e5776534233e9f662b0fe208ea7 | MissVyas/PythonCourse | /Day4/BankerRoulette.py | 194 | 3.890625 | 4 | import random
string1 = raw_input("Enter the name of people seperated by comma and space")
list1 = string1.split(', ')
#choice = int(random.randint(0,len(list1)-1))
print random.choice(list1) |
742f8c0636834f774151be0d9741efff0048fd08 | MissVyas/PythonCourse | /Day2/TypeError.py | 204 | 3.890625 | 4 | num_char = len(raw_input("What is your name: "))
print(type(num_char))
print("Your name has "+str(num_char)+" characters.")
a=str(12)
print(type(a))
b=float(123)
print(type(b))
print(70+float("100.5")) |
4e74592c63bf0adcfa9e50d45faddb70cfa253b9 | elp2/advent_of_code_2020 | /2.part2.py | 885 | 3.59375 | 4 | from collections import defaultdict
def return_default():
return 0
REAL=open("2.txt").readlines()
SAMPLE=open("2.sample").readlines()
def parse_lines(lines):
def parse_line(line):
split = line.split(" ")
times = split[0]
tmin, tmax = times.split("-")
tmin = int(tmin)
t... |
ec44a182a44ed2b65ccdc98e40d7460622d14e3a | 2448845600/LeetCodeDayDayUp | /LeetCode题解/biweekly-contest-19/1-id5311.py | 352 | 3.734375 | 4 | class Solution:
def numberOfSteps(self, num: int) -> int:
count = 0
while num:
a, b = divmod(num, 2)
if b == 1:
num = num - 1
else:
num = a
count += 1
return count
if __name__ == '__main__':
s = Solution()
... |
45184fd13af214462f7a77053d355e44fa7a239c | sathulkiran/CS313E-A0 | /A5/OfficeSpace.py | 4,309 | 3.75 | 4 | # File: OfficeSpace.py
# Description:
# Student Name: Athul Srinivasaraghavan
# Student UT EID: as84444
# Partner Name: None
# Partner UT EID: None
# Course Name: CS 313E
# Unique Number:
# Date Created:
# Date Last Modified:
import sys
import math
# Input: a rectangle which is a tuple of 4 intege... |
a82a3bed53044fd58675c482259503dca99f3b47 | sathulkiran/CS313E-A0 | /Test1/Triangle.py | 2,689 | 4.03125 | 4 | # File: Triangle.py
# Description: A basic 2D Triangle class
# Student Name: Athul Srinivasaraghavan
# Student UT EID:
# Course Name: CS 313E
# Unique Number:
import sys
import math
TOL = 0.01
class Point (object):
# constructor
def __init__(self, x = 0, y = 0):
self.x = x
self.y = y
# get the di... |
21e5f6fbc6df9a7ee13076e50b4c07ff888c434d | aarushg22/ProjectEulerHackerrank | /problem22.py | 1,283 | 3.921875 | 4 | """
Made merge sort myself from scratch because wanted to practice and
see if i still remember the algorithm correctly. :)
"""
def merge(arr, l, m, r):
il, ir, ind=0,0,l
tmp1=[arr[i] for i in range(l,m+1)]
tmp2=[arr[i] for i in range(m+1,r+1)]
while(ind<=r):
if il==len(tmp1):
arr[ind... |
cf98347f3b1e8631b86022f03ac9556e7a1a72de | aarushg22/ProjectEulerHackerrank | /problem4.py | 1,178 | 3.515625 | 4 | #!/bin/python3
import sys
def check_palindrome(num):
rev_num=0
original = num
while(num>0):
rev_num = rev_num * 10 + (num%10)
num//=10
return original == rev_num
def bin_search(arr, num, min, max):
# print(arr[min],min,arr[max],max,num)
if num<arr[min]:
return -1
i... |
e4fa98b07c7d1bc7ad72ac893691391151ebd783 | perebaj/network-attacks | /src/WaxMan.py | 2,674 | 3.578125 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import igraph
import numpy as np
import matplotlib.pyplot as pyplot
import math
import sys
class SpatialNetworl():
"""
Spatial Network Generator
"""
RANDOM = np.random
def generate_Waxman(self, size_of_network, parameter_list):
"""
P... |
2b409cfeb923e07db625a46cf4a357cc627d5a20 | niranjan2822/Interview1 | /count Even and Odd numbers in a List.py | 1,827 | 4.53125 | 5 | # count Even and Odd numbers in a List
'''
Given a list of numbers, write a Python program to count Even and Odd numbers in a List.
Example:
Input: list1 = [2, 7, 5, 64, 14]
Output: Even = 3, odd = 2
Input: list2 = [12, 14, 95, 3]
Output: Even = 2, odd = 2
'''
# Example 1: count Even and Odd numbers from given li... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.