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
412104dd50bab7a3adf7bb8cc889be227f162ed4
destinysam/Python
/map function.py
530
4.09375
4
# CODED BY SAM@SAMEER # EMAIL:SAMS44802@GAMIL.COM # DATE:11/09/2019 # PROGRAM: CONVERTING OF LIST NUMBERS INTO NEGATIVE NUMBERS def negative(numbers, rang): return_list = [] temp = 0 counter = 0 for j in range(rang): counter = int(numbers[j]) temp = counter * -1 return_list...
aa1193d1f11a0c3ed765ceebb0075cfbc1ed3b0c
destinysam/Python
/assignment operators.py
310
4.03125
4
# CODED BY SAM@SAMEER # EMAIL: SAMS44802@GMAIL.COM # DATE: 17/08/2019 # PROGRAM: USING OF ASSIGNMENT OPERATORS IN PYTHON name = "sameer" print(name + "ahmad") name += "ahmad" print(name) age = 8 print(age) age += 2 # age = 8+2 =10 print(age) age *= 2 # age = 10*2 = 20 print(age) age -= 3 # age = 20-3 = 17 print(age)...
5090e0dc9b0b2af20e1c98a8faefecc9f6e98fe3
destinysam/Python
/if_statement.py
217
4.03125
4
# CODED BY SAM@SAMEER # EMAIL: SAMS44802@GMAIL.COM # DATE: 18/08/2019 # PROGRAM: USING OF IF STATEMENT IN PYTHON age = int(input('ENTER THE AGE')) if age >= 21: print("U ARE SELECTED") else: print("YOUR AGE IS BELOW 21")
d9f27a2de72ad70490a106541336da7e12b3658d
venkatadri123/Python_Programs
/100_Basic_Programs/program_83.py
127
3.75
4
# 83.Please write a program to shuffle and print the list [3,6,7,8]. import random li = [3,6,7,8] random.shuffle(li) print(li)
1e1c08f44e704162f524bcf16e864410fbb81936
venkatadri123/Python_Programs
/core_python_programs/prog24.py
146
4.4375
4
# To accept a string from the keyboard and display individual letters of the string. str=input('enter string values:') for i in str: print(i)
6709221f53da07b735c97eb6701ac100d1c04a0a
venkatadri123/Python_Programs
/Sample_programs/31sum.py
114
3.6875
4
#To display sum of a list. l=[10,20,45] sum=0 i=0 while i<len(l): sum=sum+l[i] i=i+1 print("result=",sum)
76d555e119434b9b681e12c24d766a378a46e335
venkatadri123/Python_Programs
/Sample_programs/7incr.py
116
4.0625
4
#to increase a number by 1. ch=int(input()) x = ch+ 1 print ("The incremented character value is : ",x ) print (x)
6e279577678929165b7e5157ae4fffbdaaec1ccd
venkatadri123/Python_Programs
/core_python_programs/prog72.py
187
3.953125
4
# Write a lambda expression for sum of two number. def sum(a,b): return a+b x=sum(10,20) print('sum=',x) # Converting into lambda expression. f=lambda a,b:a+b print('sum=',f(10,20))
44c554dfeae7565f4d281bd31418a6f95a8beee4
venkatadri123/Python_Programs
/Advanced_python_programs/prog7.py
540
3.796875
4
# Wrte employee class with accessor and mulator methods. class emp: def setid(self,id): self.id=id def getid(self): return self.id def setname(self,name): self.name=name def getname(self): return self.name def setsal(self,sal): self.sal=sal def getsal(self...
0f0ac9cde7b60c38b2b507f099116c2dfa215ede
venkatadri123/Python_Programs
/Sample_programs/6addsub.py
121
3.8125
4
#To find subtraction and addition. x=int(input()) y=int(input()) z=x+y print('addition z=',x+y) z=x-y print('sub z=',x-y)
593d588380891054c09dbdae3303399a2460999a
venkatadri123/Python_Programs
/Advanced_python_programs/student.py
538
3.6875
4
# Import some code from teacher class using Inheritance. from teacher import* class student(teacher): def setmarks(self,marks): self.marks=marks def getmarks(self): return self.marks s=student() s.setid(14) s.setname('venkatadri') s.setage('25 Years') s.setheight('5.11 Inch') s.setaddress('vindu...
2e3e733022370fd080b83b15db16340d75acc2b0
venkatadri123/Python_Programs
/HackerRank_programs/hourglassSum.py
1,200
3.890625
4
"""Given a 2D Array, : 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in to be a subset of values with indices falling in this pattern in 's graphical representation: a b c d e f g There are hourglasses in , and an hourglass sum is the sum of an hourglass' values. ...
1e6200636339b88fdfab99dd685b6f6cc11cbc5a
venkatadri123/Python_Programs
/100_Basic_Programs/program_11.py
532
3.953125
4
# 11.Write a program which accepts a sequence of comma separated 4 digit binary numbers as its # input and then check whether they are divisible by 5 or not. The numbers that are divisible # by 5 are to be printed in a comma separated sequence. l=[] x=input() items=x.split(',') for p in items: q=int(p) if q%5...
d0be8e43586ecf7ccb00bb5bb2c1680e1e3cd6f6
venkatadri123/Python_Programs
/HackerRank_programs/repeatedString.py
978
3.890625
4
"""Lilah has a string, , of lowercase English letters that she repeated infinitely many times. Given an integer, , find and print the number of letter a's in the first letters of Lilah's infinite string. For example, if the string and , the substring we consider is , the first characters of her infinite string. Th...
c156d757509443dfe18982519d44481ad0484f3b
venkatadri123/Python_Programs
/Advanced_python_programs/prog21.py
395
3.859375
4
# Creating our own Exception. class MyException(Exception): def __init__(self,str): self.str=str def check(dict): for k,v in dict.items(): print('%-15s %.2f' %(k,v)) if v<2000.00: raise MyException('balence amount is less') bank={'raju':35600,'venkey':25641,'hari':1230,'suri'...
b5edf92d6ac5a62efe88d987bfaf0e080e9b7b2e
venkatadri123/Python_Programs
/core_python_programs/prog7.py
247
4.0625
4
#To display employee Id no,Name,Salory from the keyboard & display them. id_no=int(input('enter id:')) name=input('enter name:') sal=float(input('enter sal:')) print('employee details are:') print('id_no=%d,\nname=%s,\nsal=%f' %(id_no,name,sal))
039a88bcde8a8045d66b502bf2d12c14363c54f9
venkatadri123/Python_Programs
/Advanced_python_programs/prog2.py
473
3.96875
4
# Create a student class with roll number,name,marks in three subjects and total marks. class student: def __init__(self,r,n,m): self.rno=r self.name=n self.marks=m def display(self): print('rno=',self.rno) print('name=',self.name) print('marks=',self.marks) ...
0eaf2afa9cc1c3f161504fc2c9254b92fb3f4262
venkatadri123/Python_Programs
/100_Basic_Programs/program_43.py
280
4.53125
5
# 43. Write a program which accepts a string as input to print "Yes" # if the string is "yes" or "YES" or "Yes", otherwise print "No". def strlogical(): s=input() if s =="Yes" or s=="yes" or s=="YES": return "Yes" else: return "No" print(strlogical())
04fad98db209c75d4ec38471b36a7584fa8d2532
venkatadri123/Python_Programs
/Sample_programs/4prod.py
154
4.34375
4
#To find product of given two numbers. x=int(input('enter first no:')) y=int(input('enter second no:')) product=x*y print("product of two no is:",product)
15f676a5c2184115148f89723a2912283baed3c2
venkatadri123/Python_Programs
/core_python_programs/prog37.py
277
3.96875
4
# To display a given string is found or not and display position no also. lst=['hari','venkey','suri','hello'] n=input('enter a string:') a=len(n) l=len(lst) for i in lst: if i==n: print('found') break else: print('not found') print(a) print('end')
9c5ca3f0af3e22d8ed74c58d8bcf0ef5dee9ade6
venkatadri123/Python_Programs
/Codesignal_programs/1add.py
120
3.71875
4
#. Write a function that returns the sum of two numbers. def add(param1, param2): c = param1+param2 return(c)
d3604b7b41e62c1cca3c162d7cbbb5810449f075
venkatadri123/Python_Programs
/100_Basic_Programs/program_41.py
392
3.96875
4
# 41. With a given tuple (1,2,3,4,5,6,7,8,9,10), write a program to print the # first half values in one line and the last half values in one line. def halfval(): fl=[] sl=[] tup=(1,2,3,4,5,6,7,8,9,10) l=len(tup)/2 for i in range(1,int((l)+1)): fl.append(i) for j in range(int(l+1),int(l...
01158919c0c3b66a38f8094fe99d22d9d3f53bed
venkatadri123/Python_Programs
/100_Basic_Programs/program_35.py
322
4.15625
4
# 35. Define a function which can generate a dictionary where the keys are numbers between 1 and 20 # (both included) and the values are square of keys. The function should just print the keys only. def sqrkeys(): d=dict() for i in range(1,21): d[i]=i**2 for k in d: print(k) sqrkeys...
b73338136080e4dda8026e64309e34b67926b464
venkatadri123/Python_Programs
/core_python_programs/prog21.py
120
4.0625
4
# Read the elements from the tuple and display them using for loop. mytpl=(13,20,30,40,50) for i in mytpl: print(i)
22599e6316b2e1eeade05e5d1fca3dac7916fe15
venkatadri123/Python_Programs
/100_Basic_Programs/program_76.py
241
3.90625
4
# 76.Please write a program to output a random number, which is divisible by # 5 and 7, between 0 and 200 inclusive using random module and list comprehension. import random print(random.choice([i for i in range(201) if i%5==0 and i%7==0]))
8ed9e0ff208ad57a5c44d0461bc7f9d4f5ce907a
venkatadri123/Python_Programs
/100_Basic_Programs/program_85.py
157
3.875
4
# 85. Please write a program to print the list after removing even numbers in [5,6,77,45,22,12,24]. li=[5,6,77,45,22,12,24] print([x for x in li if x%2!=0])
34eaa7eb343803aed8077aa0082256046230dcfb
venkatadri123/Python_Programs
/100_Basic_Programs/program_91.py
256
3.75
4
# 91. With two given lists [1,3,6,78,35,55] and [12,24,35,24,88,120,155], # write a program to make a list whose elements are intersection of the above given lists. l1=set([1,3,6,78,35,55]) l2=set([12,24,35,24,88,120,155]) l1 &= l2 li = list(l1) print(li)
bc5117081a9d25c3662a71716194f57b5a46771e
venkatadri123/Python_Programs
/core_python_programs/prog2.py
190
3.921875
4
# To display result of add,sub,mul,div. a=float(input('enter value:')) b=float(input('enter value:')) c=a+b print('sum=',c) c=a-b print('sub=',c) c=a*b print('mul=',c) c=a/b print('div=',c)
b1adffe626fa1a1585012689ec2b1c01925c181c
venkatadri123/Python_Programs
/core_python_programs/prog78.py
334
4.15625
4
# Write a python program to accept values from keyboard and display its transpose. from numpy import* r,c=[int(i) for i in input('enter rows,columns:').split()] arr=zeros((r,c),dtype=int) print('enter the matrix:') for i in range(r): arr[i]=[int(x) for x in input().split()] m=matrix(arr) print('transpose:') print(m...
3625b577e1d82afc31436473149cc7ff1e3ce96c
venkatadri123/Python_Programs
/100_Basic_Programs/program_39.py
318
4.1875
4
# 39. Define a function which can generate a list where the values are square of numbers # between 1 and 20 (both included). Then the function needs to print all values # except the first 5 elements in the list. def sqrlis(): l=[] for i in range(1,20): l.append(i**2) return l[5:] print(sqrlis())
fa7b092a720e7ce46b2007341f4e70de60f8e6ca
venkatadri123/Python_Programs
/100_Basic_Programs/program_69.py
375
4.15625
4
# 69. Please write assert statements to verify that every number in the list [2,4,6,8] is even. l=[2,4,6,8] for i in l: assert i%2==0 # Assertions are simply boolean expressions that checks if the conditions return true or not. # If it is true, the program does nothing and move to the next line of code. # However...
7a26e4bc77d34fd19cf4350c78f4764492d32064
venkatadri123/Python_Programs
/core_python_programs/prog83.py
250
4.25
4
# Retrive only the first letter of each word in a list. words=['hyder','secunder','pune','goa','vellore','jammu'] lst=[] for ch in words: lst.append(ch[0]) print(lst) # To convert into List Comprehension. lst=[ch[0] for ch in words] print(lst)
710af7c61665471765e13c9e73316fb5a16580c5
OrkMartin/Labs-need-work
/lab1/lab2.py
161
3.5
4
x=input() l=list(x) i2=1 mx=max(l) for i in l: if(int(i)!=int(mx)): if (int(i)>int(i2)): mx2=int(i) else: mx2=int(i2) i2=int(i) print(mx2) print()
dc1edd50a486386b3ab7464bef328be9b2a4e67e
imzhangliang/LearningToys
/python/decorator/4.arguDecorator.py
512
3.734375
4
# 参考:https://www.thecodeship.com/patterns/guide-to-python-function-decorators/ # 带参数的修饰器 def tags(tag_name): def tags_decorator(func): def func_wrapper(name): return "<{0}>{1}</{0}>".format(tag_name, func(name)) return func_wrapper return tags_decorator @tags("p") def get_text(name...
82e13a62f99e125e104dc8e2d2dc13f4741e6c44
Teaching-projects/SOE-ProgAlap1-HF-2020-Fmiri08
/008/main.py
312
3.90625
4
x=0.0 y=0.0 ir=input() while ir!="stop": if ir=="forward": y=y+float(input()) if ir=="backward": y=y-float(input()) if ir=="right": x=x+float(input()) if ir=="left": x=x-float(input()) ir=input() print(round(x,2)) print(round(y,2)) origo=((x**2)+(y**2))**(1/2) print(round(origo,2))
14e530c84fedbaaa64eeae87f24fa46549b9a7da
toggame/Python_learn
/第四章/num_to_rmb.py
5,224
3.78125
4
han_list = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'] # 数值转换文本列表 unit_list = ['拾', '佰', '仟'] # 数值单位列表 # 把一个浮点数分解成整数部分和小数部分字符串 # num是需要被分解的浮点数(float) # 返回分解出来的整数部分和小数部分(str) # 第一数组元素是整数部分,第二个数组元素是小数部分 def divide(num): # 将一个浮点数强制类型转换为int类型,即可得到它的整数部分 integer_num = int(num) # 浮点减去整数部分,得到小数部分,小数部分乘以...
e8f50c141e2c193134af053d04e88d63ae175a8d
toggame/Python_learn
/第二章/compare_operator_test.py
908
3.625
4
import time print("5是否大于4:", 5 > 4) # True print('3的4次方是否大于或等于90:', 3 ** 4 >= 90) # False print('20是否大于或等于20.0:', 20 >= 20.0) # True print('5和5.0是否相等:', 5 == 5.0) # True print('5.2%4.1与1.1是否相等:', 5.2 % 4.1 == 1.1) # False 浮点精度将会影响值的对比 print('1和True是否相等:', 1 == True) # True 可以用数值1和True/0和False做对比,但是不建议,使用条件或bool...
a25f6d70039117398ad94e101c189100393d748e
toggame/Python_learn
/第二章/bit_operator_test.py
842
3.9375
4
print(5 & 9) # 1 0b0101 & 0b1001 = 0b0001,Python默认4字节 print(bin(5 & 9)) print(5 | 9) # 13 0b0101 | 0b1001 = 0b1101 print(bin(5 | 9)) a = -5 print(a & 0xff) # 251 print(bin(a)) print(~a) # 4 负数的补码规则:反码(原码除符号位取反)加1 print(bin(~a)) # 0b100 print(~-a) # -6 5→0b0101 取反0b1010 -1→0b1001 原码0b1110 5→0b00000101 取反0b111...
34da97ea1abde74ef4f13ffe4216a23742ea14c9
Simsaris/COM404
/1-basics/week-3-repetition/1-while-loop/5-sum-100/bot.py
179
3.96875
4
print("calculate the sum of the first 100 numbers") count = 1 total = 0 while count <= 100: total+=count #total=total+count# count+=1 print("the total is " + str(total))
bf69b97a50aae1366ad4884ad8fa364320c29458
Simsaris/COM404
/1-basics/week-3-repetition/1-while-loop/3-ascii/bot.py
263
4.0625
4
print("how many bars shoud be charged") ChargeNeeded = int(input()) ChargedBars = 0 while (ChargedBars < ChargeNeeded): ChargedBars+=1 print("charging: " + " █ " * ChargedBars) if (ChargedBars == ChargeNeeded): print("battery is fully charged")
665de3ee810564d1001f10b23e7108f856a4a8eb
sacktock/network_summative
/client.py
10,168
3.609375
4
import socket import sys import json # Client functions def GET_BOARDS(): # construct json message message = '{"request" : "GET_BOARDS"}' while True: # make server request response = server_request(message) if response: # parse json response ...
eb19e8d85ac5e4bf75f173c1984483d440eca8bf
ITLTVPo/SimplePython
/SimplePython/Test-Bai25.py
3,065
3.625
4
def DocSoThanhChu(): a = ["một","hai","ba","bốn","năm","sáu","bảy","tám","chín"] b = ["mốt","hai","ba","tư","lăm","sáu","bảy","tám","chín"] SoAm=False number = int(input("Nhập số bạn muốn chuyển đổi: ")) if (number <0): number = 0-number SoAm =True if (number==0): print("...
770a5461e82cc2e3fda4b42a7224f8badfd20c13
ITLTVPo/SimplePython
/SimplePython/SoNgayTrongThang.py
706
3.6875
4
print("Đếm số ngày trong tháng") def KiemTraNamNhuan(month, NamNhuan): if month in (1,3,5,7,8,10,12): return 31 elif month in (4,6,9,11): return 30 elif NamNhuan==True: return 29 elif NamNhuan==False: return 28 try: while (True): print("-"*30) month ...
a4c2e16bfc899de39d68175be19dba4b33d395ce
ITLTVPo/SimplePython
/SimplePython/VeChuN.py
605
3.8125
4
print("Chương trình vẽ chữ N bằng dấu * với độ cao h") while True: h = int(input("Nhập độ cao h: ")) for i in range(h): for j in range(h): if j==0 or j==i or j==h-1: print("*",end="") else: print(" ",end="") print("",end="\n") print("-"...
3022a1b5402c126eac6d93f065472c21efc23a3a
dhrunlauwers/advent_2020
/day01.py
905
3.78125
4
from typing import List def parse(inputs: List[int]) -> int: """ Checks to find two elements that add up to 2020, and the returns their product. """ deltas = {2020 - i for i in inputs} for i in inputs: if i in deltas: return i * (2020-i) def parse2(inputs: List[int]): ...
516507efc6764f24f12843468fce2919690d2c09
IshitaG-2002IGK/streamlit-jina
/app.py
1,224
3.578125
4
""" pclass = 1|2|3 gender = 'male'=1,'female'=0 age = 1-60 sibsp = 1|0 parch = 1|0 fare = 0-100 embarked = 1|0 """ import business import streamlit as st pclass_list = [1,2,3] gender_list = ['male','female'] gender = 1 pclass = st.selectbox( 'Passenger Class', pclass_list) gender_str = st.selectbox( ...
daea1cb549638923f92a0939fc06687b96e74ef9
Vineeth-Agarwal/FileSortingByNumericField-Northwest
/Sort_By_Numeric_Field.py
1,262
3.921875
4
##### Step0: Open input and output files and create empty lists. input=open("InputFile.txt","r") output=open("OutputFile.txt","w") tupples_array = [] sorted_array = [] ##### Step1: Read each line traditionally(as a String) for line in input: ##### Step2: Break each field in the line separated by comma, into i...
b1c41d7bfbc80bdd15642bcb0f02291c7867779e
ProgrammingForDiscreteMath/20170830-bodhayan
/code.py
700
4.15625
4
# 1 # Replace if-else with try-except in the the example below: def element_of_list(L,i): """ Return the 4th element of ``L`` if it exists, ``None`` otherwise. """ try: return L[i] except IndexError: return None # 2 # Modify to use try-except to return the sum of all numbers in L, ...
d442a0ed9a4a4c5d9a6b94b69ea39bb8ead21a3c
andrSHoi/biosim_G07_sebastian_andreas
/src/biosim/island_class.py
6,174
4.25
4
# -*- coding: utf-8 -*- __author__ = "Sebastian Kihle & Andreas Hoeimyr" __email__ = "sebaskih@nmbu.no & andrehoi@nmbu.no" from .geography import Mountain, Savannah, Jungle, Desert, Ocean, \ OutOfBounds import numpy as np import re class Map: """ The Map class takes a multiline string as input and creat...
350b8d465f906a49e22669171c8eb47fa533383c
zxch3n/Leetcode
/53/main.py
565
3.6875
4
# -*- coding: utf-8 -*- """ @author: Rem @contack: remch183@outlook.com @time: 2017/03/14/ 20:58 """ __author__ = "Rem" class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ max_ans = nums[0] t = nums[0] for i in r...
edc611b56aacab9f4b6602b233ce9f3e759bce16
ahdabalhassani/udacity_project2
/starter_code.py
4,817
3.84375
4
import random moves = ['rock', 'paper', 'scissors'] class Player: def __init__(self): self.score = 0 def move(self): return 'rock' def learn(self, their_move): pass def beats(one, two): return ((one == 'rock' and two == 'scissors') or (one == 'scissors' and two ...
650217c072d3380afd569106d224da0527f4799c
khc-data/advent-of-code-2020
/2020/max/day2/solve.py
1,711
3.921875
4
from collections import namedtuple import re PasswordPolicy = namedtuple('PasswordPolicy', 'lower upper char') PasswordWithPolicy = namedtuple('PasswordWithPolicy', 'password password_policy') def read(): passwords_with_policies = [] with open('input') as input: for line in input: (lower...
6de74047e9f7509207bea000f4dd00268077f239
khc-data/advent-of-code-2020
/2020/max/day12/ferry.py
1,394
3.9375
4
class Ferry: def __init__(self): self.dir = 'E' self.x = 0 self.y = 0 def manhattan(self): return abs(self.x) + abs(self.y) def handle_instruction(self, instruction): self.handle_action(instruction[0], instruction[1]) def handle_action(self, action,...
030214bcbe1123ef751976731feacbd614eca0b2
planetblix/learnpythonthehardway
/ex17a.py
1,230
3.9375
4
#!/bin/python #http://blog.amir.rachum.com/blog/2013/10/10/python-importing/ #using os.path as an example import os import os.path from os.path import exists from os.path import exists, dirname from os.path import * from os.path import exists as here from .os import exists os.path = __import__("os.path") reload(foo) ...
b6834d2bf0af216c26a7a2b92880ab566685caea
planetblix/learnpythonthehardway
/ex16.py
1,436
4.40625
4
#/bin/python from sys import argv script, filename = argv print "We're going to erase %r." % filename print "If you don't want that, hit CTRL-C (^C)." print "If you do want that, hit RETURN." raw_input("?") print "Open the file..." #rw doesn't mean read and write, it just means read! #You could open the file twice...
606294b3e5cf05889729aab4670e9c04c208b98b
wardm5/Data-Structures-and-Algorithms
/Python/Data_Structures/LinkedList/LinkedList.py
1,699
3.875
4
from Data_Structures.Node.Node import * class LinkedList(): # initalize with no value def __init__(self): self.head = None self.count = 0 # initalize with first value def __init__(self, value): self.head = Node(value) self.count = 1 def add(self, value): if...
37808545149f98fdff61b285857b2e63a42fad97
matthewgplace/Projects
/ex5p19MP.py
4,498
3.859375
4
""" Author: Matthew Place Date: December 6, 2017 (Although actually coded sometime in September, I think) Exercise 5.19 part a through part e i. I never got around to e ii. This program simulates light going through a transmission diffraction grating, going through a converging lens, and then hitting a screen. I...
caa1c6539841f07e7acaf8dfc0e5d9d17a972ff7
matthewgplace/Projects
/ex7p1mp.py
1,887
4.0625
4
""" Author: Matthew Place Date: November 7, 2017 Exercise 7.1 This program is designed to calculate the coefficients in the discrete Fourier transforms of a few functions and make a plot of these values """ from __future__ import division from numpy import zeros from cmath import exp, pi, sin from pylab i...
bd225d8181acc7cecb070f5c91a778475d5117d9
ninjafrostpn/PythonProjects
/Writer.py
1,319
3.59375
4
__author__ = 'Charlie' from random import randint as rand text = "" while True: textin = input("Input text for imitation (or @ when done)\n>> ") if textin != "@": text += textin text += " " else: break words = text.split(" ") links = dict() tuples = dict() sanity = int(input("Input...
eb60fc70191ca84f28abc5349263bfbc0702a556
ninjafrostpn/PythonProjects
/BehaviouralEcology/Shoal/CouzinShoal3D.py
10,920
3.6875
4
# Based on Couzin et al. (2002), but as a 2D simulation import pygame from pygame.locals import * import numpy as np from time import sleep debug = False # If True, shows zones of detection and allows their alteration with mouse position # Interface initialisation pygame.init() w = 200 screen = pygame.display.set_mo...
89a4cab84879c77e5ded99c23667abc5daf6154b
ninjafrostpn/PythonProjects
/Neural-Nets/Neural-Net-Tutorial.py
1,578
4
4
# Based on https://iamtrask.github.io/2015/07/12/basic-python-network/ import numpy as np # sigmoid function def sigmoid(x, deriv=False): if deriv: # The derivative of the sigmoid function, for calculating direction/intensity of errors # Here, x is the output of the sigmoid function of the origin...
32b18218321e2250d8f2dbddea7995fabf35d2f9
datnt55/ktpm2013
/Triangle.py
1,109
4.03125
4
def check(a,b,c): if (a < 0) | (b < 0) | (c < 0): print 'Error' else: print 'OK' x = float(raw_input("Please enter an integer: ")) y = float(raw_input("Please enter an integer: ")) z = float(raw_input("Please enter an integer: ")) e = pow(10,-9) while (x < 0)|(y<0)|(z<0): print 'Please enter...
95248b64e89e979c7298ea02ad28f462e602daaa
shanmugapriya98/shanmu
/alphabet_or_not.py
94
3.734375
4
ch = input() if(ch.isalpha() == True) print("Alphabet") else: print("Not an alphabet")
e948cb19f7b3d4c898271cfd956ce3db8a43ba39
shanmugapriya98/shanmu
/hcf_of_two_numbers.py
117
3.84375
4
num1 = int(input()) num2 = int(input()) while(num2 != 0): rem = num1 % num2 num1 = num2 num2 = rem print(num1)
a29a2a9d86f2bb27637275ebe3df713444b0d4d2
rayraysheng/python-challenge
/PyPoll/main.py
4,008
4.03125
4
import os import csv # I've set up a raw data folder and a results folder # The raw data folder will hold the input .csv files # The program will create a summary with each input file # The summary .txt files will be written to the results folder # Work on each file in the input_files folder for filename in os.listdi...
ad04b7264ba1c3cf3486d792afc3c0b1931b5479
geewynn/python_restaurant_simulator
/Menu.py
1,012
3.546875
4
import csv from MenuItem import MenuItem class Menu(object): MENU_ITEM_TYPES = ["Drink", "Appetizer", "Entree", "Dessert"] def __init__(self, filename): self.__menuItemDictionary = {} for t in self.MENU_ITEM_TYPES: self.__menuItemDictionary[t] = [] with open(filename) as f...
978f9bb97e638066dd2540b6c439c5ffdf880efc
yunusaltuntas/MachineLearning
/K Nearest Neighbors/knn.py
2,672
3.671875
4
# K-Nearest Neighbors (K-NN) # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('airbnb_warsaw.csv',sep=';') X = dataset.iloc[:, [7, 9]].values y = dataset.iloc[:, 4].values def PrepareForPrediction(X, y): global X_train,...
b44a6b18c2fb9239c4d2be5ea07bc287b004f1b2
Sher-V/cups
/main.py
3,010
3.578125
4
# время мытья - 10 мин # время тусовки - 5 мин # периодичность захода - 5 мин # количество людей 5-9 # время работы 180 минут # количество чашек в сервизе 40 # Нарисовать график времени работы от количества моющихся чашек, количество чистых чашек, количество грязных чашек import matplotlib.pyplot as plt import random ...
9522b6a465c1644ff8399a838eb3a7fb3b9cbcec
seriouspig/homework_week_01_day_01
/precourse_recap.py
566
4.15625
4
print("Guess the number I'm thinking from 1 to 10, What do you think it is?") guessing = True number_list = [1,2,3,4,5,6,7,8,9,10] import random selected_number = random.choice(number_list) while guessing == True: answer = int(input('Pick a number from 1 to 10: ')) if answer == selected_number: prin...
276f4099bdc847b7c5a92ae909838f063d513a8f
rickhaffey/supply-chain-python
/demand.py
641
3.546875
4
from validation import Validate class Demand: """ Captures all demand-related values. Parameters ---------- quantity : int The amount of demand, in units time_unit : {{'Y', 'M', 'W', 'D'}}, default 'Y' A time unit specifier, representing the period of time over which the `quan...
0fa21bbbb6afa66cd3efe096350b53d2f44670fb
ValS-Itescia/Webtarget
/Liste.py
1,422
3.59375
4
import Read_Write import os # Creation de ma liste et l'affiche liste = ["test@test.fr","test@test.fr","test@orange.fr","test@free.fr"] print(liste) # fonction qui supprime les doublons de ma liste def delete_duplicate(liste): liste = list(set(liste)) return liste # Affichage de ma liste sans dou...
29800604f0b000f1ed4906d51875ab95370a3885
CMPundhir/PandasTutorial
/Ex5.py
448
3.5625
4
import pandas as pd import matplotlib.pyplot as plt # changing index #create a dictionary webDic = {'Day': [1, 2, 3, 4, 5, 6], 'Visitors': [1000, 2000, 200, 400, 10000, 300], 'Bounce_Rate': [20, 20, 23, 15, 10, 43]} #create dataframe df = pd.DataFrame(webDic) print(df) #changing index df2 = df.set_index('Day') print...
a25e94e6f477c54dc1763353db8ffed044016a5e
szhelyabovskiy/tenki
/direction.py
2,683
3.5625
4
import smbus import time import math import RPi.GPIO as GPIO from time import sleep GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(11, GPIO.OUT, initial=GPIO.LOW) #This module receives and converts data from the HMC5883L magnetic sensor that reads off the #direction of the weather vane. #Principle of op...
0bcfdb2184da61297f36591fc3f05da63e573ecb
raghukrishnamoorthy/python-tricks
/cleaner python/underscores_and_dunders.py
846
3.734375
4
# Single _variable means it is private class Testy: def __init__(self): self.foo = 11 self._bar = 12 # Single variable_ can be used if name is a reserved keyword def make_object(item, class_): pass # Double __variable causes name mangling class Test: def __init__(self): self.foo ...
5dfdc7a42d5ee842c648979694a4852c791da6cd
dheaangelina/UG9_A_71210693
/1_A_71210693.py
128
3.640625
4
d = int(input("Masukkan diameter : ")) Keliling = 3.14*d print("Keliling lingkaran adalah : ", str(round((Keliling),2)))
961b6639cb292351bff3d4ded8c366ab0d860ed8
IshaqNiloy/Any-or-All
/main (1).py
980
4.25
4
def is_palindromic_integer(my_list): #Checking if all the integers are positive or not and initializing the variable is_all_positive = all(item >= 0 for item in my_list) #Initializing the variable is_palindrome = False if is_all_positive == True: for item in my_list: #Converting...
5729f4ab552107394ea3066e69e5b23a19b61d4d
Andrey-Dubas/inclusion_analysis
/inclusion_analysis/graph.py
8,605
4.15625
4
class Graph(object): """This class describes directed graph vertices represented by plain numbers directed edges are start with vertex which is index of __vertices vertex the edge goes to is a value within list so, __vertices is "list < list <int> >" vertex is __vertices[*vertex_from*] = list o...
bbd8f07902ff5a1ddc8ca56c3903b096c1a63624
CoderMaik/PokerZen
/src/gamemodes/setups/AmericanSetup.py
1,705
3.671875
4
""" File contains objects used in the dem: Card, deck and player to add modularity access to the attributes is not restricted, they are all public """ class Card(object): def __init__(self, val, suit): self.val = val self.suit = suit def __repr__(self): # This could be done with patte...
da6ad33803ebefe4086699cab7216ab2f16fb677
Ang-Li615/leetcode
/mergeSortedArray.py
843
3.6875
4
class Solution: def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify nums1 in-place instead. """ if m == 0 and n == 0: return None ...
14c52991b7a7a5891a7d2e0d5d2af3512d977c33
Ang-Li615/leetcode
/Number0fSegmentsInAString.py
605
3.65625
4
class Solution: def countSegments(self, s): """ :type s: str :rtype: int """ if len(s) == 0: return 0 while True: if len(s.strip(' ')) < len(s): s = s.strip(' ') continue if len(s.strip(',')) < len(s...
c9b0181161248354a1b1640e84e312bb9a76f9e9
Ang-Li615/leetcode
/validParenthese.py
424
3.65625
4
class Solution: def isValid(self, s): """ :type s: str :rtype: bool """ while True: s1 = s.replace('[]', '') s2 = s1.replace('{}', '') s3 = s2.replace('()', '') if s3 == s: return False else: ...
a252dc283a07445f1250dd55dc4018e4e0c94321
Ang-Li615/leetcode
/letterCasePermutation.py
422
3.578125
4
class Solution: def letterCasePermutation(self, S): L = [''] for char in S: LL = [] if char.isalpha(): for s in L: LL.append(s + char.lower()) LL.append(s + char.upper()) L = LL else: ...
c494273bb1e1bbf5889a81b2eeab8f27e3182a3d
Ang-Li615/leetcode
/convertBST2GT.py
1,530
3.71875
4
# # Definition for a binary tree node. # # class TreeNode: # # def __init__(self, x): # # self.val = x # # self.left = None # # self.right = None # # class Solution: # def convertBST(self, root): # if root == None: # return root # # self.L = [root] # s...
84014b5e5aeb46694ced4cd3b4b95c0e31257433
Ang-Li615/leetcode
/binaryTreeTilt.py
2,076
3.78125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def findTilt(self, root): if root == None: return 0 self.diff = 0 self.subtreeSum(ro...
46be376db7886d6ef3d8bde07178182fb09b4878
Ang-Li615/leetcode
/constructRectangle.py
792
3.90625
4
from math import sqrt class Solution: def constructRectangle(self, area): n = int(sqrt(area)) for i in range(n,area): if area % i == 0: return [i, area//i] # # # # # # # if self.is_prime(area): # return [area,1] # # ...
78ef89950a7376242b9d4897dbd092a6cdfc66b4
Ang-Li615/leetcode
/canPlaceFlowers.py
1,167
3.625
4
class Solution: def canPlaceFlowers(self, flowerbed, n): """ :type flowerbed: List[int] :type n: int :rtype: bool """ l = len(flowerbed) if l == 0: return n <= l if l == 1: if flowerbed[0] == 1: return n <= 0 ...
05079f16b25dcad0a9dc4f8bce823972c0c62ae3
dan-klasson/tic-tac-toe
/views.py
1,157
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class GameView: def intro(self): return '\nTic Tac Toe\n' def newlines(self, amount=1): return '\n' * amount def number_of_players(self): return 'Enter number of players (1-2): ' def number_of_players_error(self): ret...
de3f02e8416760c40ab208ff7ee372313040fcd1
bishal-ghosh900/Python-Practice
/Practice 1/main30.py
992
4.1875
4
# Sieve of Eratosthenes import math; n = int(input()) def findPrimes(n): arr = [1 for i in range(n+1)] arr[0] = 0 arr[1] = 0 for i in range(2, int(math.sqrt(n)) + 1, 1): if arr[i] == 1: j = 2 while j * i <= n: arr[j*i] = 0 j += 1 for i...
2b72be0a06d4a19932b256628b2b2f8b6703cb25
bishal-ghosh900/Python-Practice
/Practice 1/main3.py
262
3.625
4
#String name = "My name is Bishal Ghosh" print(name[0]) # M print(name[-2]) # h print(name[0:5])# My na print(name[1:]) # y name is Bishal Ghosh print(name[:len(name) - 1]) # My name is Bishal Ghos print(name[:]) # My name is Bishal Ghosh print(name[1:-1]) # y name is Bishal Ghos
eaadca4eda12fc7af10c3a6f70437a760c14358f
bishal-ghosh900/Python-Practice
/Practice 1/main9.py
595
4.6875
5
# Logical operator true = True false = False if true and true: print("It is true") # and -> && else: print("It is false") # and -> && # Output --> It is true if true or false: print("It is true") # and -> || else: print("It is false") # and -> || # Output --> It is true if true and not true: ...
460ea4d25a2f8d69e8e009b70cdec588b8ca7b20
bishal-ghosh900/Python-Practice
/Practice 1/main42.py
782
4.28125
4
# set nums = [1, 2, 3, 4, 5] num_set1 = set(nums) print(num_set1) num_set2 = {4, 5, 6, 7, 8} # in set there is not any indexing , so we can't use expression like num_set1[0]. # # Basically set is used to do mathematics set operations #union print(num_set1 | num_set2) # {1, 2, 3, 4, 5, 6, 7, 8} # intersection pr...
8a72ba35bf514fd7ff13479017fa3615eb4766cc
bishal-ghosh900/Python-Practice
/Practice 1/main39.py
301
3.96875
4
# queue from collections import deque list1 = deque([1, 2, 3, 4, 5]); list1.appendleft(10) print(list1) # deque([10, 1, 2, 3, 4, 5]) list1.popleft() print(list1) # deque([1, 2, 3, 4, 5]) list1.append(6) print(list1) # deque([1, 2, 3, 4, 5, 6]) list1.pop() print(list1) # deque([1, 2, 3, 4, 5])
789e675cb561a9c730b86b944a0a80d6c423f475
bishal-ghosh900/Python-Practice
/Practice 1/main50.py
804
4.75
5
# private members # In python there we can prefix any data member with __ (dunder sign) , then it will be private. In reality it don't get private, if we declare any data member with __ , that data member actually get a differet name from python , which is like => _classname__fieldname. So in the below implementation...
ff52754b77c4caeac1d1bcb6d4def097b2f6d0c8
bishal-ghosh900/Python-Practice
/Practice 1/main53.py
416
4.09375
4
# closure # A closure is a function that remembers its outer variables and can access them def multiplier(x): def multiply(y): return x * y return multiply m = multiplier(10)(2) print(m) # 20 # defected way of closure print # def doThis(): # arr = [] # for x in range(1, 4): # arr....
c2c1d70b70f5829bc69f221aaff4f1a79a682ddf
MStevenTowns/Python-1
/Statistics.py
2,060
3.625
4
##M. Steven Towns ##4/29/204 ##Assignment 14 import math def minimum(aList): guess=aList[0] for num in aList: if num<guess: guess=num return guess def maximum(aList): guess=aList[0] for num in aList: if num>guess: guess=num return guess ...
a533862c6545a575a7d932aa33b99aacb4f6bf0b
MStevenTowns/Python-1
/TurtleWalk.py
2,145
3.9375
4
#M. Steven Towns #Assignment 5 #1/20/2014 import turtle, random anne=turtle.Turtle() anne.speed(0) anne.up() anne.setpos(-325,-275) anne.down() anne.forward(650) anne.left(90) anne.forward(275*2) anne.left(90) anne.forward(650) anne.left(90) anne.forward(275*2) anne.up() anne.setpos(5000,5000) fre...
f2b42f7fdbd15e8c9d5343bbd3ff7aca8a8d4099
MStevenTowns/Python-1
/SecretMessage.py
1,508
3.96875
4
# M. Steven Towns #Assignment 8 #2/4/2014 encoder=True while encoder: msg=raw_input('What do you want to encode?: ') shift=int(raw_input('what do you want to shift it by?: '))%26 secret_msg="" for i in range(len(msg)): letter=msg[i] if letter.isalpha(): if letter...
a9bcd41772d6493b67724fc42a519cadd748020d
MStevenTowns/Python-1
/File Fun.py
1,085
3.78125
4
##M. Steven Towns ##Assignment 13 File Fun ##4/1/14 myList=[] name=(raw_input('What is the name of unsorted input file? (Enter for default): ')).strip() if (name==""): name="InputSort" if not name.endswith(".txt"): name+=".txt" f=file(name) for line in f: myList+=[line.strip()] myList.sort() ...
0cad154951e8b14a01edb5a9a2ba9d7bb81e469e
MStevenTowns/Python-1
/List.py
318
4.03125
4
x=[5,23,5,2,32,53] print len(x) print x[1:2:3] #[start:stop:step] step is to get every x values x[3]=234 #can change value in list, not str #listception to call value in the list in list multidimensional array call x[][] print x.sort() #wont work x.sort() #do not use x=x.sort() it kills list print x
53e8b7c26985bf98e7ed93563f0a0e866b353f01
kenshimota/Learning-Python
/learning Class/class_people.py
415
3.890625
4
class People(): name = "" # obtiene el nombre de la persona def getName(self): return self.name # funcion que agrega el nombre de la persona def setName(self, str = ""): if str != "": self.name = str # fabrica el input para obtene el nombre def inputName(self): name_tmp = input("Ingrese su nombre: ...