blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2ab5420425027c8709ac61acbe154185a0654117
pcarvalhor/SCRIPTS-DE-ESTUDO
/SCRIPTS DE ESTUDO/casadecambio.py
625
3.578125
4
print('\033[1;34mSeja bem-vindo ao Carvalho Cambios\033[m') S = float(input('\033[1;31mQuantos reais voce tem?\033[m')) Z = str(input('\033[1;32mQual moeda voce quer comprar?\033[m')).lower() if Z == 'dolar': D = float(5.22) if Z == 'euro': D = float(5.67) if Z == 'libra': D = float(6.52) T = S ...
511caa6a153064077476e4c38bd590d51c362789
MarvinVoV/algorithm-python
/sort/selection_sort.py
334
3.765625
4
def selection_sort(a): """ Selection sort :param a: list :return: list """ if not a or len(a) <= 1: return for i in range(len(a)): p = i for j in range(i + 1, len(a)): if a[j] < a[p]: p = j a[p], a[i] = a[i], a[p] # swap a[p], a[i]...
9fb7143527edda33e84be4a2d044a61431c8789d
SajedNahian/SoftDev2
/listcomp.py
1,254
3.78125
4
UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" LOWERCASE = UPPERCASE.lower() DIGITS = [str(i) for i in range(10)] SPECIAL = "*.!?&#,;:-_" def threshold_checker(password): upper = [char for char in password if char in UPPERCASE] lower = [char for char in password if char in LOWERCASE] numbers = [char for char in...
f6a8f87d5beb592f564d16ea02a21022d86b9b39
vincenttian/Backtesting_Platform
/strategy_random500.py
2,138
3.71875
4
import sqlite3 import math from pprint import pprint import random from security_data import SecurityData from account_manager import AccountManager from account_metrics import AccountMetrics ''' This file sets up a new account for the following trading strategy: Invest a fixed amount (e.g. 100) of fund into 500 rand...
1f15e174430ce0d8cc48bfa57fa75e5ba33588a0
vincenttian/Backtesting_Platform
/account_manager.py
3,516
3.953125
4
import sqlite3 import math from pprint import pprint import random ''' The class AccountManager contains functions to update information in the account and holding table in the database. It supports creation of accounts for new trading strategies. Each entry in the account table represents a stock trading account im...
70e15b366634efea90e939c6c169181510818fdb
Sushantghorpade72/100-days-of-coding-with-python
/Day-03/Day3.4_PizzaOrderCalculator.py
881
4.15625
4
''' Project Name: Pizza Order Author: Sushant Tasks: 1. Ask customer for size of pizza 2. Do they want to add pepperoni? 3. Do they want extra cheese? Given data: Small piza: $15 Medium pizza: $20 Large pizza: $ 25 Pepperoni for Small Pizza: +$2 Pepperoni for medium & large pizza: +$3 Extra cheese ...
049365f444a456bc954e511b09ca6a7c8a2c6868
Sushantghorpade72/100-days-of-coding-with-python
/Day-04-Randomization- and-python-lists/Day4.2_Bank_Roulette.py
278
3.84375
4
''' Project Name: Bank roulette Author: Sushant ''' import random name_str = input("Give me everybody's name, seprated by a comma. ") names = name_str.split(",") person_who_pays = random.choice(names) print(f'{person_who_pays} is going to pay for everyone')
6b07d6ae31b51c376a52628ad09e0c25da64a32b
PCvdScheer/Codewars
/Python/factorial/Kata.py
330
3.9375
4
def factorial(n): if n>12 or 0>n: raise ValueError('Provided value not within set limit (0 to 12)') elif n == 0: return 1 else: mylist = [] for i in range(1,n+1): mylist.append(i) value = 1 for x in mylist: value = value * x re...
962bfd875ae5f4e16a8ce4cbf154d9936fcba550
PCvdScheer/Codewars
/Python/Reverse every other word in the string/Kata.py
307
3.796875
4
import re def reverse_alternate(string): temp = re.sub (' +', ' ', string) temp = temp.split(' ') out = [] for i in range(len(temp)): if (i+1) %2==0: out.append(temp[i][::-1]) else: out.append(temp[i]) out1 = ' '.join(out) return out1.strip()
68eadbb2dd36110990c732586cf67b27067c4084
Long0Amateur/Self-learnPython
/Chapter 3 Numbers/A program that prints out the sine and cosine of the angles ranging from 0 to 345 degrees in 15 degrees increment.py
401
3.9375
4
# A program that prints out the sine and cosine of the angles ranging from 0 to 345 degree in # 15 degrees increments. Each result should be rounded to 4 decimal places. from math import sin, cos, pi for i in range(0,360,15): x = sin((i*pi)/180) # To convert degree to radian, multiplying by pi divided by 18...
0d5f545e7bacef8184a4224ad8e9816989ab6e2e
Long0Amateur/Self-learnPython
/Chapter 2 Loops/Chapter 2 (loops).py
633
4.46875
4
# Example 1 for i in range(5): print('i') print(sep='') #Example 2 print('A') print('B') for i in range (5): print('C') print('D') print('E') print(sep='') #Example 3 print('A') print('B') for i in range (5): print('C') for i in range (5): print('D') print('E') print(sep...
8cb56ab0d210e9f3b146f0c9a778ae33b25d614a
Long0Amateur/Self-learnPython
/Chapter 7 Lists/A programs prints a list of 50 random numbers between 1 and 100 .py
180
3.828125
4
# A program generates a list L of 50 random numbers between 1 and 100 from random import randint L = [] for i in range(50): L.append(randint(1,100)) print(L)
71669b68018642dbf531b2bef3f36e8a677a6634
Long0Amateur/Self-learnPython
/Chapter 8 More with Lists/A program picks 1 name from a list of names (choice).py
168
3.90625
4
# A program picks a name from a list of names from random import choice names = ['Joe','Bob','Sue','Sally'] current_player = choice(names) print(current_player)
ca8c79b60d0858891c593e9bdb34e1b784266715
Long0Amateur/Self-learnPython
/Chapter 4 If statement/Leap year 2.0.py
280
4.03125
4
# Leap year x = eval(input('Enter a year:')) if (x%4) == 0: if(x%100) ==0: if (x%400) == 0: print(x,'Leap year') else: print(x,'Not leap year') else: print(x,'Leap year') else: print(x,'Not leap year')
59b46979b7ed16dbb116246773fa8d75e3d139de
Long0Amateur/Self-learnPython
/Chapter 5 Miscellaneous/review/summing.py
111
3.703125
4
# A program adds up the number from 1 to 100 s = 0 for i in range(1,51): s = s + i print(s)
2f081564ba6182d99df8f9c9d51025eae805ff37
Long0Amateur/Self-learnPython
/Chapter 8 More with Lists/list comprehension/List comprehension IV (join).py
189
3.734375
4
# A program creates a random assortment of 100 letters from random import choice alphabet = 'abcdefghijklmnopqrstuvwxyz' s = ''.join( choice(alphabet) for i in range(100) ) print(s)
db25f02be10a08b3d484a4d7731055f74a62a4aa
Long0Amateur/Self-learnPython
/Chapter 3 Numbers/A program that asks the user to enter an angle in degrees and prints out the sine of that angle.py
200
4.34375
4
# A program that asks the user to enter an angle in degrees and prints out the sine of that angle from math import sin, pi x = eval(input('Enter an angle in degrees:')) print(sin((x*pi)/180))
bfd27b9e904038ac5e7dd11294d61b48f9f5c181
Long0Amateur/Self-learnPython
/Chapter 5 Miscellaneous/review/flag, prime.py
211
3.953125
4
# flag, prime numbers x = eval(input('Enter number:')) flag = 0 for i in range (2,x): if x%i == 0: flag = 1 if flag == 1: print(x,'is not prime') else: print (x,'is prime')
9b4a03cec322c2c28438a0c1df52d36f1dfce769
Long0Amateur/Self-learnPython
/Chapter 5 Miscellaneous/swapping.py
297
4.21875
4
# A program swaps the values of 3 variables # x gets value of y, y gets value of z, and z gets value of x x = 1 y = 2 z = 3 hold = x x = y y = hold hold = y y = z z = hold hold = z z = x z = hold print('Value of x =',x) print('Value of y =',y) print('Value of z =',z)
ce86a8409845bf69ba15d483e589531407b64a91
Long0Amateur/Self-learnPython
/Chapter 7 Lists/problem/6. A program modifies a given list using for loop.py
768
3.96875
4
# A program creating list using a for loop import string # A list consisting of the integers 0 through 49 L = [] for i in range(50): L.append(i) print('A list consisting of the integers 0 through 49:\n',L,'\n') # A list containing the squares of the integers 1 through 50 N = [] for j in range(1,51): ...
4af78f23eafc7a91c42c743535ddffaa8d427d01
Long0Amateur/Self-learnPython
/Chapter 7 Lists/A program prints out two highest and lowest scores in the list.py
397
4.03125
4
# A programs prints out the two largest and two smallest elements of a list # called scores from random import randint scores = [] for i in range(10): scores.append(randint(0,10)) scores.sort() print(scores) print('Two lowest scores:',scores[0],scores[1]) print('Two highest scor...
8ab960a90654477984660a75a051cd02b87e0be5
Long0Amateur/Self-learnPython
/Chapter 3 Numbers/A program that generates and prints 50 randoms integers, each between 3 and 6.py
178
4.15625
4
# A program that generates and prints 50 random integers, each between 3 and 6 from random import randint for i in range (0,50): x = randint(3,6) print(x,end=' ')
a5391be6c639c900c6f7be8e584d515d5d7b56c4
Long0Amateur/Self-learnPython
/Chapter 5 Miscellaneous/Natural logarithm.py
281
3.984375
4
# A program asks user to enter a value n, then compute ln(n) import math e = 2.718 x = eval(input('Enter a number:')) s = 0 for i in range(1,x+1): s = s + 1/i print('The natural logarithm of',x,'is',s) y = math.log(x,e) print('ln(',x,') is',round(y,3))
a70f14120ac4fd6df74ec36b96e55257cad237dc
JayantiTA/UDP-clients-server
/clients.py
1,303
3.515625
4
import socket import sys import threading # function send_message() to send message to the server def send_message(clientSock): # input client's username as identity username = input("Input username: ") # input message and send it to the server while True: message = input() message_sen...
c5107058ef2aebfe562e200daceb118484c4cad9
Carbon2015/Python-002
/week01/Week01_Task01.py
2,608
3.5
4
# 作业一: # 安装并使用 requests、bs4 库,爬取猫眼电影()的前 10 个电影名称、电影类型和上映时间,并以 UTF-8 字符集保存到 csv 格式的文件中。 # 猫眼电影网址: https://maoyan.com/films?showType=3 import requests from bs4 import BeautifulSoup as bs import pandas as pd targetUrl = "https://maoyan.com/films?showType=3" # 增加cookie字段,否则可能去到”验证中心“页面。 header = { "user-agent": "Mo...
8f42e52832e46d28c857ee3d84cd19ae49f00b72
LakshayNagpal/Data-Analyst-Nanodegree
/P6: Intro to Hadoop and MapReduce/reducer_wordcount.py
739
3.546875
4
#!/usr/bin/python import sys current_count = 0 current_word = None # Loop around the data # It will be in the format key\tval # Where key is the store name, val is the sale amount # # All the sales for a particular store will be presented, # then the key will change and we'll be dealing with the next store for line...
e93d8b3bc8ceb3d66066bc1e4585e4e82bd001fd
morrislab/plos-medicine-joint-patterns
/scripts/co_occurrences/summarize_deltas.py
1,179
3.53125
4
""" Summarizes deltas. """ import pandas as pd from click import * from logging import * @command() @option('--input', required=True, help='the CSV file to read deltas from') @option('--output', required=True, help='the CSV file to write summaries to') def main(input, output): basicConfig( level=INFO, ...
6760ca99d0f6ddf708a15c4b409074372558db40
morrislab/plos-medicine-joint-patterns
/scripts/localizations/get_optimal_partial_threshold.py
1,021
3.59375
4
""" Obtains optimal thresholds for partial localization. This threshold is determined by where the most negative slope occurs. """ import pandas as pd from click import * from logging import * @command() @option('--input', required=True, help='the CSV file to read stats from') @option( '--output', required...
2db6ef3327edb52ccd1074d7a2f2b3a46aec8c5d
morrislab/plos-medicine-joint-patterns
/scripts/crosstalk/make_data.py
6,289
3.8125
4
""" Generates data for analyzing distributions of scores among patient groups. Normalizes scores by patient. The end result is that for each patient, scores will be in the range [0, 1] with the highest-scoring factor having a normalized score of 1. """ from click import * from logging import * import janitor as jn i...
fafa60fcff780a161c7889d5d763ecae8dab8849
consbio/parserutils
/parserutils/numbers.py
414
4.03125
4
from math import isnan, isinf def is_number(num, if_bool=False): """ :return: True if num is either an actual number, or an object that converts to one """ if isinstance(num, bool): return if_bool elif isinstance(num, int): return True try: number = float(num) return ...
29251cbc397c958ab2bb023038dca2a6c58aea9a
sabk18/CS_555_GEDCOM
/src/sprint2/story25.py
2,455
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Apr 2 14:00:42 2020 @author: sabkhalid """ #story 25: Unique first names in Family #No more than one child with the same name and birth date should appear in the family #step 1: for each row of FAM, chk for children id. for every unique children id, ch...
e480e4a53659ad7983b6be14b4c06dba1fb00c50
sabk18/CS_555_GEDCOM
/src/sprint3/story41.py
1,532
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Apr 7 22:18:31 2020 @author: sabkhalid """ #story41: include partial dates. 'Only Year ' from datetime import * def partial_date(date): try: date_dt = datetime.strptime(date, '%d %b %Y') #change to datetime Year = date_dt...
23094db9ffde4fff11f92010efe854558bb732de
haraldyy/teaching_turtles
/retangulos_e_quadrados.py
432
3.84375
4
from turtle import * shape("turtle") #Isso vai desenhar uma estrela cinza clara em um fundo azul escuro color("WhiteSmoke") bgcolor("MidnightBlue") def quadrado(): for i in range(4): forward(100) right(90) def retangulo(): for i in range(2): right(90) forward(150) ...
0e41bd56ce0c6b4761aa3bf3f86b181ea7b70697
Tuman1/Web-Lessons
/Python Tutorial_String Formatting.py
1,874
4.28125
4
# Python Tutorial: String Formatting - Advanced Operations for Dicts, Lists, Numbers, and Dates person = {'name':'Jenn', 'age': 23} # WRONG example # Sentence = 'My name is ' + person['name'] + ' and i am ' + str(person['age']) + ' years old.' # print(Sentence) # Sentence = 'My name is {} and i am {} years old.'.fo...
949f77b98a5e36ce0b38ba07937cf73a17120097
dahea-moon/Algorithm
/leetcode/345_Reverse Vowels of a String.py
852
3.671875
4
from unittest import TestCase from typing import List class Solution: def reverseVowels(self, s: str) -> str: vowels = ['a', 'e', 'i', 'o', 'u'] s = list(s) vowel_index = [(idx, char) for idx, char in enumerate(s) if char.lower() in vowels] j = 0 for i in range(len(vowel_ind...
5fa5335a5f6a44d3546c47db3b2718cc4a9634ff
dahea-moon/Algorithm
/leetcode/605_Can Place Flowers.py
1,867
3.703125
4
from unittest import TestCase from typing import List class Solution: def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool: idx = 0 planted = 0 for i in range(n): while idx < len(flowerbed): if flowerbed[idx]: idx += 1 ...
9153885112141bce545f746c8f1aab591766dae1
Invirent/Tugas-Pertemuan-12
/code_penulisan_angka.py
2,031
3.546875
4
import os kata = ['','one ','two ','three ','four ','five ','six ','seven ','eight ','nine '] belasan = ['','eleven ','twelve ','thirteen ','fourteen ','fifthteen ','sixteen ','seventeen ','eighteen ','nineteen '] puluhan = ['','ten ','twenty ','thirty ','fourty ','fifty ','sixty ','seventy ','eighty ','ninety '] d...
39603555694c8d7f1f7bf47daee88f06ec297e99
SusyVenta/Chess
/Utils.py
1,545
3.546875
4
class Utils: def get_current_letter(self, tag_position): return tag_position[0] def get_current_number(self, tag_position): return tag_position[1] def letter_to_number(self, letter): letters_and_numbers = {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "g": 7, "h": 8} retu...
16fc93b40eb0ad8b1b35774e0172315d67b4e46b
koushikd9/Mini_Projects
/Python/RollADice.py
210
3.90625
4
import random while True: choice=input("Do you want to Roll Dice or exit:Y/N").capitalize() if choice=="Y": print(random.randint(1,6)) elif choice=="N": print("Bye") break
b7439c8d91988f6652f6dccf2886ac650db178db
yu5shi8/AtCoder
/ABC_A/ABC171A.py
183
3.65625
4
# -*- coding: utf-8 -*- # A - αlphabet # https://atcoder.jp/contests/abc171/tasks/abc171_a S = input() if S.isupper(): print('A') else: print('a') # 21:00 - 21:02(AC)
aaaaf1539dfaf12e1991144d05f3096958bc19d5
yu5shi8/AtCoder
/ABC_A/ABC046A.py
200
3.515625
4
# -*- coding: utf-8 -*- # A - AtCoDeerくんとペンキ # https://atcoder.jp/contests/abc046/tasks/abc046_a abc = list(map(int, input().split())) count = (len(abc) + len(set(abc))) - 3 print(count)
cc483e1488b21a6666c72989ad9f3be348da652d
yu5shi8/AtCoder
/ABC_A/ABC018A.py
347
3.65625
4
# -*- coding: utf-8 -*- # A - 豆まき # https://atcoder.jp/contests/abc018/tasks/abc018_1 a = [1] + [int(input())] b = [2] + [int(input())] c = [3] + [int(input())] rank = [a, b, c] rank.sort(key=lambda x:-x[1]) for i in range(3): rank[i].append(i+1) rank.sort(key=lambda x:x[0]) for i in range(3): print(rank[i][...
ef83c6b7cebd3095bcd5171043eaa45a7f2baa78
yu5shi8/AtCoder
/ABC_A/ABC006A.py
210
3.71875
4
# -*- coding: utf-8 -*- # A - 世界のFizzBuzz # https://atcoder.jp/contests/abc006/tasks/abc006_1 n = input() if n.count('3') > 0 or int(n) % 3 == 0: print('YES') else: print('NO') # 11:03 - 11:07
5418ae94592bff2e401f03d295adc3c4aaf2bfa1
yu5shi8/AtCoder
/ABC_A/ABC092A.py
431
3.5625
4
# -*- coding: utf-8 -*- # A - Traveling Budget # https://atcoder.jp/contests/abc092/tasks/abc092_a a = int(input()) b = int(input()) c = int(input()) d = int(input()) if a >= b and c >= d: print(b + d) elif a >= b and c < d: print(b + c) elif a < b and c >= d: print(a + d) else: print(a + c) # min()...
bd44ffbfac8714c373eec4a6bb907cf6f32f4aa3
yu5shi8/AtCoder
/ABC_A/ABC073A.py
257
3.96875
4
# -*- coding: utf-8 -*- # A - September 9 # https://atcoder.jp/contests/abc073/tasks/abc073_a n = input() if n[0] == '9' or n[1] == '9': print('Yes') else: print('No') # if n[0] == '9' or n[1] == '9': # ↓ スマートにできる # if '9' in n:
489caf71a3730eb7897cc16629a39715db58022f
yu5shi8/AtCoder
/ARC_A/ARC003A.py
401
3.5625
4
# -*- coding: utf-8 -*- # A - GPA計算 # https://atcoder.jp/contests/arc003/tasks/arc003_1 N = int(input()) r = input() cnt = 0 for i in range(N): if r[i] == 'A': cnt += 4 elif r[i] == 'B': cnt += 3 elif r[i] == 'C': cnt += 2 elif r[i] == 'D': cnt += 1 else: cn...
5f024e8fbf88acb26502a5e6e26b16b1b6a10673
yu5shi8/AtCoder
/ABC_A/ABC088A.py
200
3.5625
4
# -*- coding: utf-8 -*- # A - Infinite Coins # https://atcoder.jp/contests/abc088/tasks/abc088_a n = int(input()) a = int(input()) ans = n % 500 if ans <= a: print('Yes') else: print('No')
f65400b3a60dd75d0674a81523e6cc3eebc9bb2d
JoLartey/data
/app.py
249
3.875
4
print('Hello Notitia-AI C2 Fellow') # The greet function requests the name of the fellow and then welcomes them to the fellowship. def greet(): name = input("Please enter your name\n") print("Welcome to Notitia-AI" + "" + name) greet()
efdccd8d87863e0aaa75ef8c76c9b761bb2dd275
clkadem/Goruntu-Isleme
/intensity_inverse_example.py
1,811
3.515625
4
# intensity transformation # intensity inverse example # gamma correction import os import matplotlib.pyplot as plt import numpy as np print(os.getcwd()) path = "C:\\Users\\Adem\\PycharmProjects\\GörüntüIsleme" file_name_with_path = path + "\pic_1.jpg" print(file_name_with_path) img_0 = plt.imread(file_...
5e1f4a6ef075b0ada1c5e5517f4048f1a259307d
glassnotes/Balthasar
/src/balthasar/curve.py
5,452
3.59375
4
#!/usr/bin/python # -*- coding: utf-8 -*- # # curve.py: A class for curves over finite fields in discrete phase ...
f79f39bfe901c87ae8fdfbaa1b24cbf76bfc20bd
Ngyg520/python--class
/预科/7-12/夜晚作业/字符串方法练习.py
218
3.671875
4
f=open('zfc.txt','r',encoding='utf-8') for line in f: list1=line.split('"') for x in list1: res=x.startswith('h') if res==True: print(x) else: continue f.close()
a90ed1ca6f1dd7e673b8b804b655e510da0dbd87
Ngyg520/python--class
/预科/7-23/函数的参数.py
1,664
3.859375
4
""" 座右铭:路漫漫其修远兮,吾将上下而求索 @project:预科 @author:Mr.Yang @file:函数的参数.PY @ide:PyCharm @time:2018-07-23 09:45:55 """ #1,必备参数(位置参数),实参和形参数量上必须要保持一致 def sum(a,b): c=a+b print(c) sum(1,6) #2,命名关键字参数:通过定义关键字来获取实参的值,与形参的顺序无关. def show(name,age): print('姓名是:%s-年龄是:%s'%(name,age)) show(age=20,name='张三') #3.默认参数 #使用场景...
1da35e52a93c7f856043ad7dd3cfed3741169d14
Ngyg520/python--class
/正课/7-25/高阶函数之filter函数.py
1,253
3.734375
4
""" 座右铭:路漫漫其修远兮,吾将上下而求索 @project:正课 @author:Mr.Yang @file:高阶函数之filter函数.PY @ide:PyCharm @time:2018-07-25 09:22:58 """ #filter():用于对一个序列进行过滤或者筛选. #两个参数:第一个参数:函数,用于设置过滤的内容的逻辑,第二个参数:序列 #返回值也是一个迭代器 #定义一个函数,用于过滤奇偶数 def filter_function(number): return number%2==1 #filter函数会将序列中每一个元素都传递到函数中执行,在函数中返回True或者false的结果,filete...
280d6a67ced86fdb7c8f4004bb891ee7087ad18c
Ngyg520/python--class
/正课第二周/7-30/(重点理解)self对象.py
1,556
4.21875
4
""" 座右铭:路漫漫其修远兮,吾将上下而求索 @project:正课第二周 @author:Mr.Yang @file:self对象.PY @ide:PyCharm @time:2018-07-30 14:04:03 """ class Student(object): def __init__(self,name,age): self.name=name self.age=age # print('self=',self) def show(self): print('调用了show函数') # print('self=',self)...
23b0fbe3cba25c9ef37ddbad2bb345086e63e6be
Ngyg520/python--class
/正课第二周/7-31/对象属性的保护.py
2,251
4.21875
4
""" 座右铭:路漫漫其修远兮,吾将上下而求索 @project:正课第二周 @author:Mr.Yang @file:对象属性的保护.PY @ide:PyCharm @time:2018-07-31 09:26:31 """ #如果有一个对象,当需要对其属性进行修改的时候,有两种方法: #1.对象名.属性名=属性值------------------>直接修改(不安全) #2.对象名.方法名( )--------------------->间接修改 #为了更好的保护属性的安全,也就是不让属性被随意的修改,一般的处理方式: #1,将属性定义为私有属性 #2.添加一个可以调用的方法(函数),通过调用方法来修改属性(还可以在方法中设...
cf28d90ba946d4968a7ed1dc0dc538a93d32dc44
Ngyg520/python--class
/预科/7-11/字典.py
3,791
3.546875
4
#author:yang #字典:也是 python中内置的一种容器类型.字典是可变的,可以对字典进行增删改查的操作. #字典有以下特点: #1,字典是以"键-值"结构来存储数据的,字典照片那个没有索引这个概念,'键':相对于列表中的索引.可以通过键对一个数据进行增删改查. #2,列表中的索引值是唯一的,键也是唯一的,都不允许重复. #3,字典是无序的,'键-值'对的存储没有先后顺序,只需要一个键对应一个值. #声明一个空字典 dict1={} #声明一个非空字典 #键:adc,辅助,打野,中单,上单 #值:uzi,ming,mlxg,小虎,letme dict2={'adc':'uzi','辅助':'ming','打野':'ml...
a62a4f8dfa911c1f3bde259e14efe019c5b7ddc1
Ngyg520/python--class
/预科/7-23/生成器函数.py
1,580
4.125
4
""" 座右铭:路漫漫其修远兮,吾将上下而求索 @project:预科 @author:Mr.Yang @file:生成器函数.PY @ide:PyCharm @time:2018-07-23 14:34:00 """ #生成器函数:当一个函数带有yieid关键字的时候,那么他将不再是一个普通的函数,而是一个生成器generator #yieid和return;这俩个关键字十分的相似,yieid每次只返回一个值,而return则会把最终的结果一次返回 #每当代码执行到yieid的时候就会直接将yieid后面的值返回出,下一次迭代的时候,会从上一次遇到yieid之后的代码开始执行 def test(): list1=[] ...
d5a6aea9ce496970111d058fa130c14d4d318c31
Ngyg520/python--class
/预科/7-11/晚间复习.py
3,317
4.03125
4
#列表,元组,字典 list=[] tuple=(20,1,3,5) dict={} set1=set() #-----------添加数据------------- list.append('李四') print(list) list.insert(0,'张三') print(list) dict['A']='阿罗多姿' print(dict) set1.add(1) print(set1) #---------查询数据------------ name=list[0:2] print(name) name1=list[:] print(name1) name2=list[-1] print(name2) for x in li...
a7b4bb3d047da001a63dbc9560a84a4542d2a8ea
Ngyg520/python--class
/正课第二周/7-31/类的多继承.py
659
3.734375
4
""" 座右铭:路漫漫其修远兮,吾将上下而求索 @project:正课第二周 @author:Mr.Yang @file:类的多继承.PY @ide:PyCharm @time:2018-07-31 16:10:38 """ #定义一个A类 class A(object): def print_test(self): print('A类') class B(object): def print_test(self): print('B类') class C(A,B): def print_test(self): print('C类') #面试题: #在上面多继...
27f8780f3f00118b1d34db5b2c593f2bc802b28f
Ngyg520/python--class
/正课第二周/7-31/类的单继承.py
2,148
3.96875
4
""" 座右铭:路漫漫其修远兮,吾将上下而求索 @project:正课第二周 @author:Mr.Yang @file:类的单继承.PY @ide:PyCharm @time:2018-07-31 15:43:05 """ #面向对象编程的三个基本特征:封装,继承,多态 #函数是封装的最基本单位,而类和对象属于更高级的封装形态,在类中封装用于保存数据,也可以在类中封装函数用于操作数据,不同的功能和逻辑又可以封装成不同的函数 #继承: #继承的优势:可以更好的实现代码的重用 #1.子类可以继承父类,子类会拥有父类中所有的属性,子类不需要重复声明,父类的对象是不能够调用子类的属性和方法的,这种继承属于单项继承 #2.当父类当中的...
b8a2c3747c37ee4d7ad47a35a006009c65639132
Abhishek-Bajpai/hackerrank
/exepy.py
120
3.5625
4
def gcd(a,b): while( b!=0): temp = a a = b b = temp % b return a print(gcd(60, 96))
4aa5b7924d8f7d10a1ec7f7c7b1c1a41a9996665
Lyndondshelton/Cryptographic-System
/Encoder.py
4,935
3.59375
4
import math import numpy as np # # Initialization of the encryption and decryption dictionaries. alpha_encrypt will return the value of a letter, # alpha_decrypt will return the letter associated with a value. # alpha_encrypt = {' ': 0, 'A': 3, 'B': 6, 'C': 9, 'D': 12, 'E': 15, 'F': 18, 'G': 21, 'H': 24, 'I': ...
9e57dbd5a0eb34bd3ed3567b5c83fd2cfed10ebc
Psami-wondah/shiiiiii
/atm shii.py
1,383
3.78125
4
from datetime import datetime now = datetime.now() currentDt = now.strftime("%d/%m/%Y %H:%M:%S") allowedUsers = ['Seyi', 'Sam', 'Love'] allowedPassword = ['passwordSeyi', 'passwordSam', 'passwordLove'] Balance = 0 name = input('What is your name? \n') if name in allowedUsers: password = input('Your password \n') ...
607d083c65f3d595701c5b185fa55e87f4f78cc5
Prasannarajmallipudi/Python_ToT_2019
/gcdnumber.py
314
3.890625
4
#from math import gcd #print(gcd(20, 8)) a = int(input('Please input the First Number:')) b = int(input('Please input the Second Number:')) while b != 0: gcd = b b = a % b a = gcd print(gcd) ''' for i in range(1,b+1): if a % i == 0 and b % i == 0: gcd = i print(gcd)'''
9a303764d51699ab237fe658e66a4e498b57df8c
greg-dry/BlackJack
/blackjack.py
4,943
3.796875
4
import random import math suits = ('Hearts', 'Diamonds', 'Spades', 'Clubs') ranks = ('Ace','Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King') values = {'Ace': 1, 'Two': 2, 'Three': 3, 'Four': 4, 'Five': 5, 'Six': 6, 'Seven': 7, 'Eight': 8, 'Nine': 9, 'Ten': 10, 'Jack': 10, ...
524b33b034b850a6ef1a8bcc9c5f6c321bb76ccb
skydeamon/Pre-Bootcamp-Coding-Challenge
/Task3.py
345
3.765625
4
""" Created on 11/04/2020 @author: SkyCharmingDeamon _Umuzi_ Pre-bootcamp challenges tast 3: functions A function that takes 2 numbers as input. If either of the numbers is 65, OR if the sum of the numbers is 65 then return true. Otherwise return false, """ def function(a,b): return (a == 65 or b ==...
f2f85ec9808c7dedfb4d7d11215aa37e3a5c0de4
AnikaitSahota/Naive-Bayes-classifiers
/Codes/Matrix.py
3,918
4.1875
4
""" Author : Anikait Sahota Status : no error Dated : 21 March 2019 """ def matrix_multiplication(a,b): """ function to multiply matrix a with matrix b -> aXb Arguments: a and b are two dimensional matrices """ if len(a[0])!=len(b): # if number of columns of matrix a == number of rows of matrix b return(Fal...
a86010ff291698cf14382ff1bfd77c3a1aaf3617
kkyoung28/Programming-Python-
/Function2.py
3,547
3.6875
4
#p107~109 import random # def rolling_dice(): # n=random.randint(1, 6) # print("6면 주사위 굴린 결과 : ",n) #1<=n<=6 랜덤수 # def rolling_dice(pip): # n=random.randint(1,pip) # print(pip, "면 주사위 굴린 결과 : ",n) #1<=n<=pip 랜덤 def rolling_dice(pip, repeat): for r in range(1, repeat+1): n = random.randint(1,pip) ...
85012bb061be955cb0e30489928b014f2b3f1053
RussH-code/Forest-Fire-Simulation
/sims.py
19,935
3.53125
4
""" This module contains: simulation(), simulation_combine() and sim_plot(). The simulation and simulation_combine functions run the forest fire simulation. The simulation function only changes one parameter at a time, this is useful for studying the effect of one parameter on the function. The simulation_combine funct...
4724c8dead863938ccb4c7ce4c65a31f29f2363f
LeonKennedy/DataStructureAlgorithm
/Knapsack.py
2,136
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Filename: Knapsack.py # @Author: olenji - lionhe0119@hotmail.com # @Description: 0-1 背包问题 # @Create: 2019-07-10 22:48 # @Last Modified: 2019-07-10 22:48 from copy import copy from typing import List class Knapsack: def __init__(self): self.maxW = 9 ...
7b98b8dd7e3a060af3ed6f3f7a7769fbb65af04e
LeonKennedy/DataStructureAlgorithm
/leetcode/MergeSortedLists.py
1,536
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Filename: MergeSortedLists.py # @Author: olenji - lionhe0119@hotmail.com # @Description: 合并多个有序列表 # https://leetcode.com/problems/merge-k-sorted-lists/ # @Create: 2019-07-20 17:24 # @Last Modified: 2019-07-20 17:24 from typing import List from queue import PriorityQueue...
2cb2346e70db90645b00a7e910c0bf85c691dfff
LeonKennedy/DataStructureAlgorithm
/graph/TopologicalSort.py
1,217
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Filename: TopologicalSort.py # @Author: olenji - lionhe0119@hotmail.com # @Description: # @Create: 2019-08-16 15:39 # @Last Modified: 2019-08-16 15:39 from Graph import AdjacencyMap def topological_sort(graph: AdjacencyMap): incount = dict() queue = list() ...
5840829e5f7c53e2d6416bba1d77ca793d8d62be
LeonKennedy/DataStructureAlgorithm
/leetcode/nqueue.py
2,528
3.78125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Filename: nqueue.py # @Author: olenji - lionhe0119@hotmail.com # @Description: 51. N-Queens # The n-queens puzzle is the problem of # placing n queens on an n×n chessboard # such that no two queens attack each other. # Given an integer n, return all distinct soluti...
ce6179fc4574abb0e25669192dad041088c0ea7b
JustCreature/Py_practice
/practice.py
10,814
4.09375
4
"""This is the list of my practical work of learning OOP. (Uncomment he part of code you want to run)""" """Class and object creation""" # # import random # # class Warrior: # def __init__(self, name): # self.name = name # self.hp = 100 # # def gotHurt(self): # self.hp -= 20 # # # fir...
5d78a0925d11a2978b91d75f298730931692a4cd
nschalla/GUVI_Home
/333.py
120
3.875
4
n=int(input("enter the number")) sum = 0 while (num > 0): sum += int(n % 10) n = int(n / 10) print(sum)
d1771a309ef434261340ad20b2937d96dedd188f
nschalla/GUVI_Home
/555.py
62
3.90625
4
'''reverse the given number''' n=int(input()[::-1]) print(n)
42b32eeaa42d5962f29f4d1235951a38e014dd77
gabrielsgradinar/exercicios-hacker-rank
/introduction/if-else.py
458
3.859375
4
#!/bin/python3 import math import os import random import re import sys if __name__ == '__main__': n = int(input().strip()) def is_even(n): if n % 2 == 0: return True return False if not is_even(n): print("Weird") if is_even(n) and n in range(2, 6): pri...
5470b091b9bd46530850873c488b5598249d3a0b
roger2399/python-practice
/loop_traversal.py
145
3.765625
4
fruit = "banana" index = 0 while len(fruit) > index: letter = fruit[index] print (letter) index += 1
ed6d0b6d1f7240a0e3caba4092c71d7d42b2b8ac
vanman247/Stat-GUI
/Tests/pearson_Coor1.py
1,483
3.59375
4
from scipy.stats import pearsonr from tkinter import * from tkinter import filedialog def main(url = "adult.csv", data1="age", data2="y"): direc="C:/Users/Ammon Van/Desktop/Fun Projects/Statistic Analysis/Tests" filetypes = (("CSV", "*.CSV"), ("All Files", "*.*")) url = filedialog.askopenfilename(ini...
266db82f465a561b52a117fa38cb97ee80aa0d4d
dsssssssss9/pimoroni-pico
/micropython/examples/pico_display/buttons.py
1,998
3.5
4
# This example shows you a simple, non-interrupt way of reading Pico Display's buttons with a loop that checks to see if buttons are pressed. import picodisplay as display import utime # Initialise display with a bytearray display buffer buf = bytearray(display.get_width() * display.get_height() * 2) display.init(buf...
1b81f53332ac9ed7f14bd9d1146d309f92eb3573
seilcho7/algorithm-practice
/algo_3.py
2,075
3.65625
4
# movie theater problem # nCols = 16 # nRows = 11 # col = 5 # row = 3 # affected_column = nCols - (col -1) # affected_rows = nRows - row # affected_peeps = affected_column * affected_rows # print(affected_peeps) # elevator problem # left_elevator = "left" # right_elevator = 'right' # def elevator(left, right, call...
c4c6d1dfddde4594f435a910147ee36b107e87b9
Pakizer/PragmatechFoundationProject
/tasks/7.py
303
4.15625
4
link[https://www.hackerrank.com/challenges/py-if-else/problem] n = input('Bir eded daxil edin :') n=int(n) if n%2==0 and n>0: if n in range(2,5): print('Not Weird') if n in range(6,20): print ('Weird') else: print('Not Weird') else: print('Weird')
f7e9b67df56874a72f9b38844b2e0ced43313850
tothricsaj/dataStructures
/LinkedList/simply/python/main.py
348
3.515625
4
import LinkedList as ll if __name__ == '__main__': print('Hello LinkedList!!!\n') llist = ll.LinkedList() llist.add(1) llist.add(2) llist.add(3) llist.add('What the bloody horse lungs....????') # llist.printAll() llist.shift(0) llist.shift(-1) llist.shift(-2) llist.shif...
3f95d9eb38c10dedc759e9d59c6337dec412f6b0
jjauzion/salesman_problem
/src/population.py
4,710
3.859375
4
# -*-coding:Utf-8 -* import random from src.city import City from src.individual import Individual import src.param as param class Population(): """Class population is a set of Individual""" count = 0 final = 0 def __init__(self, city2travel=None, population_size=None): """Constru...
19e9415ff1883e29e995c0bea242524a1f9bb625
himashugit/python_dsa
/string/List/module/forloop/range.py
230
4.03125
4
# 5 is the stop value and o is the start value print(list(range(5))) # we use list to conver the result in the list format in python3 print(list(range(0,20,2))) # result will be 0,2,4,6..18 so 20-2 will be last number to print
7481502d696c2d5a78261dd7becc48f8a849ca6f
himashugit/python_dsa
/string/join_Center_zerofill.py
204
3.640625
4
x="hello" print("-".join(x)) # center my_str="python" my_Strn1="scripting" my_Str2="lang" print(f'{my_str.center(12)}\n{my_Strn1.center(20)}\n{my_Str2.center(20)}') zero="python" print(zero.zfill(10))
06badb56fb645ab46abc58aae9871c5f913a4bbc
himashugit/python_dsa
/string/List/module/forloop/read_string_printwith_indexvalue.py
994
3.859375
4
''' usr_strng= input("Enter your string: ") index=0 # index var is defined for each_char in usr_strng: print(f' {each_char} -->{index}') index=index+1 # we're increasing index value by 1 ''' import os req_path= input("Enter your dir path: ") if os.path.isfile(req_path): print(f' the {req_path} is a file pl...
3a57aa31606b198a76d98cff001fec94613a18e4
himashugit/python_dsa
/variables/var.py
99
4.0625
4
x = 3 # x is var to store value here y = 5 print(x) myname="himanshu" print(myname,type(myname))
edfd81e4cbd96b77f1666534f7532b0886f8ec4e
himashugit/python_dsa
/func_with_Arg_returnvalues.py
617
4.15625
4
''' def addition(a,b): result = a+b return result # this value we're sending back to main func to print def main(): a = eval(input("Enter your number: ")) b = eval(input("Enter your 2ndnumber: ")) result = addition(a,b) # calling addition func & argument value and storing in result print(f...
38c8fc1d0c52d8d25cb810d8e272961831471ccf
chrisjdavie/compsci_basics
/number_theory/primality_test/naive.py
634
3.578125
4
from math import sqrt from parameterized import parameterized import unittest class Test(unittest.TestCase): @parameterized.expand([ (11, True), (15, False), (1, False), (5, True), (4, False), (49, False) ]) def test(self, target, is_prime_expected): ...
2d92ff696bd8fb26b608b6c50ce5681c12f972bd
chrisjdavie/compsci_basics
/stacks/next_greater_element/heap.py
1,089
3.8125
4
""" Given an array A [ ] having distinct elements, the task is to find the next greater element for each element of the array in order of their appearance in the array. If no such element exists, output -1. https://practice.geeksforgeeks.org/problems/next-larger-element/0 """ from heapq import heappush, heappop from p...
78fbd0e815c8cf689d089a7abcd84576aab9fe32
chrisjdavie/compsci_basics
/dynamic_programming/partition_problem/playing.py
557
3.765625
4
from copy import copy def _rec(arr, n, m): if n < 1: return yield from _rec(arr, n-1, m) for i in range(1,m): arr_loop = copy(arr) arr_loop[n-1] = i yield arr_loop yield from _rec(arr_loop, n-1, m) def main(n, m): arr = [0]*n yield arr yield from _r...
d0d3c2a049951c3c8b4d57ada259ceefd6fd79b4
chrisjdavie/compsci_basics
/dynamic_programming/pick_from_top_or_bottom/memoization.py
1,794
3.609375
4
import unittest from parameterized import parameterized class Test(unittest.TestCase): @parameterized.expand([ ("provided example 0", [5, 3, 7, 10], 15), ("provided example 1", [8, 15, 3, 7], 22), ("one number", [1], 1), ("two numbers highest", [1, 2], 2), ("three numbers",...
f9fea5999edbcad89bc88a0c6ab3d38f238a699f
chrisjdavie/compsci_basics
/sorting_and_searching/key_pair/solve.py
911
3.609375
4
"""Given an array A[] of n numbers and another number x, determine whether or not there exist two elements in A whose sum is exactly x.""" from parameterized import parameterized import unittest class Test(unittest.TestCase): @parameterized.expand([ (16, [1, 4, 45, 6, 10, 8], True), (10, [1, 2, ...
011660b420866fac9fbfd80c72f0924bff71f8c4
chrisjdavie/compsci_basics
/dynamic_programming/subset_sum/recursive.py
785
3.546875
4
import unittest from parameterized import parameterized class Test(unittest.TestCase): @parameterized.expand([ ("provided example", [3, 34, 4, 12, 5, 2], 9, True), ("single value true", [1], 1, True), ("single value false", [1], 2, False), ("three values true", [1, 2, 3], 5, True),...
575f4c1f07957af2be9b688ce5b5333c25d4b441
samcoh/Data-Manipulation
/SQL/hw9_ec1.py
1,379
3.84375
4
import sqlite3 as sqlite import datetime conn = sqlite.connect('Northwind_small.sqlite') cur = conn.cursor() def extra_credit(): statement = 'SELECT CustomerId,OrderDate ' statement += 'FROM [Order] ' statement += 'ORDER BY CustomerId' row = cur.execute(statement) ids = [] print('CustomerID, '+...
08f6dcabed5205513d36aae8ce1bb1f7dbe7baff
egoetz/clustering-analysis
/k_means.py
6,690
3.6875
4
# E Goetz # Basic implementation of the k-means clustering algorithm from clusteringalgorithm import ClusteringAlgorithm from random import uniform from numpy import ndarray, zeros, array_equal class KMeans(ClusteringAlgorithm): def __init__(self, data, answer_key, dimension_minimums=None, dimens...
ce3606b2dd45f71f61953d4e8542384584b733e0
bharathulaprasad/Sentiment-Analysis-on-US-Airlines-Twitter-data
/US Airlines Twitter Sentiment Analysis .py
11,465
3.671875
4
#!/usr/bin/env python # coding: utf-8 # ### Importing the necessary libraries # In[1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns # ### Importing the data # In[2]: data=pd.read_csv("Tweets.csv") data.columns # In[3]: data.head() # In[4]: data.tail() #...
c9361ac9212e8bd0441b05a26940729dd6915861
itsMagondu/python-snippets
/fib.py
921
4.21875
4
#This checks if a certain number num is a number in the fibbonacci sequence. #It loops till the number is the sequence is either greater or equal to the number in the sequence. #Thus we validate if the number is in the fibonacci sequence. import sys tot = sys.stdin.readline().strip() try: tot = int(tot) except V...
389887394ef680275f708fd4e8fc0370e3aafaf2
itsMagondu/python-snippets
/utopia.py
173
3.5
4
doub = True h = 1 cyc = 10 while cyc: if doub == True: h = h*2 doub = False else: h = h+1 doub = True print h cyc = cyc -1