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 |
|---|---|---|---|---|---|---|
9e189d566aef8c8f900d3f8201505180da45bb69 | jordanbelinsky/ics4u-finalproject | /wip/game_of_life-merged.py | 25,288 | 3.515625 | 4 | # Import #
import pygame
import random
import pygame.midi
# Rules #
rules = '''
1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
2. Any live cell with two or three live neighbours lives on to the next generation.
3. Any live cell with more th... |
ebefd9d3d3d7139e0e40489bb4f3a022ee790c19 | vatasescu-predi-andrei/lab2-Python | /Lab 2 Task 2.3.py | 215 | 4.28125 | 4 | #task2.3
from math import sqrt
a=float(input("Enter the length of side a:"))
b=float(input("Enter the length of side b:"))
h= sqrt(a**2 + b**2)
newh=round(h, 2)
print("The length of the hypotenuse is", newh)
|
7216af7c0f6a00e10a8fe55d5c35e1ccdb5e90fb | MuthumariP/python | /m-1.py | 133 | 4.125 | 4 | x=int(input("enter the number"))
if(x>0):
print("positive number")
elif(x==0):
print("zero")
else:
print("nagative number")
|
45d6c05e65769e205350e81b2650f51f8a78b5df | scalpelHD/Study_python | /习题/习题4.5.py | 300 | 3.75 | 4 | foods=('potato','tomato','french fries','beef','pork')#元组
for food in foods:#遍历元组
print("delicious"+food+'!')
foods=('potato','tomato','fish','noodles','pork')#重新给元组赋值
for food in foods:
print("delicious"+food+'!')
foods[0]="ricea"#不能给元组中的元素赋值
|
8eea3adf0682985a99b7276a0cc720cbeec98d0b | scalpelHD/Study_python | /课堂/car.py | 1,239 | 4.125 | 4 | class Car():
"""一次模拟汽车的尝试"""
def __init__(self,make,model,year):
"""初始化描述汽车的属性"""
self.make=make
self.model=model
self.year=year
self.odometer_reading=0
def get_descriptive_name(self):
"""返回整洁的描述性信息"""
long_name=str(self.year)+' '+self.make+' '+self.... |
2e80e44088a353ace3a3f5352d325276ea244551 | scalpelHD/Study_python | /习题/city_function.py | 173 | 3.6875 | 4 | def city_country(city,country,population=''):
if population:
return city+','+country+'-'+'population:'+str(population)
else:
return city+','+country
|
c9e28a67d62c80c9cfe4204b12cf5c6e21e9a00d | scalpelHD/Study_python | /help/乘三四等数.py | 290 | 3.765625 | 4 | def func(a):
a = str(a)
s = 0
for c in a:
s += int(c)
return s
for x in range(100, 1001):
flag = True
for y in range(3, 8):
if func(y*x) != func(3*x):
flag = False
break
if flag:
print(x)
|
32b3140eb782c4acfc813ecddbe29134af99788a | scalpelHD/Study_python | /help/判断密码强度.py | 485 | 3.8125 | 4 | def judge(password):
degree = 0
for c in password:
if c.isdigit():
degree += 1
break
for c in password:
if c.isupper():
degree += 1
break
for c in password:
if c.islower():
degree += 1
break
... |
8e783872a469448ab00a7967eecfa8eb608a9106 | scalpelHD/Study_python | /课堂/6.4嵌套.py | 1,715 | 3.703125 | 4 | alien_0={'color':'green','points':5}
alien_1={'color':'yellow','points':10}
alien_2={'color':'red','pinots':15}
aliens=[alien_0,alien_1,alien_2]#在列表中嵌套字典
for alien in aliens:
print(alien)
aliens=[]
for alien_number in range(30):
new_alien={'color':'green','points':5,'speed':'slow'}
aliens.append(new_alien)
... |
1179a03075ab98c1e6727b067074bb3f67d4ba38 | scalpelHD/Study_python | /课堂/5 if 语句.py | 1,153 | 4.21875 | 4 | cars=['AUDI','Toyota','bmw','honda','beijing','jeep','beiJING']#if语句
for car in cars:
if car=='bmw':
print(car.upper())
else:
print(car.title())
if car.lower()=='audi' or car.upper()=='TOYOTA':#或
print(car.title())
if car.lower()=='beijing' and car!='beiJING':#与
print(car... |
18a8ab191a285b8ed49edd4df3d6c3dcc955b627 | TiagoSanti/uri-solutions | /Python/Estruturas e Bibliotecas/1068.py | 489 | 3.5 | 4 | while True:
try:
pilha = input()
correct = 1
par = 0
i = 0
while i < len(pilha) and correct:
if pilha[i] == '(':
par += 1
#print('1', i, par)
if pilha[i] == ')':
if par == 0:
correct = 0
#print('2', i, par)
else:
par -= 1
#print('3', i, par)
if i == len(pilha)-... |
8a90fba30c8f21215f15d9a41a3eb786ee2967a6 | TiagoSanti/uri-solutions | /Python/Iniciante/1002.py | 83 | 3.859375 | 4 | pi = 3.14159
radius = float(input())
A = pi*radius**2
print('A={:.4f}'.format(A))
|
8fe92181c5e810fde2bc844d782d2cff9b5ef8ab | TiagoSanti/uri-solutions | /Python/Iniciante/1165.py | 325 | 3.53125 | 4 | N = int(input())
for i in range(N):
X = int(input())
is_prime = 1
aux = 2
while is_prime == 1 and aux < X:
if X % aux == 0:
is_prime = 0
else:
aux += 1
if is_prime == 1:
print('{} eh primo'.format(X))
else:
print('{} nao eh primo'.format... |
65fb89fe22be2bb155911f303b3515aadb68603e | Alejandrozic/CS3642-SearchAlgorithms-BFS-UCS-AStar | /eight_puzzle_problem/priority_queue.py | 2,230 | 4.03125 | 4 | class Node:
def __init__(self, priority, puzzle_state):
self.priority = priority
self.puzzle_state = puzzle_state
def __repr__(self):
return f'({self.priority}, {self.puzzle_state})'
class PriorityQueue:
""" Minimum Priority Queue """
def __init__(self)... |
d127ec8a1cea73890822497cd79cbfc5f3632c8b | Aishwaryakotharu/GUVI | /pratice/loop/3atoz.py | 61 | 3.703125 | 4 | n=ord('a')
while(n<123):
print(chr(n))
n=n+1
|
cf0b39ebb3ffc35ff3f111a2e0a35d4fbd259a0d | Aishwaryakotharu/GUVI | /data structure/questack.py | 331 | 3.9375 | 4 | s1 = [];
s2 = [];
def eq(x):
s1.append(x)
def dq():
if (len(s2) == 0):
if (len(s1) == 0):
return 'Cannot dequeue because queue is empty'
while (len(s1) > 0):
p = s1.pop()
s2.append(p)
return s2.pop()
eq('a');
eq('b');
eq('c');
dq();
print(s1)... |
c0ead2f0baa178739688e58968451b23dbd039ce | Aishwaryakotharu/GUVI | /pratice/str/4.py | 106 | 3.515625 | 4 | n=input()
n=list(n)
s=0
for i in n:
s=s+ord(i)
if(s%8==0):
print("1")
else:
print("0") |
9e855549308c53a24b430e0922ca77443a8bb1d0 | Aishwaryakotharu/GUVI | /zenclass/DAY2/D2list.py | 225 | 3.65625 | 4 | l=list()
s=0
av=0
for i in range(0,4):
a=int(input("enter marks subject %d :",%(i)))
l.append(a)
s=s+a
print("the subject marks:",l)
print("the sum of all subjects:",s)
av=s/4
print("the average is:",av) |
21de7ad29e25a364cbf80ec0d430285a3d293a79 | Aishwaryakotharu/GUVI | /zenclass/D6string.py | 466 | 3.9375 | 4 | n=input()
#input().split()
"""if we give n=input().split()
wont work for guvi but
will work for g*u*v*i then give input().split(*)"""
#it will not work str obj doesnt support assignment
"""for i in range(0,len(n)):
n[i]=n[i].upper()
print(n)"""
#only char gets upper
"""for i in n:
... |
c2a5385c3389ce0fe92001508da43b6f01cadcf5 | Aishwaryakotharu/GUVI | /zenclass/D6strSTRIP.py | 219 | 4 | 4 | s="string***"
#strip
print(s.rstrip("*"))
print(s.lstrip("str"))
print(s.strip("***"))
print(s.strip("str"))
#replace
a=s.replace("***","")
print(a)
x="this***is***test"
print(s.replace("***"," ")) |
95dc7195c3c9daaf18cce38add9516341147d3f2 | Aishwaryakotharu/GUVI | /zenclass/DAY2/D2listoper.py | 376 | 3.859375 | 4 | l=[]
l.append(2)
l.append(3)
print(l)
x=l.copy()
print(type(x))
print(x)
l.clear()
print(l)
l=[2,2,3,4,'a']
print(l.count('a'))
x=(5,)
l.extend(x)
print(l)
print(l.index(5))
l.insert(5,'b')
print(l)
l.pop(1)
print(l)
l.insert(1,2)
l.remove(2)
print(l)
l.reverse(... |
850aae71b10da8b093eab1f6bb9f3ca9cca4ea75 | snishizawa/eps2lef | /eps2lef.py | 6,809 | 3.609375 | 4 | #!/bin/python3
# program which translate eps into lef
# usage
# python3 eps2lef.py -i input.eps -o output.lef
import argparse, re, os
import myObjects as mobj
def main():
parser = argparse.ArgumentParser(description='argument')
parser.add_argument('-i','--input', type=str, help='input eps')
parser.add_argument('-... |
1eb2fe2bb55172539afe01d6d66b1a7d6782bfa0 | justAminAhmad/PythonProjectPR215 | /main.py | 2,615 | 3.5625 | 4 | """
module principale du programme
"""
from tkinter import *
import os
def main():
# Les differentes fonctions de navigations du programme
def entrer():
root.destroy()
os.system("python gui/ajouter.py")
def afficher():
root.destroy()
os.system("python gui/afficher.py")
... |
c95b02e386a039b2bef1693759667cafc3a7bce6 | mandawilson/PyVCF | /vcf/utils.py | 1,016 | 3.9375 | 4 |
def walk_together(*readers):
""" Walk a set of readers and return lists of records from each
reader, with None if no record present. Caller must check the
inputs are sorted in the same way and use the same reference
otherwise behaviour is undefined.
"""
nexts = [reader.next() for ... |
c63b6506b3b7cad390374a69c04fbb1bdcb2ddca | csula-students/cs4660-fall-2017-GeorgeAria | /cs4660/search/searches.py | 6,010 | 4.03125 | 4 | """
Searches module defines all different search algorithms
"""
import Queue
import math
def bfs(graph, initial_node, dest_node):
"""
Breadth First Search
uses graph to do search from the initial_node to dest_node
returns a list of actions going from the initial node to dest_node
"""
q = Queue... |
478c659e40e506e24bc3c9b246aa0db3c85b0807 | NathanSchomer/Ecec301 | /wk2/person_test.py | 1,755 | 3.546875 | 4 | import person
if __name__ == '__main__':
usrInput = ''
people = []
promptHeader = '\n'+'_'*20
prompt1 = promptHeader+'\n1. Create Person\n2. Create Student\n3. Create Instructor\n\nSelect: '
prompt2 = '\nEdit:\n1. Major \n2. GPA\n\nSelect:'
prompt3 = '\nEdit:\n1. Salary\n\nSelect:'
#whil... |
eef3584574d8640b80cc9af31ec5b359855b354b | moshoulix/ZOJ | /1103.py | 2,136 | 3.59375 | 4 | # 三个棋子,邻接矩阵,棋子只能在其他两个棋子之间路径相同的颜色的路径上移动 BFS
class State:
def __init__(self, A, B, C, Result):
self.s = [A, B, C]
self.res = Result
self.same = True if A == B == C else False
def can_move(state, II, J): # 棋子II 可以移动到J
p = state.s[II]
lis = [0, 1, 2]
lis.remove(II)
return map... |
86f47e6ce622914493a87b26762f2fa47205a943 | moshoulix/ZOJ | /1007.py | 339 | 3.640625 | 4 | # 求和问题 没啥意思 https://blog.csdn.net/qust1508060414/article/details/50762415
for j in range(2001):
res = 0.0
temp = 0.0
num = j * 0.001
for i in range(1, 6000):
temp += 1 / (i * (i + 1) * (i + 2) * (i + num))
res += (1 - num) * ((2 - num) * temp + 0.25) + 1
print('%.3f %.12f' % (num, res... |
83f89520de7d5ced55e546f6614b89b50a14a88d | moshoulix/ZOJ | /1113.py | 217 | 3.859375 | 4 | # 计算e
print('n e')
print('- -----------')
print('0 1')
print('1 2')
print('2 2.5')
res = 2.5
factorial = 2
for i in range(3, 10):
factorial *= i
res += 1 / factorial
print('{} {:.9f}'.format(i, res))
|
4b4cc84a3a7aa5f50ac3bb763dfb341110aeccd3 | moshoulix/ZOJ | /1067.py | 790 | 3.578125 | 4 | # 前16行为点集,求输入与点集距离最近的点
def dist(a, b):
return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2 + (a[2] - b[2]) ** 2
points = []
for _ in range(16):
temp_line = input().split(' ')
points.append([int(temp_line[0]), int(temp_line[1]), int(temp_line[2])])
while 1:
temp_line = input().split(' ')
color = [int... |
7a9a8bbd6502a5d5dd9fc7f2427768bd704057bc | yadavpratik/python-programs | /Regex_programs.py | 7,749 | 4.375 | 4 | # what is regular Expression ?
# 1. The regular expressions can be defined as the sequence of characters
# which are used to search for a pattern in a string.
#
# 2. The module re provides the support to use regex in the python program.
# 3. The re module throws an exception if there is some error ... |
f235e7b36ac48915e7e0750af1fb6621a971f227 | yadavpratik/python-programs | /for_loops_programs.py | 1,901 | 4.28125 | 4 | # normal number print with for and range function
'''n=int(input("enter the number : "))
print("normal number print with for and range function")
for i in range(n):
print(i)
# =============================================================================================================================
# pr... |
0b0d3048ba7067daca2a139fc90f4278104f030f | yadavpratik/python-programs | /exception_programs.py | 3,385 | 4.0625 | 4 | #use of try and except block
'''a=int(input("enter the first no :"))
b=int(input("enter the second no :"))
print(a/b)'''
'''try:
a=int(input("enter the first no :"))
b=int(input("enter the second no :"))
print(a/b)
except:
print("enter the correct number ")'''
# ===================... |
9b0f19dd00b501ebd0e34d9d3a6068edb6e2713d | enricog84/ud120-projects | /naive_bayes/nb_author_id.py | 1,976 | 3.734375 | 4 | #!/usr/bin/python
"""
This is the code to accompany the Lesson 1 (Naive Bayes) mini-project.
Use a Naive Bayes Classifier to identify emails by their authors
authors and labels:
Sara has label 0
Chris has label 1
"""
import sys
from time import time
sys.path.append("../tools/")
#sys.pa... |
e95989a2f12a86bdc83e02758c91a20e17780565 | olincollege/uno-card-game | /uno_game.py | 1,377 | 4.03125 | 4 | """
Main program to set up and run a uno game.
"""
from uno_deck import Deck, PlayGame
from uno_view import TextView
from uno_controller import TextController
def main():
"""
Play a game of uno
"""
# Set up the MVC components.
print("Welcome to Uno!\n \
Here are the rules:\n \
1. M... |
05a4d7609249fdac128ad9e3c9fb0b061e69c0f7 | monk200/Daily_Coding_Problem | /problem13.py | 1,147 | 3.828125 | 4 | """
Daily Coding Problem #13
Given an integer k and a string s, find the length of the longest substring that contains at most k distinct characters.
For example, given s = "abcba" and k = 2, the longest substring with k distinct characters is "bcb".
"""
def substringLength(k, s):
start = 0
end = 1... |
28c263feaa9d10282854b9dd25cb0e94e41b82f0 | monk200/Daily_Coding_Problem | /problem6.py | 2,025 | 4.09375 | 4 | """
Daily Coding Problem #6
An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev fields,
it holds a field named both, which is an XOR of the next node and the previous node. Implement an XOR linked list;
it has an add(element) which adds the element to the e... |
a1ee1c5cfa1a83dfa4c2ca2dc2ec204b201ed1f2 | NatalieBeee/PythonWithMaggie | /algorithms/printing_patterns.py | 1,218 | 4.28125 | 4 | '''
#rows
for i in range(0,5):
#columns
for j in range(0,i+1):
print ('*', end ='')
print ('\r')
'''
# half_pyramid() is a function that takes in the number of rows
def half_pyramid(num_r):
#for each row -vertical
for i in range(0,num_r):
#for each column -horizontal
for j ... |
247ce8df8eb0c979a59c5c9d9f3d5282994f560a | DavidLewinski/CA116 | /week06/a/add-args.py | 164 | 3.59375 | 4 | #!/usr/bin/env python3
import sys
i = 0
total = 0
args = sys.argv[1:]
while i < len(args):
total = total + int(args[i])
i = i + 1
print(total)
|
ec5f15beeeede6ada5c129bb7e1e09a898a0c263 | DavidLewinski/CA116 | /week09/fruit.py | 304 | 3.640625 | 4 | #!/usr/bin/env python3
import sys
words = sys.stdin.readlines()
fruits = {
"apple": True,
"pear": True,
"orange": True,
"banana": True,
"cherry": True,
}
i = 0
while i < len(words):
if words[i].strip() in fruits:
print(words[i].strip())
i = i + 1
|
782b5bbccedc7a8b602d92314361d94945e5e09c | DavidLewinski/CA116 | /week02b/sequence-8.py | 83 | 3.640625 | 4 | #!/usr/bin/env python3
x = (x * -1)
if x <= 0:
x = x - 1
else:
x = x + 1
|
e502a93551fd4be7e4901f689dffc39266fb37d3 | DavidLewinski/CA116 | /week03/b/reverse-ten-digits.py | 569 | 3.546875 | 4 | #!/usr/bin/env python3
n = 10
i = 0
while i < n:
num = int(input())
if i == 0:
num10 = num
elif i == 1:
num9 = num
elif i == 2:
num8 = num
elif i == 3:
num7 = num
elif i == 4:
num6 = num
elif i == 5:
num5 = num
elif i == 6:
num4 =... |
3f22f8358abb033e0cc5483c5225df552b03420e | DavidLewinski/CA116 | /week03/b/ten-sum-even.py | 176 | 3.8125 | 4 | #!/usr/bin/env python3
n = 10
i = 0
total = 0
while i < n:
numIn = int(input())
numIn = ((numIn + 1) % 2) * numIn
total = total + numIn
i = i + 1
print(total)
|
f3435986eff6cd592081f3679e29277fc2b3a681 | DavidLewinski/CA116 | /week02a/b/longer-of-three-strings.py | 196 | 3.96875 | 4 | #!/usr/bin/env python3
A = input()
B = input()
C = input()
if (len(A) > len(B) and (len(A) > len(C))):
print(A)
elif (len(B) > len(A) and (len(B) > len(C))):
print(B)
else:
print(C)
|
e5a0fb9bd8186b10e0bf147e33860d88a42d1c40 | DavidLewinski/CA116 | /week08/tt-module-codes.py | 226 | 3.6875 | 4 | #!/usr/bin/env python3
timetable = []
s = input()
while s != "end":
timetable.append(s)
s = input()
i = 0
while i < len(timetable):
tokens = timetable[i].split()
print(tokens[3])
i = i + 1
|
78d919d0ab8a5060c0beebfd2d92cb713daf8293 | DavidLewinski/CA116 | /week01/the-three-digits.py | 152 | 3.765625 | 4 | #!/usr/bin/env python3
num = int(input())
x1 = num // 100
x2 = (num // 10) - (x1 * 10)
x3 = (num) - ((num // 10) * 10)
print(x1)
print(x2)
print(x3)
|
3837feef9b7baabd45186ef4956883477ead0f67 | josezm/python-excercises | /ejercicios 1.py | 555 | 3.53125 | 4 | def retornar(x):
lista=[]
for i in range(0,x+1):
lista.append(i)
return lista
print retornar(5)
def retornar2(x):
lista=[]
if x==-1:
return lista
else:
lista=retornar2(x-1)
lista.append(x)
return lista
print retornar2(5)
def suma(x):
... |
4697eecf633a30e9d323b394e1e0e7c328245e13 | victorglimskog/blackjack | /hand.py | 386 | 3.671875 | 4 | '''
Hand keeps track of cards on hand and total value of them
'''
class Hand():
def __init__(self, initial_cards = []):
self.cards = initial_cards
def __str__(self):
return f'{self.cards}'
def get_card_info(self,hidden_cards = 0):
card_list = self.cards
for i in range(hidd... |
2ed4e01f37128a22e6b19308fcb6681085a671e0 | seojinsarejj/coding-test-practice | /daily/가장 긴 팰린드롬.py | 639 | 3.71875 | 4 | # 1차 --- 성공
def solution(s):
for count in range(len(s),1,-1):
for i in range(len(s)-count+1):
target = s[i:i+count]
palindrome = True
for j in range(count//2):
if target[j] != target[(j+1) * (-1)]:
... |
40d053be518e98376c8e47119c739e5e36705b5d | NikitaBukreyev/UniDump | /I Курс/1 Семестр/Алгоритмы/Лаб.2/Задание 2.py | 385 | 3.703125 | 4 | result = 0
def fun_fuction(m, n):
if 0 < m or m < n:
return "Wrong input"
else:
Variable_to_save_m = m
Variable_to_save_n = n
global result
if m == n or m == 0:
result += 1
else:
if 0 < m and m < n:
fun_fuction(m - 1, n - 1)
fun_fuction(Variable_to_save_m, Variable_to_save_n - 1)
return r... |
2fbfd3a8a15e4ab72218ced71736fd4545cda3af | NikitaBukreyev/UniDump | /I Курс/1 Семестр/Алгоритмы/Лаб.1/roman_to_arabic.py | 424 | 3.9375 | 4 | def to_arabic (k):
# initial settings
k+=" "
result=0
dictionary_={"M":1000,"D":500,"C":100,"L":50,"X":10,"V":5,"I":1," ":0}
J=list(dictionary_.keys())
# convert digit
for x in range(len(k)-1):
if J.index(k[x])<=J.index(k[x+1]):
result+=dictionary_.get(k[x])
else:
result-=dictionary_.get(k[x])
if... |
5be53534c00ff8e024201e16884771e781aacc21 | NikitaBukreyev/UniDump | /I Курс/1 Семестр/Алгоритмы/Лаб.5/Main.py | 1,388 | 3.6875 | 4 | import random
import sys
from Shellsort import *
from Heapsort import *
sys.setrecursionlimit(1_000)
# Метод по созданию упорядоченных списков
def make_consistent_list(list_range):
empty_list = []
for x in range(list_range):
empty_list.append(x)
return empty_list
# Метод по созданию случайных спис... |
04bfe134d49351814870a5e2971142dddb5b2b28 | amandalynne/language-similarity | /typo_demo.py | 312 | 3.671875 | 4 | import typology
def demo(language):
print "The most similar language to "+ language + " is: "
print typology.get_similar_langs(language)[0]
#demo('Kannada')
#demo('Telugu')
#demo('Urdu')
demo('Persian')
demo('German')
demo('Korean')
#demo('Turkish')
#demo('Russian')
#demo('Polish')
#demo('Japanese')
|
badd2db1c53a82992f07e5606c980d3e2f9fdcc8 | emanuelgit/Python_Program_BI | /Clases/Clase_1/Listas por comprensión.py | 473 | 3.953125 | 4 | cubos = []
# elevado al cubo
for x in range(10):
cubos.append(x**3)
print(cubos)
# Lista por comprensión
cuboslc = [x**3 for x in range(10)]
print(cuboslc)
lista = []
for x in [1, 2, 3]:
for y in [3, 1, 4]:
if x != y:
lista.append((x, y))
print(lista)
# lista multidimensional por compre... |
d3c1f969e7908a25d0f744ba955860a6cda2a2d9 | emanuelgit/Python_Program_BI | /Clases/Clase_1/Comentarios clase 1.py | 5,560 | 3.96875 | 4 | # -*- coding: utf-8 -*-
# Funcion Dir
dir()
text_1 = 'hola'
text_2 = 'holasa'
text = 'hola'
Text = 'hola'
# help
# help(algo) Ctrl + i
# Función print
print('hola mundo')
print("hola mundo")
print('''hola mundo''')
print(''' este es un string largo
... y 'mas' largo aun
... y "super" largo'''... |
83b34674a351770ac06fd59afcbc7d2a11dabfe0 | emanuelgit/Python_Program_BI | /Clases/Clase_1/Ejemplos.py | 1,405 | 4 | 4 | # -*- coding: utf-8 -*-
# Ejemplo 1:
# lecturas de archivos:
import pandas as pd
urldata = 'https://raw.githubusercontent.com/emanuelgit/Python_Program_BI/master/data/titanic/titanic3.csv'
data = pd.read_csv(urldata)
# Ejemplo 2:
# Impresion en consola:
text = 'Curso\n\tPython' # \n print an ENTER
print(te... |
dd098f2a3b51169b3fc9f043730530d862bc67db | sundarsrst/PyFiles | /2.py | 1,296 | 3.78125 | 4 | def dog_check(mystring):
if 'dog' in mystring:
return True
else:
return False
a = dog_check("hey this is dog")
print(a)
def dog_checks(my_string):
if 'dogy' in my_string:
return True
else:
return False
b = dog_checks("hey this is dogyy")
print(b)
def pig... |
9e435b4d6c56c3195bdb55a5ba26889f7bd68f52 | Kirill255/python-books-read-and-code | /hangman/main.py | 1,901 | 3.734375 | 4 | import random
def hangman(word):
wrong = 0
stages = ["",
"__________ ",
"| | ",
"| | ",
"| 0 ",
"| /|\ ",
"| / \ ",
"| "
]
... |
717b39e724ddeb9387cc093b0c22f5c5b0544d69 | Kazenoyari/Pygame-space_invaders | /game.py | 5,298 | 3.5 | 4 | #///////////////////////////////////////////////////////////
#
# Main game file. Contains the actual game.
# Its in charge of creating the objects and drawing them
# on the screen, recieving keyboard events and handling
# the win and loose logic.
#
# Uses dirty rectangles for drawing
#
#//////////////////////////////... |
61ebfe8812dbfcfa4ef0a392186f78e0536f6938 | Ju5t15e/fCulc | /calc321.py | 435 | 3.875 | 4 | ask = input("Enter your expression: ")
#Тут я маю перетворити ask в float
def variables(s):
chrList = ['(',')','+','-','*','/','0','1','2','3','4','5','6','7','8','9']
if s in chrList:
return True
else:
return False
def jisuan(n1,n2,o):
if o=='+':
return n1+n2
elif o=='-':
... |
ce61728870d245451685895509bb235ab8c1907a | smith-sanchez/validadores_en_python | /Boleta 3.py | 681 | 3.890625 | 4 | #INPUT
nombre=input("ingrese el nombre del cliente:")
cantidad_docenas=int(input("ingrese la cantidad de docenas:"))
valor_por_docena=float(input("ingrese el valor por docena:"))
#PROCESSING
precio_total=(cantidad_docenas*valor_por_docena)
#VERIFICADOR
beneficia_la_compra=(precio_total==80)
#OUTPUT
print... |
82a924511d525dfa9fe513541b648832d68711e8 | smith-sanchez/validadores_en_python | /Verificador 13.py | 456 | 3.78125 | 4 | #Verificador 13
#INPUT
semiperimetro_del_triangulo=float(input("ingrese el semiperimetro del triangulo:"))
radio_del_circulo=float(input("ingrese el radio del circulo:"))
#PROCESSING
area_del_triangulo=(semiperimetro_del_triangulo*radio_del_circulo)
#VERIFICADOR
area=(area_del_triangulo>75)
#OUTPUT
print... |
3cacfde1db19a4f7b8ccf3fca55c579fc8fc7313 | smith-sanchez/validadores_en_python | /Boleta 17.py | 682 | 4.125 | 4 | #INPUT
cliente=(input("ingrese el nommbre del cliente: "))
precio_mochila=float(input("ingrese el precio de la mochila:"))
numero=int(input("numero de mochilas:"))
#procesing
total=(precio_mochila*numero)
#vereficador
cliente_necesario=(total>120)
#OUTPUT
print("############################")
print("# B... |
4e020c382ef9e81ec1894d180fb8e24f2254ef59 | smith-sanchez/validadores_en_python | /Verificador 8.py | 439 | 3.6875 | 4 | #verficador 8
#input
carga_electrica_acumulada=float(input("ingrese la carga electrica acumulada:"))
diferencia_de_potencial=float(input("registre la diferencia de potencial:"))
#procesing
capacitancia=(carga_electrica_acumulada/diferencia_de_potencial)
#vereficadores
capacitancia_adecuada=(capacitancia==4)
... |
496dcd3e69bf5332f9c990928804c8381c74502f | smith-sanchez/validadores_en_python | /Verificador 5.py | 333 | 3.875 | 4 | #Verificador 5
#Input
angulo=float(input("ingrese el angulo:"))
tiempo=float(input("ingrese el tiempo:"))
#Procesing
velocidad_angular=(angulo/tiempo)
#Verificador
velocidad=(velocidad_angular==9)
#output
print("la velocidad angular es:",velocidad_angular)
print("¿la velocidad angular es igual que 9?:",... |
15b475329b26186eae18598630a6e7a21db03fd0 | JasonVanRaamsdonk/Python_HackerRank | /runnerUp_score.py | 421 | 4 | 4 | # Jason van Raamsdonk
# program to print the second highest element of an inputted my_array
# first input is the array size, second to n inputs are the array elements
if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().split()))
current = min(arr)
for i in range(0, n):
if... |
7d0b00c62b88561c3452d04c17d107fd6ac4f0e8 | havok-dev/Disease-model-using-pygame | /main.py | 13,535 | 3.546875 | 4 | #importing libraries
import numpy as np
import pygame,sys
#Defining the rgb values of the colours in the program
BLACK=(0,0,0)
WHITE=(255,255,255)
BLUE=(53, 128, 232)
GREEN=(70, 245, 12)
RED=(245, 12, 12)
GREY=(230,230,230)
YELLOW=(190,175,50)
BACKGROUND=WHITE
#making the dot
class person(pygame.sprite.Sprite): ... |
bc60e9e81cdf5b0ae71ee6ac794a34e28e44a470 | TheerthaChammancheri/Python-Automation | /assessment.py | 140 | 4.0625 | 4 | st = 'Sam Print only the words that start with s in this sentence'
for n in st.split():
if n[0].lower() == 's':
print (n)
|
2a7ce3faee8d0e57f5507280b84858b7c4c4410d | TheerthaChammancheri/Python-Automation | /Ques6.py | 543 | 4.0625 | 4 | def max(l1,l2,l3):
l1.sort()
l2.sort()
l3.sort()
maxlist = [l1[-2], l1[-1], l2[-2], l2[-1], l3[-2], l3[-1]]
print maxlist
return maxlist
def avg(l):
average = sum(l) // len(l)
print(average)
def min(l1,l2,l3):
l1.sort()
l2.sort()
l3.sort()
minlist = [l1[... |
4c0658065ee84676b9cf5cbb456f40336157b9d2 | AlexKjes/kogark_3 | /handout.py | 763 | 3.65625 | 4 | def triangle(position, x0, x1, x2, clip=1):
value = 0.0
if x0 <= position <= x1:
value = (position - x0) / (x1 - x0)
elif x1 <= position <= x2:
value = (x2 - position) / (x1 - x0)
if value > clip:
value = clip
return value
def grade(position, x0, x1, clip=1):
if p... |
aa4f86a4154fc153efb7714bcca5ce8e25f90bf3 | EkanshMaheshwari/SuicideAnalysis | /Pythongraphs/pig5.1.5/educational status wise clustering 0-100+.py | 642 | 3.625 | 4 | import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from sklearn.cluster import KMeans
from sklearn.preprocessing import LabelEncoder
data= pd.read_csv("part-r-00000.csv",header=None)
z=LabelEncoder()
kmeans =KMeans(n_clusters=3)
data["numerical"]=z.fit_transform(data[0])
l=data[["numerical",2]]
kmea... |
94fdc2e92f3c16cb55ceaf885f797f64632e8c39 | EkanshMaheshwari/SuicideAnalysis | /Pythongraphs/pig1.4/agegroup cluster.py | 608 | 3.578125 | 4 | import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import LabelEncoder
from sklearn.cluster import KMeans
import pandas as pd
data = pd.read_csv("part-r-00000.csv",header=None)
lbmake =LabelEncoder()
data["numerical"]=lbmake.fit_transform(data[0])
print(data)
x=data[["numerical",1]]
kmeans=KM... |
cb774f262c84f722534628917dae06ef58c17f50 | VishalPanchal96/todolist | /app.py | 1,060 | 3.578125 | 4 | """
Author : Vishal Panchal
Created At : 9 August 2019
Description : This is sample flask application with sample API to create to do list.
"""
from flask import Flask, request, jsonify, render_template,redirect
from controller import TaskController
import os
app = Flask(__name__)
app.config["DEBUG"] = True
# ... |
9fbcd6e620fa20f853b69028c20462bde54670f7 | akuroodi/MIT-Python-Courses | /6001 - Intro to CS with Python/Week 2/FixedAmt.py | 690 | 3.875 | 4 | balance = 150
annualInterestRate = 0.2
def calculator (x, r, n, p):
"""
Inputs:
x = initial balance
r = annual interest rate
Outputs: The monthly fixed payment to reduce x to <=0 in 12 months
"""
for n in range(0,12):
if (n == 0):
balUnpaid = x - p
... |
7225f8c0ec76085b2845a800c0d656a0244f497a | akuroodi/MIT-Python-Courses | /6001 - Intro to CS with Python/Week 2/FixedAmt_Bisection.py | 1,312 | 3.96875 | 4 | balance = 999999
annualInterestRate = 0.18
lowerBound = balance / 12.0
upperBound = balance
def calculator (x, r, n, p, l, u):
"""
Inputs:
x = initial balance
r = annual interest rate
n = month counter
p = fixed payment guess, starting with mid of two bounds
l = lower bound
h = upper ... |
319861b98a81af693bbb0681cd09722813519620 | akuroodi/MIT-Python-Courses | /6001 - Intro to CS with Python/Midterm/P3.py | 670 | 4.09375 | 4 | # Write a function that returns a list of keys with the target value in aDict
# Assume both keys and values are integers
# The list should be sorted in increasing order
# Return empty list of aDict does not contain target value
def keysWithValue(aDict, target):
'''
Inputs:
aDict: a dictionary
... |
07a714f7e157d2f07c6501362224a976e63f3d50 | akuroodi/MIT-Python-Courses | /6002 - Computational Thinking/Final/rabbits.py | 3,632 | 4.21875 | 4 | import random
import pylab as plt
# Global Variables
MAXRABBITPOP = 1000
CURRENTRABBITPOP = 50
CURRENTFOXPOP = 300
def rabbitGrowth():
"""
rabbitGrowth is called once at the beginning of each time step.
It makes use of the global variables: CURRENTRABBITPOP and MAXRABBITPOP.
The global variable CUR... |
afe2fb346a891326a7f1e528dc527ea2d510e2b3 | akuroodi/MIT-Python-Courses | /6001 - Intro to CS with Python/Week 2/StringSearcher.py | 569 | 3.9375 | 4 | def isIn(char, aStr):
'''
char: a single character
aStr: an alphabetized string
returns: True if char is in aStr; False otherwise
'''
if (len(aStr) == 0):
return False
index = len(aStr) // 2
guess = aStr[index-1]
if (len(aStr) == 1):
return guess == char
... |
7f3d44d266f8dec11d3097ba69c0a7a074da55c7 | bala-gunasundar/my-challenge | /snake/temple_land.py | 1,219 | 3.828125 | 4 | #!/usr/bin/python
import sys
def unique_center(inp):
l = len(inp)
if l >= 3 and (l % 2 != 0):
return True
else:
return False
def start_and_end(inp):
if inp[0] == 1 and inp[-1] == 1:
return True
else:
return False
def check_order(inp):
l = len(inp)
if l % 2... |
a940010e496c7067b229f937e28bf786b64a6665 | 1017-MJ/1017_MJ | /369.py | 314 | 3.703125 | 4 | for i in range(1, 101):
str_i = str(i)
count_str = 0
for j in str_i:
if (j =='3') or (j =='6') or (j =='9'):
count_str = count_str+1
if count_str == 0:
print(str_i+':', i)
else:
print(str_i+':', count_str * '짝') |
7faeb4e9245c70420d308b34b2bc8839296a3b58 | 1017-MJ/1017_MJ | /2.py | 208 | 3.796875 | 4 | print("3개의 값을 입력하시오")
x = int(input("Enter the x: "))
y = int(input("Enter the y: "))
z = int(input("Enter the z: "))
z = x + 1
y = y + 1
x = z + 1
print("변경된 값 : ", x, y, z) |
17e5db37f739cc17b92a5727bce52cf8ad37c918 | cgamer21000/python-1 | /review/hi | 178 | 3.65625 | 4 | #!/usr/bin/env python3
import colors as c
print('c.clear')
print(c.blue + 'what is your name' + c.reset)
person = input('enter your name')
print('nice to met you' + person)
|
754cd0a9c3159b2eb91350df0f5d2907c543a6ad | sbishop7/DojoAssignments | /Python/pythonAssignments/funWithFunctions.py | 639 | 4.21875 | 4 | #Odd/Even
def odd_even():
for count in range(1,2001):
if count % 2 == 1:
print "Number is ", count, ". This is an odd number."
else:
print "Number is ", count, ". This is an even number."
#Multiply
def multiply(arr, x):
newList = []
for i in arr:
newList.... |
e98cf2fd2201f84a888cf8ad8e33befafb08afe6 | sbishop7/DojoAssignments | /Python/pythonAssignments/findCharacters.py | 307 | 3.84375 | 4 | """
Write a program that takes a list of strings and a string containing a single character, and prints a new list of all the strings containing that character.
"""
l = ['hello','world','my','name','is','Anna']
char = 'a'
n = []
for item in l:
if item.find(char) > 0:
n.append(item)
print n
|
d004ec009f9b453689fb9e38e502f82c83b7be51 | pykevery1/pykevery1 | /README.py | 827 | 3.609375 | 4 | import random
import time
class Introduce:
Bleeps = ["&","#","$","-","*","+","@","_"]
def MyselfAs (name):
print("Hi! I'm " + str(name))
time.sleep(2)
print("I am a self taught programmer, who's only goal is to get better")
time.sleep(2)
print("I have made a few project... |
24c8e96223323f95aedb356ba852e83bfbbac05d | Aniket23160/PythonCodes | /Problem.py | 204 | 3.953125 | 4 | N = input()
# Get the input
sum_integer = 0
for i in range(N):
sum_integer=sum_integer+numArray[i-1]
# Write the logic to add these numbers here
# Print the sum
print(sum_integer) |
14b07e0e418e84a905786bcc9f62931e0bd8df1f | roblivesinottawa/Python3-Programs-Scripts | /functions/func_arg.py | 140 | 3.625 | 4 | def add():
return 1 + 1
def beforeFunction(func):
print("This is the function before add()")
print(func())
beforeFunction(add) |
b61314b7915fac3f3f4e4f0b7423166f262cbd69 | NavTheRaj/python_lab | /pickle_veg.py | 3,513 | 4.5625 | 5 | #WAP TO DEMONSTRATE DICTIONAARY OPERATIONS IN PYTHON
veg_dict={'Brinjal':10,'Cabbage':20,'Pumpkin':25}
print("-------------------\n")
#print("1.View list\n2.Add a new vegetable\n3.Change the price of an vegetable\n4.Delete the vegetable\n5.Quit!")
choice=0
while choice != 5 :
print("1.View list\n2.Add a new veg... |
f4e62c6fa38d6003192523bdc000b885ba0f4a6d | LdeWaardt/Codecademy | /Python/2_Strings_and_Console_Output/07_Dot_Notation.py | 480 | 4 | 4 | #Let's take a closer look at why you use len(string) and str(object), but dot notation (such as "String".upper()) for the rest.
lion = "roar"
len(lion)
lion.upper()
# Methods that use dot notation only work with strings.
# On the other hand, len() and str() can work on other data types.
# PROBLEM: call the len() fu... |
9535c83847a12174fc9d6002e19f70c163876af5 | LdeWaardt/Codecademy | /Python/1_Python_Syntax/09_Two_Types_of_Division.py | 1,640 | 4.59375 | 5 | # In Python 2, when we divide two integers, we get an integer as a result. When the quotient is a whole number, this works fine
# However, if the numbers do not divide evenly, the result of the division is truncated into an integer. In other words, the quotient is rounded down to a whole number. This can be surprisin... |
a692770ee44e320cb01132ec3fd8304bc240c2d4 | mak372/CS50-assignments | /pset6/cash/cash.py | 531 | 3.578125 | 4 | from cs50 import get_float
change = 0.00
quarters = 0.25
dimes = 0.10
nickels = 0.05
pennies = 0.01
coins = 0
while True:
change = get_float("Change owed:")
if change > 0.00:
break
while(change >= quarters):
change = change - quarters
coins += 1
while( change >= dimes):
change = change - dim... |
d692305ec1f85378b23baf31be90e47877e7dcb1 | wesleyclarkgit/python_notes | /matrix.py | 2,179 | 4.03125 | 4 | """Matrix:
Special case of two dimensional array where each data element is of strictly the same size.
These are important for some mathematical and scientific calculations."""
# use numpy for this one
from numpy import *
a = array([['Mon',18,20,22,17],['Tue',11,18,21,18],
['Wed',15,21,20,19],['Thu... |
d70be3359843ad8fb3e3057e0a9712a57204abaf | weberlu88/2020-Python3-self-learning | /8_function-basic.py | 150 | 3.96875 | 4 | # 函數宣告: parameter return
def mutiply(n1, n2):
result = n1*n2
return result
# 函數呼叫
value = mutiply(8, 10)
print(mutiply(8, 7)) |
a212e7ffcf2d6f5a073d8e7f63666cc02233d7c3 | weberlu88/2020-Python3-self-learning | /9_fuction-args.py | 464 | 4 | 4 | # 參數的預設資料
def power(base, exp = 0):
res = base**exp
print(res)
return res
power(3, 2)
# 使用參數名稱對應
def divide(n1, n2):
res = n1/n2
print(res)
return res
divide(2, 4)
divide(n2=2, n1=4)
# 無限(不定)參數資料(tuple)
def avg(*ns):
print(ns)
sum = 0
for i in ns:
sum += i
else:
... |
3a2c68af4df0e616be48d9c38f8c5408df6a97cc | weberlu88/2020-Python3-self-learning | /7_loop-control.py | 932 | 3.71875 | 4 | # while-else 區塊
n = 1
while n <= 10:
n += 1
else:
print('迴圈結束前,必會執行此區塊')
# break的簡易範例 > break不會執行else區塊
n = 0
while n < 5:
if n == 3:
break
print(n) #印出迴圈中的n
n+=1
print("最後的n: ",n) # 印出迴圈結束的 n
# continue 的簡易範例
n = 0
for x in [0,1,2,3]:
if x % 2 == 0: # x是偶數 > 忽略下方程式
continue
... |
3c161bf6bca2ef7b25f8fa4a411716a602118d6c | embasa/cs151 | /src/addressbook/AddressBookGUI.py | 736 | 3.859375 | 4 | or__ = 'bruno'
class AddressBookGUI(object):
"""
This is the parent class of AddressBookImportDialogue, AddressBookEntryDialogue and
AddressBookDialogue, it holds methods and variables that
are shared among the two children classes
"""
def __init__(self):
"""
Does things, and t... |
86ea818619a81d0034994f0c9c70d326b5972d56 | Sanakhan29/PythonPrograms | /if_elif_else.py | 260 | 4.125 | 4 | ali_age = int(input('Input Ali Age:'))
sara_age = int(input('Input Sara Age:'))
if ali_age == sara_age:
print('They both have same age')
elif ali_age < sara_age:
print('Ali is younger than Sara')
else:
print('Ali is elder than Sara') |
b7ba09e1c4a3da869b69b436593b611dab77cf58 | luximeng/OnlineShopDiscount | /Person.py | 4,712 | 4 | 4 | from Product import *
class Person:
def __init__(self, name):
"""
Constructor for base class Person's name
"""
# Person class has an attribute called name
self.name = name
def apply_discount(self, product):
"""
user-defined method will be overriden lat... |
161ae4ab40f62d33e98345159d22e7adc6e362c9 | YunusovSamat/LaboratoryWorkPython | /Lr1/task3.py | 1,680 | 3.796875 | 4 | import random
def is_prime(n):
if n < 1:
return False
for i in range(2, int(n / 2)):
if n % i == 0:
return False
return True
def gcd(a, b):
while (a != 0) and (b != 0):
if a > b:
a = a % b
else:
b = b % a
return a + b
def m... |
bcf7e23d39f5d8a0b4ef9402d42ba221e3089cc0 | sigurdurh18/Forritun1 | /TicTacToe.py | 2,178 | 3.53125 | 4 | PLAYERS={False:'X',True:'O'}
def creation(length):#finished but no error handeling
return [[1+q+i*length for q in range(length)] for i in range(length)]
def display(kek):#finished
for i in kek:
for q in i:
print('{:>5}'.format(q),end="")
print()
def innit():#finished up to error m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.