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
46b98996322d857ca70f8e3da744a925c4631013
AbishekNanjappa/MyPythonCode
/first_N_natural_numbers_part_2/utility.py
161
3.546875
4
def first_N_num_2(N): List = [] while N > 0: List.append(N) N -= 1 if N >= 1: List.append("#") return List
996864ee05a2cb1e717cf7d47c16a2e75d8caeb4
AbishekNanjappa/MyPythonCode
/split_num/main.py
141
3.796875
4
import utility N = int(input("Enter a number N:\n")) List = utility.split_num(N) for i in range(len(List)): print(List[i] , end = "")
1ec8deb7b2fff301006755625e314dcd5c15c90b
AbishekNanjappa/MyPythonCode
/sumofpositive/utility_positive.py
256
3.5625
4
def sum_of_positive(n1,n2,n3,n4,n5):#listofint sum = 0 if n1 > 0: sum += n1 if n2 > 0: sum += n2 if n3 > 0: sum += n3 if n4 > 0: sum += n4 if n5 > 0: sum += n5 return sum
2c548121c83ac9f4b27092d94e2210aa997878fd
AbishekNanjappa/MyPythonCode
/leap_year/utility.py
178
3.765625
4
def check_leap_year(year): result = "0000" if year % 4 == 0: result = "Leap year" else: result = "Not a leap year" return result
daffe90c435c2bdab555e1005541136670a064a4
diodores/cook_book
/task_number_3.py
1,591
3.609375
4
import os def select_files(): """Отбирает нужные файлы с директории""" total_list = [] directory_files = os.listdir() for file in directory_files: if file == '1.txt' or file == '2.txt' or file == '3.txt': total_list.append(file) return total_list def sorting_files(total_list):...
3cb5aa83a1f9dc745cef0f953b4bc1883e58c5d5
akyWong114/ics3u-classwork
/coding_practice_2020_11_27.py
847
3.84375
4
# EXAMPLE # 1. from -321 to -188 by 7. i = -321 while i <= -188: print(i) i += 7 #Personal Practice #1. from 207 to 223 by 1 i = 207 while i <= 223: print(i) i += 1 #2. from -87 to 1 by 8 i = -87 while i <= 1: print(i) i += 8 #3. from 14 to 60 by 1 i = 14 while i <= 60: print(i) i += 1 ...
f6be351b86b735d33e78b1a7320d367d80854ad4
EomSunYoung/pyworks
/Day24/file_io/f_read.py
318
3.53125
4
# 파일 읽기 - read() 함수 사용 f = open("c:/pyfile/file.txt", 'r') data = f.read() # 파일 내용을 읽어서 data에 저장 print(data) f.close() f = open("c:/pyfile/number.txt", 'r') data = f.read() print(data) f.close() f = open("c:/pyfile/number2.txt", 'r') data = f.read() print(data) f.close()
4ec82ee06eed049e028652cf51a5780caee86b7c
EomSunYoung/pyworks
/Day32/Trt_Except/Try_Except_else.py
412
3.703125
4
# try ~ except ~ else # 오류가 없을 때는 try ~ else가 실행 # 오류가 있을 때는 try ~ except가 실행 # finally는 항상 실행 : 외부 장치를 초기화, 종료할 때 사용 try: print('1번') with open('animal.txt', 'r') as f: lines = f.readlines() except: print('2번') else: print('3번') for i in lines: print(i, end='') finally: print...
18cb25d05d33a67afe3945913cde2a6039da8fc9
EomSunYoung/pyworks
/Day25/list/listD2_ex.py
691
3.609375
4
d2 = [ [10, 20], [30, 40], [50, 60] ] print("리스트의 크기(행)", len(d2)) print("리스트의 크기(열)", len(d2[0])) print("리스트의 크기(열)", len(d2[1])) print() # 전체 요소 출력 for i in range(len(d2)): for j in range(len(d2[i])): print(d2[i][j], end=' ') print() # 합계와 평균 sum_v = 0 count = 0 for i in range(len(d2)):...
e292ac1c557eca007924ae1f3a49dc23a91c8539
oruizrubio/utilidades
/python/ejemplos/for.py
688
3.875
4
print("Comienzo") for i in [0, 1, 2]: print("Hola ", end="") print() print("Final") print(" ") print("Comienzo") for i in [1, 1, 1]: print("Hola ", end="") print() print("Final") print(" ") print("Comienzo") for i in [3, 4, 5]: print(f"Hola. Ahora i vale {i} y su cuadrado {i ** 2}") print("Fi...
435d334a1bf338e9704878769acab5575b714be4
chelseali2001/CS160-Computer-Science-Orientation
/Assignments/Assignment 8/Assignment8.py
3,643
3.78125
4
def Occurance(a): letters = [] numbers = [] for x in a: for i in x: if i not in letters: letters.append(i) numbers.append(1) else: index = letters.index(i) numbers[index] += 1 ...
52524bd856d95c3e9911ee2ec9d2c71bc47ebc51
jasperhouston/UN_Security_Influence_Net
/HowToVote.py
5,102
4.0625
4
votingRecords = {} infoString = '' keysArray=[] stateVotes={} influence={} numVotes=0 def main(): filename="finaldata.txt" readInData(filename) countVotes() influenceGame() howToVote() def howToVote(): #checks what country is represented by the user yesNo = 'n' while yesNo == ...
8188f56d88b92848a463936f28b36a782236be74
emorycs130r/Spring-2021
/class_11/add_to_matrix.py
678
3.953125
4
def print_matrix(matrix): for i in matrix: for j in i: print(j, end=" ") print() def add_const_matrix(matrix, constant): row_num = len(matrix) column_num = len(matrix[0]) for i in range(row_num): for j in range(column_num): matrix[i][j] = matr...
23bb12b101b6b592334bf78c30e441028ca9da8c
emorycs130r/Spring-2021
/class_7/rock_paper_scissor.py
1,387
4.09375
4
import random def check_input(player_1): ''' 0 -> r 1 -> p 2 -> s ''' value = random.randint(0,3) if player_1 == 'r': if value == 0: return None elif value == 1: return False else: return True elif pla...
7905fd144485c3f503276f4cef396ac541169421
emorycs130r/Spring-2021
/class_10/first_program.py
146
3.53125
4
array_2d = [[1,2,3], [4,5], [6,7,8]] # print(array_2d[1][1]) # print(array_2d[0]) print(array_2d[2]) array_2d[2][2] = 10 print(array_2d[2])
356ad2bf5d602c408dd3c44c2e475c5a8379da0a
emorycs130r/Spring-2021
/class_8/lists_intro.py
454
4.25
4
fruits = ['Apple', 'Strawberry', 'Orange'] # Index = Position - 1 # print(fruits[3]) print(type(fruits)) vegetables = [] print(f"Before adding value: {vegetables}") vegetables.append('Brocolli') print(f"After adding value: {vegetables}") # print(vegetables) fruits.append('Kiwi') print(f"Fruits are: {fruits}") f...
9af404e0faeff67ace5589e05ecb3fdc9c680104
emorycs130r/Spring-2021
/class_6/temperature_conversion.py
662
4.40625
4
''' Step 1: Write 2 functions that converts celsius to farenheit, celsius to kelvin. Step 2: Get an input from user for the celsius value, and f/k for the value to convert it to. Step 3: Based on the input call the right function. ''' def c_to_f(temp): return (9/5) * temp + 32 def c_to_k(temp): return te...
90653fca5369a36f393db2f49b30322080d0a944
emorycs130r/Spring-2021
/class_11/pop_quiz_1.py
458
4.1875
4
''' Create a dictionary from the following list of students with grade: bob - A alice - B+ luke - B eric - C Get input of name from user using the "input()" and use it to display grade. If the name isn't present, display "Student not found" ''' def working_numbers_set(input_list): return list(dict.fromkeys(in...
40d7b2f1a6d4272907075fce63d81d209a9f5953
emorycs130r/Spring-2021
/class_6/nested_ifs.py
285
3.703125
4
age = 19 if_graduated = False has_license = True # Look if person is 18 years or older if age >= 18: print("You're 18 or older. Welcome to adulthood!") if if_graduated: print('Congratulations with your graduation!') if has_license: print('Happy driving!')
8a85073710499424168063a5b01eb3622bd2abd4
Debu381/program
/Python Program/search.py
125
3.90625
4
my_List=["Dipu","Debu","Mitali","Rupali","Soma"] search=input() if search in my_List: print("Yes") else: print("No")
eca8d242839bdac68d85b77891a97a0fd16a5244
kinoshitayua/python_sample
/sample2/sample2.py
784
3.625
4
from menu_item import MenuItem menu_item1 = MenuItem('サンドイッチ', 500) menu_item2 = MenuItem('チョコケーキ', 400) menu_item3 = MenuItem('コーヒー', 300) menu_item4 = MenuItem('オレンジジュース', 200) menu_items = [menu_item1, menu_item2, menu_item3, menu_item4] index = 0 for item in menu_items: print(str(index) + '. ' + i...
3511635c140ff01a97b794e1ae2e074cee6a3e85
LokeshKD/MachineLearning
/ML4SE/DLwithTF/metrics.py
707
3.6875
4
import tensorflow as tf ''' In the backend, we've loaded the logits tensor from the previous chapter's model_layers function. We'll now obtain probabilities from the logits using the sigmoid function. ''' probs = tf.nn.sigmoid(logits) ''' We can calculate label predictions by rounding each probability to the neares...
31172b7f206e9fcfbf64e664952c1f7261da3a8e
LokeshKD/MachineLearning
/ML4SE/numPy/filtering.py
1,698
3.515625
4
import numpy as np ## Filtering arr = np.array([[0, 2, 3], [1, 3, -6], [-3, -2, 1]]) print(repr(arr == 3)) print(repr(arr > 0)) print(repr(arr != 1)) # Negated from the previous step print(repr(~(arr != 1))) arr = np.array([[0, 2, np.nan], [1, np.nan, -6], ...
ee27305ea4a56f2e282de366e26592766e239b7b
anuragpatil94/coursera-python
/Lists/lists1.py
290
3.71875
4
#fname = raw_input("Enter file name: ") fh = open("romeo.txt") lst = list() i=0 for line in fh: line.rstrip() x=line.split() for i in range(len(x)): print x[i] if x[i] not in lst: lst.append(x[i]) #lst.append(x[0]) lst.sort() print lst
c624059e4407f7816e38d6641e5bdb20961cede1
sbalian/aoc2020
/day9/day9.py
1,406
3.75
4
#!/usr/bin/env python def get_numbers(path): with open(path) as f: lines = f.read().strip().split("\n") return [int(line) for line in lines] def find_first_invalid(numbers, preamble_length=5): n = len(numbers) for i in range(preamble_length, n): if not is_valid(numbers, i, preamble_l...
89182b04ae3fe818895a15b51a0b0a25cc833606
sbalian/aoc2020
/day22/day22.py
1,877
3.59375
4
#!/usr/bin/env python import copy def read_input(path): with open(path) as f: player1, player2 = f.read().strip().split("\n\n") player1 = [int(x) for x in player1.split("\n")[1:]] player2 = [int(x) for x in player2.split("\n")[1:]] return player1, player2 def score(player): n = len(pla...
c393eb9ee3b12d4c197ffae7cf8b8dbf4c113cc6
moses-alexander/basic-string-calculator
/basic string calc.py
1,438
3.890625
4
def parse_calc(str): for i in range(len(str)): if str[i]=='+': try: a=int(str[:i]) + int(str[i+1:]) print(int(str[:i])) except ValueError: a="invalid, string cannot be converted to integer." return a if str[...
dcc138709a8fddb4f0c9e4d2ab01afea27c9e761
bklybor/decision_table
/decision_table/decision_table.py
14,884
3.53125
4
#!/usr/bin/env python # coding: utf-8 from tabulate import tabulate class decision_table: """ A generic decision table. There are three prinicple components: 1.) a dictionary of N 'conditions' where each key is a code number for a condition and each value is the function that determines that con...
7147428bcf2710453b8b7360008ffda1a8715aff
Tyler-Applegate/natural-language-processing-exercises
/regex_functions.py
6,917
4.15625
4
# These are my initial regex functions for Natural Language Processing # imports import pandas as pd import re def is_vowel(subject): ''' This function will take in a string and look for an exact match for a single character vowel. It will return a boolean value. ''' # startswith an upper or lowe...
f9d2fe5ec05fc1e9e7a21c23abc99f9f139fb786
Chushenko-AV/Main
/Unit 13. Practical Task.py
2,336
3.78125
4
# Ввод количества билетов, также сообщаю об условии скидки tickets = int(input("При покупке от 4-х билетов действует скидка 10% от стоимости заказа!\n" "Введите количество билетов, которое хотите купить? ")) # Если пользователь ошибся при вводе, сообщаю ему об этом и прошу повторный ввод while ti...
c093846e84340e99f2275705b3c0ce8252a05220
HuangCongQing/DeeCamp
/count.py
505
3.578125
4
# -*- coding: UTF-8 -*- # Filename : test.py # author by : www.runoob.com # 获取用户输入十进制数 print(10**12 + 1) count = 0 for i in range(1, 10 ** 12 + 1): a = str(oct(i) % 10) b = str(oct(i**2) % 10) if a[-1] == b[-1]: conut = count + 1 print(count) print(count) # x = pow(10, 12) # count = 0 # for ...
dbf1a895672ba8cc25d20fdbeb1fa33519dd6ca3
srinidhi136/python-app
/Iteration.py
168
4
4
#the general class of programming constructs that allows the definition of repeatation are called iteration ### num=1 while(num<=5): print(num) num+=1
2dd3b2eef7e3193deb6ff0f915d6abf2cb0a8ac3
srinidhi136/python-app
/SIMPLE_CALCULATOR.PY
826
4.0625
4
#SIMPLE CALCULATOR BY SIMPLE FUNCTIONS def add(x,y): return x + y def sub(x,y): return x - y def mul(x,y): return x * y def div(x,y): return x / y def Mod(x,y): return x%y print("Select the required operations:") print("1.Add") print("2.Sub") print("3.Multiply") print("4.Modulous") ...
8ae4664bc4ec6731a3af7825594acfa1ec1e1913
srinidhi136/python-app
/boolean.py
1,042
4.09375
4
#if conditon statements often called if statements, consist of test or one more options #test is called boolean expression #actions are executed when the test evaluates are true #COMPRESSION : Most common boolean expression are comparison a= 10 b= 20 c= 30 if (a>b): Print("A is bigger than b") else: ...
ad4e7ac40bce0de7f1ad0516a3bb85fba35fd22e
papachristoumarios/codejam-2018
/qualification/cubic_ufo.py
458
3.640625
4
import math as m def rotate(x, y, z, theta): x_ = m.cos(theta) * x - m.sin(theta) * y y_ = m.sin(theta) * x + m.cos(theta) * y z_ = z print x_, y_, z_ return x_, y_, z_ T = int(raw_input()) for t in range(1, T + 1): print "Case #{}:".format(t) A = float(raw_input()) theta = round( m.as...
c0cb66d637c94a99eb4255c5991a2fcc0aae122c
vparjunmohan/Python
/Basics-Part-II/program30.py
513
4.125
4
'''Write a Python program to reverse the digits of a given number and add it to the original, If the sum is not a palindrome repeat this procedure. Note: A palindrome is a word, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar.''' def rev_number(n): while ...
6da942919c4afcaf3e6a219f42c642b4a34761c3
vparjunmohan/Python
/Basics-Part-I/program19.py
334
4.40625
4
'Write a Python program to get a new string from a given string where "Is" has been added to the front. If the given string already begins with "Is" then return the string unchanged.' str = input('Enter a string ') if str[:2] != 'Is': newstr = 'Is' + str print('New string is',newstr) else: print('String un...
64a1544ab385c547d247e493cec609c94b5944e8
vparjunmohan/Python
/Basics-Part-II/program99.py
369
4.03125
4
'Write a Python program to compute the sum of all items of a given array of integers where each integer is multiplied by its index. Return 0 if there is no number.' def sum_index_multiplier(nums): return sum(j*i for i, j in enumerate(nums)) print(sum_index_multiplier([1, 2, 3, 4])) print(sum_index_multiplier([-...
a73d72582cc340a3c517b4f5ecde7a396175b7cc
vparjunmohan/Python
/Basics-Part-I/program150.py
241
4.1875
4
'Python Program for sum of squares of first n natural numbers.' def squaresum() : sm = 0 for i in range(1, n+1): sm = sm + (i * i) return sm n = int(input('Enter a number ')) print('Sum of squares is',squaresum())
55e157e4a5c65734f28ef1a72c3c987732ca8ebc
vparjunmohan/Python
/Basics-Part-I/program7.py
375
4.46875
4
''' Write a Python program to accept a filename from the user and print the extension of that. Sample filename : abc.java Output : java''' filename = input('Enter file name: ') extension = filename.split('.') #split() method returns a list of strings after breaking the given string by the specified separator. print(...
5ba74fcc46711f7c2ce61a3e700579dc8323f775
vparjunmohan/Python
/Basics-Part-I/program24.py
244
4.125
4
'Write a Python program to test whether a passed letter is a vowel or not.' def vowel(): if n in ['a','e','i','o','u']: print(n,'is a vowel') else: print(n,'is not a vowel') n = input('Enter a letter ') vowel()
d0b7813fd8eab20ad85120da19d396259e6778f3
vparjunmohan/Python
/Basics-Part-I/program26.py
356
4.09375
4
'Write a Python program to create a histogram from a given list of integers.' def histogram(): histList = hist.split(" ") for i in histList: output = '' times = int(i) while(times>0): output += '*' times = times -1 print(output) hist = input('Enter numbe...
4ca5203fa26581552aba7b641275bb1e30c0e8f9
vparjunmohan/Python
/Basics-Part-II/program85.py
375
3.890625
4
'Write a Python program to count the number of equal numbers from three given integers.' def test_three_equal(x, y, z): result = set([x, y, z]) if len(result) == 3: return 0 else: return (4 - len(result)) print(test_three_equal(1, 1, 1)) print(test_three_equal(1, 2, 2)) print(test_three_...
162897c560d106004ce319ffffb1fa4ea2472c94
vparjunmohan/Python
/Basics-Part-I/program86.py
147
4.4375
4
'Write a Python program to get the ASCII value of a character.' n = input('Enter a character ') print('ASCII value of {} is {}'.format(n,ord(n)))
b07684fbb0a42f18683a21a8fc4d08abe25c5712
vparjunmohan/Python
/String/program1.py
215
4.15625
4
'Write a Python program to calculate the length of a string.' def strlen(string): length = len(string) print('Length of {} is {}'.format(string, length)) string = input('Enter a string ') strlen(string)
934e0cca5992d269cf87bb86f6dbfe9d04407c4f
vparjunmohan/Python
/Basics-Part-I/program91.py
196
4.1875
4
'Write a Python program to swap two variables.' a = input('Enter value of A ') b = input('Enter value of B ') temp = a a = b b = temp print('Swapped values are A = {}, B = {}'.format(a,b))
b206558992aed8a4b4711787dff8f4933ad1d2ec
vparjunmohan/Python
/Basics-Part-II/program45.py
671
4.15625
4
'''Write a Python program to that reads a date (from 2016/1/1 to 2016/12/31) and prints the day of the date. Jan. 1, 2016, is Friday. Note that 2016 is a leap year. Input: Two integers m and d separated by a single space in a line, m ,d represent the month and the day. Input month and date (separated by a single space)...
2bedeef7980e2d57738adaca5638b245db886972
vparjunmohan/Python
/Basics-Part-II/program36.py
462
3.59375
4
'''Write a Python program which reads an integer n and find the number of combinations of a,b,c and d (0 = a,b,c,d = 9) where (a + b + c + d) will be equal to n. Input: n (1 = n = 50) Input the number(n): 15 Number of combinations: 592''' import itertools print('Input the number(n):') n = int(input()) result = 0 for ...
704f7f23c897141e8d6e137cdd61ee47855507de
vparjunmohan/Python
/String/program23.py
108
3.796875
4
'Write a Python program to remove a newline in Python.' str1 = 'Python\n' print(str1) print(str1.rstrip())
45bffd66b9e16eb2abc018b8c4f74fbab6601b53
aytoldi/python-basic
/if_else/demo1.py
629
3.71875
4
# ئې: شەرتكە ھۈكۈم قىلىش # شەرت ئىپادە قۇرۇلغان دا (true) قوش چىكىت كەينىدىكى كود بۆلىكى ئىجرا بولىدۇ num = 3; if num > 2: print("ok"); def fn(): return 0; # ئې : فونكىسيە fn ئىجرا بولغان دا (0 | 1) ، قوش چىكىت : ئاستىدىكى كود بۆلىكى ئىجرا بولسۇن . # ئې : بولمىسا if بىلەن ئوخشاش باشلنىش نوقتىسدىكى else قو...
f56523f807dc029b3a81038a262ebd7ee5a059f3
aytoldi/python-basic
/var/demo1.py
2,577
3.6875
4
#!/usr/bin/env python # -*- coding:utf-8 -*- #@Time : 2019/12/7 0007 上午 10:51 #@Author: qaytix #@File : demo1.py # ئا: python دا ئۆزگەرگۈچى مىقدار ئىپادىلگەندە ، ئۆزگەرگۈچى مىقدارنىڭ type نى ئىنقلاشنىڭ ھاجىتى يوق x=1; y=1; z=x+y; print(z);#2 # ئې: string تىپدىكى قىممەت ئىنقلاش str="HelloWorld"; print(str);#HelloWorl...
26e6febc3d8ee93be39496e3c05ef6e62def8bac
mandeeppunia2020/python2020
/Day8.py
1,477
4.46875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: Intronduction to tuple datatype: # In[ ]: defination: an immutable list is called tuple: classfication: tuple is classified as an immutable datatype: how to define the tuple:------>() # In[1]: student=('mandeep','punia','muskan','ravi','rohit','prince'...
171ccc0ce6a35d99c4422ad43f76cef2b4ceb9e6
kzlamaniec/Python-Beginnings-2018
/04 - 06 dominanta.py
1,344
3.546875
4
list = [2, 3, 5, 2, 9, 8, 1, 3, 9, 1, 1, 4, 7, 7, 1, 4] n = len(list) def sort(tab): for i in range(n): ost = n - 1 while ost > i: if tab[ost] < tab[ost-1]: zam = tab[ost] tab[ost] = tab[ost - 1] tab[ost - 1] = zam ost -= 1 ...
a9d7c9c929a902226dbfd8332428648bcf8360cd
kzlamaniec/Python-Beginnings-2018
/02 - 07wiek.py
158
3.5
4
wiek = int(input('Ile masz lat?: ')) if wiek >= 18 and wiek <= 120: print('Jesteś osoba dorosłą!') else: print('Nie masz odpowiedniego wieku :(')
31004e8dd5833199d04a459b9fd550accb6f357b
kzlamaniec/Python-Beginnings-2018
/02 - 18iteracje 2.py
107
3.796875
4
i = 6 for x in range(6): g = '*' * x print(g) while i>0: g = '*' * i print(g) i -= 1
79553ee747b2e51b9d1c59617ed7e5cebb1753fd
kzlamaniec/Python-Beginnings-2018
/04 - 11 punkty współlinowe.py
524
3.5
4
print("Wprowadź punkt A: ") xa = int(input("xa: ")) ya = int(input("ya: ")) print("Wprowadź punkt B: ") xb = int(input("xb: ")) yb = int(input("yb: ")) print("Wprowadź punkt c: ") xc = int(input("xc: ")) yc = int(input("yc: ")) tabABC = [[xa,ya,1],[xb,yb,1],[xc,yc,1]] for w in tabABC: print(w) det1 = (xa*yb)...
65ab859bc991f52f141ab4e1ecf9a7a292a737f2
kzlamaniec/Python-Beginnings-2018
/05 - 01.py
69
3.5625
4
x = 1 y = 2 for n in range(5): y += n + x x = x + 1 print(x,y,n)
9fd98544a46dd19cae8ba7a60dc1ff28514320f5
WK-Chen/leetcode
/013.py
696
3.53125
4
class Solution: def romanToInt(self, s: str) -> int: output = 0 dic = {'I': 1, 'V': 5, 'X': 10, 'L':50, 'C':100, 'D':500, 'M':1000, 'IV': 4, 'IX': 9, 'XL': 40, 'XC':90, 'CD':400, 'CM':900} length = len(s) flag = False for i in range(length): ...
32bea2f1d3553ed5696c0f55ede2c74d486821fa
ynikitenko/lena
/lena/context/functions.py
19,715
3.609375
4
"""Functions to work with context (dictionary).""" import copy import lena.core # pylint: disable=invalid-name # d is a good name for dictionary, # used in Python documentation for dict. def contains(d, s): """Check that a dictionary *d* contains a subdictionary defined by a string *s*. True if *d* co...
cd4664b1082e5ed11d41473a83de14bf3e1b0564
ynikitenko/lena
/lena/output/write.py
12,084
3.609375
4
"""Write data to filesystem.""" import os import sys import warnings import lena.context import lena.core import lena.flow def Writer(*args, **kwargs): """ .. deprecated:: 0.4 use :class:`Write`. """ warnings.warn("Writer is deprecated since Lena 0.4. Use Write. In:", Depreca...
a15d40782d4aa5be95e521956b0a925c5f02ce5a
ynikitenko/lena
/lena/math/vector3.py
16,348
4.53125
5
"""*vector3* is a 3-dimensional vector. It supports spherical and cylindrical coordinates and basic vector operations. Initialization, vector addition and scalar multiplication create new vectors: >>> v1 = vector3(0, 1, 2) >>> v2 = vector3(3, 4, 5) >>> v1 + v2 vector3(3, 5, 7) >>> v1 - v2 vector3(-3, -3, -3) >>> 3 * ...
f032912bc2f97bf04e6deb7967ed2805d2093a19
MehrdadBozorg/moujez
/moujez/test_database.py
932
3.796875
4
''' Create database script ''' import sqlite3 conn = sqlite3.connect("log.db") cursor = conn.cursor() cursor.execute(""" CREATE TABLE log ( log_id INTEGER PRIMARY KEY AUTOINCREMENT , submitted_time datatime, title text, source text, summarized_text text, source_...
cc3ddaab88130528113de54d5b75a071c13ad8ce
huisai/Learning-Data-Mining-with-Python
/Python基础教程/Chapter6.py
349
3.71875
4
""" function:介绍函数的一些基本功能 @author: Ethan """ #1-关键字参数:用于解决参数位置的问题 #同时默认参数 #2-收集参数:参数前的星号将所有值放置在同一个元组中 #3-global:声明为全局变量 x = 1 def change_global(): global x x = x + 1 # 此时全局变量x为2 change_global()
64ee10688a1d883bf6da998ee9eebd6c00dca154
sbsdevlec/PythonEx
/Hello/Lecture/Day04/Set/SetEx02.py
615
3.640625
4
""" Set의 연산 수학에서 두개의 집합 간의 연산으로 교집합, 합집합, 차집합이 있는데, set 클래스는 이러한 집합 연산 기능을 제공한다. 즉, a와 b가 set 일 때, 교집합은 a & b (혹은 a.intersection(b)), 합집합은 a | b (혹은 a.union(b)), 차집합은 a - b (혹은 a.differene) 와 같이 구할 수 있다. """ set1 = {1,3,5,7,9} set2 = {1,2,3,4,5} print(set1) print(set2) # 교집합 set3 = set1 & set2 print(set3) ...
bce91af4bc75b6d496b559494c20681d0e7ee160
sbsdevlec/PythonEx
/Hello/DataType/numbersType/Numbers.py
5,324
3.71875
4
''' Numbers ''' """ 파이썬 3는 정수형(integer)과 실수형(floating point number)을 지원합니다. 파이썬은 변수 선언시 타입을 별도로 선언하지 않기 때문에, 정수형인지 실수형인지를 판단하려면 값에 소숫점이 있는지 없는지를 봐야합니다. """ # 타입 검사 print(type(1)) print(type(1.)) print(type(1.0)) print(type(.0)) print("="*50) # isinstance() 함수를 사용하면, # 첫번째 파라미터로 넘겨진 값이나 변수가 두번째 파라미터로 넘겨...
af0958c3448f111592cd86acafe4985c4dbf5620
sbsdevlec/PythonEx
/Hello/Lecture/Turtle/trinket/ex03.py
654
3.546875
4
import turtle t = turtle.Turtle() # 거북이 객체 생성 t.pensize(3) # 펜 크기를 3으로 t.pendown() # 펜을 내린다 (그릴 준비) t.circle(40, steps=3) # 반지름 40인 원을 3번의 직선으로 그린다. = 삼각형 t.penup() # 펜을 올린다. (그리지 않음) t.goto(-100, -50) t.pendown() t.circle(40, steps=4) # 4각형 t.pen...
6b009b97f60bfa87d06cc98cbba4a49040f533f0
sbsdevlec/PythonEx
/Hello/Lecture/Day04/Dictionary (dict)/DictEx02.py
1,082
3.59375
4
# 추가, 수정, 삭제, 읽기 dataMap = {1:('한사람',32),2:('두사람',22)} print(dataMap) # 추가 dataMap[3] = ('세사람',21) dataMap[4] = ('네사람',51) print(dataMap) # 수정 dataMap[3] = ('세사람',35) print(dataMap) dataMap[3] = ('오사람',34) print(dataMap) # 삭제 del dataMap[3] print(dataMap) # 읽기 for key in dataMap: print(key , ":...
2d0156dd261bf6d2bcc5b1add4491421cae18287
sbsdevlec/PythonEx
/Hello/Lecture/Turtle/Ex014.py
182
3.671875
4
import turtle import math line=10 dash=5 for i in range(10): turtle.forward(line) turtle.penup() turtle.forward(dash) turtle.pendown() turtle.exitonclick()
6f6f54e6e1439aadd310a739864001d93088f2ad
sbsdevlec/PythonEx
/Hello/Lecture/Example_wikidocs/Ex019.py
402
4.03125
4
""" 019 문자열 곱하기 변수가 다음과 같이 문자열을 바인딩하고 있을 때 실행 예와 같이 출력하는 프로그램을 작성하라. t1 = 'python' t2 = 'java' 실행 예: python java python java python java python java python java java python java java """ t1 = 'python' t2 = 'java' print( (t1 + " " + t2 + " ") * 4) print( (t1 + " " + (t2 + " ") * 2 + " ") * 2)
f2528b6788a101b3f3f02837bc0f51387b3547c0
sbsdevlec/PythonEx
/Hello/Lecture/Function/functionEx26.py
808
4.03125
4
# 재귀(Recursion)호출 함수 : 자신이 자신을 호출하는 함수 def hanoi(ndisks, startPeg=1, endPeg=3): if ndisks: hanoi(ndisks - 1, startPeg, 6 - startPeg - endPeg) print("{}번기둥의 {}번 원반을 {}번 기둥으로 옮김!".format(startPeg, ndisks, endPeg)) hanoi(ndisks - 1, 6 - startPeg - endPeg, endPeg) hanoi(ndisks=3) def ...
c1570c4e97587da91b7a0d6a77ab1846652866b0
sbsdevlec/PythonEx
/Hello/Lecture/Day02/005. Ex.py
592
4.0625
4
# 입력받아 출력하기 name = input('이름: ') print( name + "씨 방가방가!!") print( name, "씨 방가방가!!") print('Hello ', name, '!') print('Hello ', name, '!', sep='') print('Hello ', name, '!', sep='-') print("{}씨 방가방가!!".format(name)) print("'{0}'씨 방가방가!!".format(name)) print("'{name}'씨 방가방가!!".format(name=name)) print("'{0} {0}...
7c457a18a12c68ef7bfe7080dd0c089c4916f0da
sbsdevlec/PythonEx
/Hello/DataType/Question/1/gugu3.py
169
3.796875
4
for i in range(1,10): #print("** {0:02d}단 **".format(i)) for j in range(1,10): print("{0:3d}*{1:1d}={2:2d}".format(j,i,i*j), end=" ") print()
be5d7f455819de07fa66dfae998dbcbab63ac6fe
sbsdevlec/PythonEx
/Hello/DataType/Question/1/star7.py
260
3.734375
4
height = int(input("몇줄짜리?")) str="" len = 0 # 파이선 삼항연산!!!! # 참 if 조건 else 거짓 for i in range(1,height*2) : len += 1 if i<=height else -1 str += " " * (height - len) + "☆" * (len * 2 - 1) + "\n" print(str)
6c55e617f3ea1279cfe72cb335c7334fe5501c71
sbsdevlec/PythonEx
/Hello/Lecture/Question/1/lotto4.py
285
3.796875
4
import random def lottoGame(): lotto = set() while len(lotto) < 6: lotto.add(random.randrange(1, 46)) s = list(lotto) s.sort() return s gameCount = int(input("몇게임할래?")) for i in range(1,gameCount+1): print(i, lottoGame())
20cf8b29e696480982ef07a54d8fa55db5dea143
sbsdevlec/PythonEx
/Hello/DataType/stringType/strings05.py
1,253
3.90625
4
str="안녕하세요" print("'{0}'".format(str)) print("'{0:30}'".format(str)) # 길이 print("'{0:<30}'".format(str)) # 왼쪽정렬 print("'{0:>30}'".format(str)) # 오른쪽정렬 print("'{0:^30}'".format(str)) # 중앙정렬 print("'{0:*^30}'".format(str)) # 중앙정렬 공백채우기 print("'{0:~<30}'".format(str)) # 왼쪽정렬 공백채우기 print("'{0:^>30}'".format(...
8b68d06119062cf9fbf42d8c44fd327907803103
sbsdevlec/PythonEx
/Hello/Lecture/Function/functionEx24.py
559
3.78125
4
# 람다함수 : 이름이 없는 함수. 1회성 함수를 바로 만들어서 사용한다. # return 구문을 사용할 수 없다. 1줄 실행결과를 바로 리턴함 # lambda 인수들 : 명령문 add = lambda x,y : x+y print(add(3,5)) isEven = lambda x : x%2==0 print( "짝수" if isEven(5) else "홀수") print( "짝수" if isEven(6) else "홀수") isLeapYear = lambda year : year%400==0 or year%4==0 and ...
a70ec19099207c0d8dfc42a54a221e83249ca034
sbsdevlec/PythonEx
/Hello/Lecture/Day04/Set/Example02.py
368
3.53125
4
import random card = list(range(0,52)) print(card) random.shuffle(card) print(card) cardName = ["◆","♠","♥","♣"] cardNumber="1,2,3,4,5,6,7,8,9,10,J,Q,K".split(",") print(cardName) print(cardNumber) cnt=0; for i in card: cnt += 1 print("{0:2d}:{1:1s}{2:2s}".format(i,cardName[i//13],cardNumber[i%13]),...
1673e885185c7622d131f05915844e706878518c
sbsdevlec/PythonEx
/Hello/DataType/listType/sort.py
381
3.703125
4
colors = ["blue", "lavender", "red", "yellow"] print(colors) color2 = sorted(colors, key=lambda color: len(color), reverse=True) print(colors) print(color2) print("*"*30) colors.sort() print(colors) colors.sort(reverse=True) print(colors) colors.sort(key=lambda color: len(color)) print(colors) colors.sort(k...
9be64679a04eee5780a4e25da60f847312cf190a
sbsdevlec/PythonEx
/Hello/DataType/stringType/strings06.py
259
3.984375
4
# 변환 class Data(object): def __str__(self): return 'str한글' def __repr__(self): return 'repr한글' print("{} {}".format(Data(),Data())) print("{!a} {!r}".format(Data(),Data())) print("{!s} {!r}".format(Data(),Data()))
7d9295436a718244bd6f94d780551b4c020a64de
sbsdevlec/PythonEx
/Hello/Lecture/Question/1/randNum1.py
434
3.71875
4
# 1~100사이의 숫자를 몇번에 맞출까요? import random computer = random.randint(1,101) num=0 count=0 while (num!=computer): num = int(input("1~100 사이의 숫자를 입력하세요?")) count += 1 if num<computer: print("입력한 값이 작아요!!!") elif num>computer: print("입력한 값이 커요!!!") print("-"*50) print(count,"번째 마...
634d7bc3b670a9ecd7c5131547202793693d4ef3
sbsdevlec/PythonEx
/Hello/Lecture/Function/functionEx19_1.py
485
4
4
# x = 2 # 함수의 정의 위에 있든 아래에 있든 함수 밖에서 선언하면 전역변수이다. def myFunction1(): print("myFunction1 에서 전역변수 출력", x) x = 2 # 전역변수. 함수에서 사용하려면 호출 전에 선언이 되어있어야 함 print("myFunction1 함수 호출 전", x) myFunction1() # x = 2 # 변수를 선언 전에 사용하면 Error : NameError: name 'x' is not defined print("myFunction1 함수 호출 후", x) print()
90d4a6a8418b369ae23fa5e3cd3c7124e15952aa
sbsdevlec/PythonEx
/Hello/BeautifulSoupEx/File/pickle_ex05.py
592
3.921875
4
import pickle import pprint # 클래스 저장 및 로딩 class Fruits: pass banana = Fruits() banana.color = 'yellow' banana.value = 44 apple = Fruits() apple.color = 'red' apple.value = 55 file_obj1 = open('pickle.class','wb') pickle.dump(banana,file_obj1) pickle.dump(apple,file_obj1) file_obj1.close() f...
58120c422a1036b39aeda32a8fb76f7be67458b6
qqqclark/Python-Foundation-Suda
/苏大上机代码/python_project/03_历年真题期末期中/pat_字符串和数组类/py83_1082.py
472
3.640625
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 29 22:54:06 2020 @author: douzi """ def distance(a, target): return (abs(a[0] - target[0])**2 + abs(a[1] - target[1])**2) def solve(): n = int(input()) stu = [] for i in range(n): data = input().split() stu.append((da...
ac6090cc7fc586781ee853655909008f6beb5195
qqqclark/Python-Foundation-Suda
/苏大上机代码/python_project/03_历年真题期末期中/algorithm/py01_gcd.py
250
3.875
4
# -*- coding: utf-8 -*- num1, num2 = eval(input("请输入两个正整数")) if num1 < num2: num1, num2 = num2, num1 while (num1 % num2): temp = num1 % num2 num1 = num2 num2 = temp print("最大公约数:", num2)
78fdf7437bcab7f85d3a3f5f092b1107d8b4a1e7
qqqclark/Python-Foundation-Suda
/苏大上机代码/python_project/03_历年真题期末期中/RealExercise3/py22_suda_exercise02.py
845
3.90625
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 12 23:20:30 2020 @author: douzi """ import math def is_prime(num): if num < 2: return False top = math.sqrt(num) i = 2 while i <= top: if num % i == 0: return False i = i + 1 return True def Re...
3bc85443d8b3bdf0c45154e66a5739483762c435
qqqclark/Python-Foundation-Suda
/苏大上机代码/python_project/03_历年真题期末期中/algorithm/py19_midterm_07.py
771
3.5
4
# -*- coding: utf-8 -*- # 字母表中字幕出现的次数 >= 单词的字幕出现次数 def contains(charCount, wordCount): print(charCount, wordCount) for key in wordCount.keys(): print(charCount.get(key, 0) , wordCount.get(key)) if charCount.get(key, 0) < wordCount.get(key): return False return True d...
36ffb686cbf8065fa7ee86c678082d920f41e69f
qqqclark/Python-Foundation-Suda
/苏大上机代码/python_project/03_历年真题期末期中/pat_字符串和数组类/py08_1007.py
646
3.8125
4
# -*- coding: utf-8 -*- # 埃氏筛选法 def judge(): n = int(input()) res = 0 is_prime = [True]*(n+1) is_prime[0] = is_prime[1] = True # 筛选出所有素数 primes = [] for i in range(2, n+1): if is_prime[i]: primes.append(i) j = 2*i ...
aa9f679016b46448ed4c2904a1237ab43ed8ea8d
qqqclark/Python-Foundation-Suda
/苏大上机代码/python_project/03_历年真题期末期中/pat_字符串和数组类/py82_1081.py
1,018
3.734375
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 29 19:47:25 2020 @author: douzi """ import re def solve(): n = int(input()) i = 0 for i in range(n): # 密码必须由不少于6个字符组成,并且只能有英文字母、数字和小数点 . ,还必须既有字母也有数字 pwd = input() plen = len(pwd) sign = re.finda...
e8515aed4e5f4fbff514524eb700c1cd7d6a70c6
qqqclark/Python-Foundation-Suda
/上机题目和面试题整理/Python-Foundation-Suda-master/03_本科编程题/04_期末题.py
5,679
3.5
4
# 给定整数m和n,如果m和n都大于1,则判定m和n是否互质,并返回判定结果。 def func1(): # 方法:2~t(t为m,n中较小的数) 分别除m和n,若能同时被除尽则互质。 x, y = eval(input()) if x <= 1 or y <= 1: return # 调整使得x < y if y < x: y, x = x, y temp = 2 while temp<= x: if y%temp == 0 and x%temp==0: # print(temp) # 输...
2a44c3fc54b5dc0d8d9158876544d0e94fee335e
qqqclark/Python-Foundation-Suda
/苏大上机代码/python_project/03_历年真题期末期中/RealExercise2/py02_2005_2.py
846
3.78125
4
# -*- coding: utf-8 -*- # 2005.2 统计篇文章中 各英文字母 的个数,并排序 import re # 读取文章 各英文字母 如: 'test' --> ['t','e', 's','t'] def words(text): return re.findall('[a-z]', text.lower()) # 统计各英文字母的 个数 def train(features): # 存放结果 model = {} for f in features: # 如果 f单词未出现过,默认值为0; # 否则,次数 ...
10b2a83b1a4b513ee9654733ac5a1315a2e7124d
qqqclark/Python-Foundation-Suda
/苏大上机代码/python_project/03_历年真题期末期中/algorithm/py11_midterm3.py
586
3.640625
4
# -*- coding: utf-8 -*- def fun2(lst): length = len(lst) i = 0 j = length - 1 while i < j: while i < j and lst[j] % 2 == 0: # 后面是偶数 j = j - 1 if i < j: t = lst[j] while i < j and lst[i] % 2 == 1: # 前面是奇数 i = i + 1 if ...
f92ac4efe29704947de70826474ea1ca7bf91bb1
qqmb3r/Pycharm
/test.py
632
4
4
def primes(number): if isinstance(number, int) == False: print("This is not an integer, please set another number!") return if number > 1: for i in range(2,number): if (number % i) == 0: print("Number " + str(number) + " is a prime number") ...
9ceecb9dd8d04dd1a9e5e2a0b4992f2a3de3ec70
sathyanarayananan96/5G-SmartphoneSimulation
/5gsystem.py
4,689
3.546875
4
#Main program for 5G system #Import statements: #These statements arer used to interact with the tx and rx class of users 1 and 2. import satscr as user1 import satscr2 as user2 #math library imported for using basic trigonometric functions to be seen below: import math #Radio Access Network- Transmits signal from ...
aeb473760c7c8f4de31882ba769c5ff9d01ef8e4
apolenary20/SecondSem
/Greengrocer.py
997
3.9375
4
import json print("Выберете продукт:") price = dict() price["Tomato"] = 100 price["Cabbage"] = 10 price["Eggplant"] = 200 price["Cucumber"] = 95 price["Avocado"] = 500 price["Carrot"] = 120 price["Pumpkin"] = 100 price["Squash"] = 150 price["Mushroom"] = 100 price["Parsley"] = 10 print(price) a = input() val=0 d = pric...
f33b8eb1d6c9be367cfcc5b72d92ac5ee237ee43
AbhishekKunwar17/pythonexamples
/09 dictionary/example01.py
420
4.03125
4
cities = { 101:"Pune", 102:"Mumbai", 105 : "Delhi", 103:"Chennai" } cities[104]="Bengaluru" cities[103]="Kolkatta" print(cities) # unordered print(cities[102]) #val=cities[109] # KeyError print(cities.get(103, "NIL")) print(cities.get(107, "NIL")) print(104 in cities) print(105 not in cities) for k in citi...
82766d1be42eb006439b91ad42539fc476b11b64
AbhishekKunwar17/pythonexamples
/11 if_elif_else condition/unsolved01.py
279
4.0625
4
Write a python program to check the user input abbreviation. If the user enters "lol", print "laughing out loud". If the user enters "rofl", print "rolling on the floor laughing". If the user enters "lmk", print "let me know". If the user enters "smh", print "shaking my head".
6db0146e39dbf99bf2be7b695b27cb9e0659e226
AbhishekKunwar17/pythonexamples
/decorator/example02.py
162
3.5625
4
def add(val1): return val1 + 10 def sub(val1): return val1 - 10 def job(func,val2): result = func(val2) print(result) job(add,100) job(sub,100)
97cc5bf2f5ebc0790d157a8ad00a2006aa53ca64
AbhishekKunwar17/pythonexamples
/11 if_elif_else condition/unsolved02.py
236
4.21875
4
Write Python code that asks a user how many pizza slices they want. The pizzeria charges Rs 123.00 a slice if user order even number of slices, price per slice is Rs 120.00 Print the total price depending on how many slices user orders.
5f8fdcdf707c62dc58c52a93863c91e0ac989c23
AbhishekKunwar17/pythonexamples
/11 if_elif_else condition/example03.py
383
3.578125
4
var1 = 0 # var1 = 100, 0, -6 if var1: print ("1 - Got a true expression value") print ("var1=",var1) else: print ("1 - Got a false expression value") print ("var1=",var1) var2 = -6 # var1 = 0, 10, 100 if var2: print ("2 - Got a true expression value") print ("var1=",var2) else: print ("2 - Got a f...
8f647d4a921d6db06d9067eba6bd2fd2f5e15d2b
bermuda-ut/under-education-codes
/University_Project_2/header.py
3,878
4.4375
4
''' Author : Ho Suk Lee (Max) Email : maxisbac@gmail.com Last Modified: 10/MAY/15 ''' DIRECTIONS = (UP, RIGHT, DOWN, LEFT) = (0, 1, 2, 3) def get_exit_point(maze): """ get_exit_point takes one argument maze, returns 2-tuple of integers identifying the maze exit point. Assumptions: maze ...