blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
9d30c4e827acb72d6b13932a5d3c8667b6669c96
gergokutu/cs50-python
/try.py
912
4.28125
4
text = input("Your text: ") # pay attention > f (format string) print(f"You typed: {text}") print("You typed: {text}") # order counts > cough() def cough(): print("Cough") for i in range(3): cough() # say no to write anything after the ?s # named argument > end # then use print() to write a new line for i...
false
5151cfe22c6ba893660c49ba006b512c77a74e6b
Suryashish14/Suryashish-Programs
/SpecialCalculator 1.py
2,115
4.25
4
print('::::::::::::::::::::::::::: MENU ::::::::::::::::::::::::::::::::::') print('Press 1 To Check For Armstrong Number') print('Press 2 To Check For Duck Number') print('Press 3 To Check For Perfect Number') print('\t\t\t\t Instructions') print('''1.Provide Only Positive Numbers 2.For Using The Menu Use Only 1...
true
459ad480d62c540f80f0160af4fe6d59478cea54
wear99/Python_Study
/类和实例/类和实例.py
1,860
4.15625
4
# 类是抽象的模板,比如Student类,而实例是根据类创建出来的一个个具体的“对象”, # 每个对象都拥有相同的方法,但各自的数据可能不同。 # 首先要定义类,指定从哪继承 class 学生(object): # 也可以定义类的属性,这样实例就会自动具备这个属性 性别='女' # 定义类的实例有什么属性,定义了之后,再生成实例的时候就必须传入这些参数 def __init__(self, 姓名, 学号, 成绩): self.姓名 = 姓名 self.学号 = 学号 self.成绩 = 成绩 # 数据封装,直接在类里面定义好获得属性的函...
false
3ec8b2046e343d9ef8422f4f83640ad579aa342b
u101022119/NTHU10220PHYS290000
/student/101022105/fibonacci_rec.py
327
4.1875
4
n=float(raw_input("Put n here.")) def fibonacci_rec(n): if n==1: return 1 if n>1: return n+fibonacci_rec(n-1) else: return 0 if fibonacci_rec(n)>0: print fibonacci_rec(n) elif n<0 or type(n)!=int or type(n)!=str: print 'Error, the n given should positive and should be an inte...
false
ab74efe5f6803502cf971679fdce57ebbab0f609
u101022119/NTHU10220PHYS290000
/student/101022171/hw1/satellite.py
366
4.25
4
#File: satellite.py #HW1_EX5_Altitude_of_a_satellite #Due: 3/25/2014 #Author: 101022171 import math G = 6.67 * 10**-11 M = 5.97 * 10**24 R = 6417.0 t = float( input('Enter the period T of the satellite in seconds. >:')) h = ((G*M*t**2)/(4*math.pi**2))**(1.0/3) - R print "The satellite is about %.2f km above the Ea...
false
034c084055637a5c567c8c6b25e6ccd6c25a302e
u101022119/NTHU10220PHYS290000
/student/100021216/myclass.py
734
4.125
4
import copy import math class point(object): '''Represents a point in 2-D space.''' class rectangle(object): """ Represents a rectangle. attributes: width, height, corner. """ a=point() a.x=0.0 a.y=0.0 b=point() b.x=3.0 b.y=4.0 box=rectangle() box.width=100.0 box.height=200.0 box.corner=point()...
true
73a465b867ac3d51f2319dabc02c8581084e6cf7
u101022119/NTHU10220PHYS290000
/student/100022223/is_triangle.py
207
4.125
4
def is_triangle(a,b,c): if (a+b)>c and(a+c)>b and(b+c)>a: print 'Yes' else: print 'No' x=float(raw_input('x:')) y=float(raw_input('y:')) z=float(raw_input('z:')) is_triangle(x,y,z)
false
b411dacd5547dc23c890717b6be2f31f01c0ed59
u101022119/NTHU10220PHYS290000
/student/101022139/convert polar.py
289
4.28125
4
import math x=float(raw_input('enter the value of the x coordinate:')) y=float(raw_input('enter the value of the y coordinate:')) r=math.sqrt(x**2+y**2) theta=math.atan(y/x)*180/math.pi print 'the corresponding polar coordinates (r,theta) is:','(',r,',',theta,')','theta given in degrees'
false
8a6188201bbbb2991472cac385ad33da1197df12
u101022119/NTHU10220PHYS290000
/student/101022122/hw1/fibonacci series.py
580
4.1875
4
n=input('enter the fibonacci number:') def fi(n): if n<0: pass elif not isinstance(n,int): pass else: if n==1: return 1 elif n==2: return 1 else: return fi(n-1)+fi(n-2) def print_fi(n): f1=1 f2=1 if n<0: print ...
false
a856fb36597912de35ac0cbce90aadb781d63599
bria051/Game
/Tic_tac_toe/choose.py
345
4.21875
4
def choosing(): print("Choose O or X to play the Game:") while (True): user = input() if (user == 'O'): computer = 'X' break elif (user == 'X'): computer = 'O' break else: print("You chose the wrong one. Choose again") ...
true
881c561f1e8ca930a70a4c7a35be7df48b8bbc04
jiuash/python-lessons-cny
/code-exercises-etc/section_04_(lists)/ajm.lists01_attendees.20170218.py
983
4.125
4
##things = [] ##print things attendees = ['Alison', 'Belen', 'Rebecca', 'Nura'] #print attendees print attendees[0] ##name = 'Alison' ##print name[0] print attendees[1:3] print attendees[:3] #print attendees[4] #print len(attendees) number_of_attendees = len(attendees) print number_of_attendees attendees.append(...
true
495f7f47477d142d149095c3c84906575ab22bdd
Austin306/Python-Assessment
/prob2.py
704
4.3125
4
def comparator( tupleElem ) : '''This function returns last element of tuple''' return tupleElem[1] def main(): '''This function takes the tuple as input and sorts it''' final_list = [] lines = input('Enter the list of tuples separated by , : ') for tup in lines.split('),('):#This For Loop is us...
true
3e0ddfa7513c609ecbc2c87604767f846ea6d1b8
karanchavan26/math-operation-using-python
/Quadratic_Equation.py
475
4.125
4
#FINDING THE ROOT OF ax^2+bx+c=0 import cmath a=int(input('ENTER coeffient of x^2 : ')) b=int(input('ENTER coeffient of x : ')) c=int(input('ENTER coeffient of 1 : ')) ''' To find the value of x following is the formula, x=( -b +ro- sqrt(b^2 - 4ac))/(2*a) ''' # (b^2 - 4ac) z=(b*b)-(4*a*c) # s...
false
bcf6cc01615591b36df9c3822ae51821c684d6ff
nicholaskarlson/Object-Oriented-Programming-in-Python
/off day.py
2,170
4.125
4
# creating a class of my class. class Science: form ="c" num_student=0 def __init__(self,name,college_num,fav_sub): self.name=name self.college_num=college_num self.fav_sub=fav_sub Science.num_student+=1 def introduce(self): print(f"Hey! I am {self.name}.My...
true
83871c85a545012e93680ba23a0e61caf02e40a4
dapazjunior/ifpi-ads-algoritmos2020
/Iteracoes/Fabio_03/f3_q14_maior_quadrado.py
205
4.125
4
def main(): n = int(input('Digite um número: ')) num = 0 while (num ** 2) <= n: maior_quadrado = num ** 2 num += 1 print(f'Maior quadrado: ', maior_quadrado) main()
false
537a10b2964afb6cbecdce161536769f24eb410f
sokuro/PythonBFH
/03_Exercises/Stings/06_SplitStringDelimiter.py
278
4.28125
4
""" split a string on the last occurrence of the delimiter """ str_input = input('Enter a String: ') # create a list from the string temp_list = list(str_input) int_input = int(input('Enter a Number of split Characters: ')) print(str(temp_list).rsplit(',', int_input))
true
3fc66aa0b3bde5ee6a7d3bafdeb6bab46f0c926e
sokuro/PythonBFH
/01_Fundamentals/Strings/Exercises/04_IsString.py
344
4.40625
4
""" 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. """ def IsString(str): if len(str) >= 2 and str[:2] == 'Is': return str else: return 'Is' + str print(IsString("Testing")) print...
true
c8c32cfec48b1307d4b5156bbe8881d0303063d0
sokuro/PythonBFH
/01_Fundamentals/Lists/Lists.py
477
4.125
4
""" * Lists are MUTABLE ordered sequence of items * Lists may be of different type * [] brackets * Expressions separated by a comma """ list1 = [1, 2.14, 'test'] list2 = [42] list3 = [] # empty list list4 = list() # empty list # ERROR # list5 = list(1, 2, 3) # Solving list6 = list((1, 2, 3)) # List out o...
true
286f659c944c2744440dcdf9b3ffba55d4e4b1c1
sokuro/PythonBFH
/01_Fundamentals/Sort/01_Sort.py
414
4.21875
4
""" sort(...) L.sort(key=None, reverse=False) """ # List of Names names = ["Karol", "Rebeca", "Daniel", "Michael", "Patrik", "Richard"] # sort alphabetically names.sort() print(names) # sort reversed names.sort(reverse=True) print(names) # Tuple of Names names_tuple = ("Karol", "Rebeca", "Daniel", ...
true
4e8ad1365031a9051b83c439396cea43aa5b6d3a
igorgabrig/AprendizadoPython---curso-em-video
/Mundo03/desafios/Desafios Funcao/desafio104.py
522
4.1875
4
# Crie um programa que tenha a função leiaInt(), que vai funcionar de forma semelhante # 'a função input() do Python, só que fazendo a validação para aceitar apenas um valor numérico. # Ex: n = leiaInt('Digite um n: ') def leiaInt(msg): while True: num = str(input(msg)) if num.isnumeric(): ...
false
da46590dcb44a879d75f9ebe34eeb043545760c8
nithin-kumar/urban-waffle
/LucidProgramming/paranthesis_balance_stack.py
551
4.15625
4
from stack import Stack def is_balanced(expression): stack = Stack() for item in expression: if item in ['(', '[', '{']: stack.push(item) else: if is_matching_paranthesis(stack.peek(), item): stack.pop() else: return False if not stack.is_empty(): return False return True def is_matching_p...
true
abcbb6f7a02de5de2d19df7a96a2fa018d2d1985
nithin-kumar/urban-waffle
/InterviewCake/max_product_3.py
699
4.125
4
import math def highest_product_of_3(list_of_ints): # Calculate the highest product of three numbers if len(list_of_ints) < 3: raise Exception return window = [list_of_ints[0], list_of_ints[1], list_of_ints[2]] min_number = min(window) min_index = window.index(min_number) prod =...
true
a8798d0623136431334ef7e791b6b5cd2a81e187
nachobh/python_calculator
/main.py
1,064
4.1875
4
def compute(number1, operation, number2): if is_number(number1) and "+-*/^".__contains__(operation) and is_number(number2): result = 0 if operation == "+": result = float(number1) + float(number2) elif operation == "-": result = float(number1) - float(number2) ...
true
0a217be052ad34e326b15008bf02dcf4a54fa27b
gilgameshzzz/learn
/day4-循环和分支/04-while循环.py
738
4.25
4
# while 循环 """ while 条件语句: 循环体 while :关键字 条件语句:结果是True,或者False 循环体:重复执行的代码段 执行过程:判断条件语句是否为True,如果为True就执行循环体,执行完循环体在判断条件语句是否True, 如果为True,再次执行循环体,直到条件语句的值为False,循环结束,直接执行其他语句。 注意:如果条件语句的结果一直都是True,就会造成死循环。在循环体中要有可以让循环结束的操作。 Python 中没有do-while循环 """ # 使用while循环计算1+2+。。+100 x=1;a=0 while x<=100: a+=x x+=1 print(a) ...
false
a045cd2a100ac535a1ce498f282c9c0b9fb5a80f
gilgameshzzz/learn
/day7Python管理系统/03-函数参数.py
1,394
4.46875
4
""" 参数的作用:从函数的外面给函数传值 """ # 1、位置参数 """ 传参数的时候,实参按顺序给形参赋值 """ # 2、关键字参数 """ 调用函数的时候: 函数名(参数=值) """ def func1(a, b, c): print(a, b, c) func1(10, 20, 30) func1(b=20, a=10, c=30) # 说明:位置参数和关键字参数可以混着来 # 3、参数的默认值 """Python中函数的参数可以设置默认值,有默认值的 参数必须放在参数列表的最后 调用参数有默认值的函数,有默认值的参数可以传参也可以不传参 """ def func2 (a, b, c=100): ...
false
5531f81e5a293246c451eec8e6dff1bb005b1b5d
gilgameshzzz/learn
/day6Python字典/day6-字典/dict/04-集合.py
2,419
4.25
4
"""__author__ = 余婷""" """ 集合(set)也是一种容器类型的数据类型(序列);数据放在{}中,多个之间只用逗号隔开:{1, 2, 'a'} 集合是无序的(不能通过索引取取值), 可变(可以增删改), 元素不能重复 集合可以进行数学中集合相关的操作:判断是否包含,求交集、并集、差集、补集 """ # 1.怎么声明集合 """a.声明一个变量,赋一个集合值""" set0 = set() # 创建一个空的集合 set1 = {1, 2, 3, 2, 2} print(set1, type(set1)) """b.将其他的数据转换成集合""" set2 = set('abc1233h') # 将其他数据转...
false
c64ba5ea1bb599384e763e95e123b638aa5e3733
gilgameshzzz/learn
/day5Python/03-列表.py
1,642
4.1875
4
""" 列表、字典、元组、集合都是序列,都是容器类型的数据类型 列表(list):用来存储多个数据的一种数据类型。里面存储的单个数据,叫元素 特点1、有序的 2、可变的(可变指容器中的内容的个数和值可变) 3、元素可以是任何类型的数据 列表的值:用[]将列表中的元素括起来,多个元素之间用逗号隔开。[] -->空列表 """ # 1、怎么声明一个列表 """1、声明一个变量,赋一个列表值""" list1 = [] print(type(list1)) """2、将其他的数据类型转换成列表""" list2 = list('police') print(list2) list3 = list(i*2 for i in rang...
false
1f5d440084e02fe88bce3a547e56a7c0a83f5e29
gilgameshzzz/learn
/day12Python面向对象/day12-面向对象基础/object/05-对象属性的增删改查.py
2,608
4.5
4
"""__author__ = 余婷""" class Dog: """狗类""" def __init__(self, age=0, color='yellow'): self.age = age self.color = color if __name__ == '__main__': dog1 = Dog(3,'white') # 1.查(获取属性) """ 方法一:对象.属性 (如果属性不存在,会报错) 方法二:对象.__getattribute__(属性名) 和 getattr(对象, 属性名, 默认值) """ ...
false
86485d9d6f8634e1e1b7cba487180bb6f86441d1
Mixiz/python_study
/lesson_3/task_2.py
1,099
4.5
4
# Запросим у пользователя данные и передадим их в функцию как именованные аргументы. Вывод в одну строку def print_user_data(name, surname, birth_place, birth_date, email, phone_number): print(f'Пользователь {name} {surname} родился {birth_date} в населенном пункте {birth_place}. ' f'Вы можете написать ...
false
b10dfdb063283012974f58deb9f5baf5711570bf
skhortiuk/python_course
/lab_5/main_3.py
803
4.1875
4
#! /usr/bin/python3 # -*-coding: utf-8-*- import random def human_win(human_move_id, computer_move_id): if human_move_id == computer_move_id: return "Draw" elif human_move_id == 0 and computer_move_id == 2: return "YOU WIN!!!!!!!" elif human_move_id > computer_move_id and human_move_id !=...
false
2b9d4c7bd4d01cd5c5547dd5b0bd45a206afe19f
nopomi/hy-data-analysis-python-2019
/hy-data-analysis-with-python-2020/part01-e16_transform/src/transform.py
393
4.125
4
#!/usr/bin/env python3 def transform(s1, s2): #convert to list of integers s1_int = map(int, s1.split()) s2_int = map(int, s2.split()) #multiplicate elements and add to one list zipped = zip(s1_int, s2_int) L = [] for i in zipped: L.append(i[0]*i[1]) return L def main(): pr...
false
324a22534f107a044d7b9d7b40bfd1fd19624df3
nopomi/hy-data-analysis-python-2019
/hy-data-analysis-with-python-2020/part01-e13_reverse_dictionary/src/reverse_dictionary.py
462
4.375
4
#!/usr/bin/env python3 def reverse_dictionary(d): reversed = {} for key in d.keys(): for fin in d[key]: if fin in reversed.keys(): reversed[fin].append(key) else: reversed[fin] = [key] return reversed def main(): d={'move': ['liikuttaa'],...
false
17f8beb9bb16ad49e62d0f4637d99862c3169bc5
YiddishKop/python_simple_study
/OO/interface_absmethods_overriding.py
2,335
4.3125
4
""" python 想使用接口或是抽象类, 要比 java 多做一些工作, 需要引入 abc 包中的 ABCMeta 函数和 abstractmethod 标签 """ # [知识点] # 想使用接口/抽象类等定义,必须引入这个包 from abc import ABCMeta, abstractmethod # Interface class Shape(object): # [知识点] # 当你希望把这个类声明为接口or抽象类,并且其中的两个函数必须被 # 子类实现的时候,就必须在该类中 # 1. 声明 __metaclass__ 字段为 ABCMeta # 2. 抽象函数头添加...
false
a1b1b2983bf4721f26de6b1cf85468509703bc46
SjorsVanGelderen/Graduation
/python_3/features/classes.py
1,010
4.125
4
"""Classes example Copyright 2016, Sjors van Gelderen """ from enum import Enum # Enumeration for different book editions class Edition(Enum): hardcover = 0 paperback = 1 # Simple class for a book class Book: def __init__(self, _title, _author, _edition): self.title = _title self.author =...
true
23c0d628cf4eb3c0b347c149a1c90e89eb159866
BohdanHamulets/LearnPython3
/ThinkPython/newfile1.py
2,816
4.125
4
#!/usr/bin/env python3 import time import turtle # some_text = input("What fo you want to print?\n") def print_user(some_text): if len(some_text) > 0: print(">>> ", some_text) else: pass # print_user(some_text) def my_get_time(): seconds = time.time() days = 60 * 60 * 24 days_...
false
6a33fc24a8ebcbae955ef6e91e6cd5f6d918596c
ankit1765/Hangman-and-other-fundamental-programs
/HIghScores.py
700
4.15625
4
#This program asks is a high score displayer. #It asks the user how many entries they would like to input #and how many top scores it should display scores = [] numentries = int(raw_input("How many entries would you like to Enter? ")) numtop = int(raw_input("How many top scores would you like to display? ")) count =...
true
c838d8701727936b9b7134468b879573e9fd3cd3
solandmedotru/Python_Tutorials
/useless_trivia.py
942
4.15625
4
# Программа бесполезные факты # name = input("Привет. Как тебя зовут? ") age = int(input("Сколько тебе лет? ")) weight = int(input("И последний вопрос. Сколько ты весишь в кг? ")) print("\nЕсли бы маленький ребенок захотел привлечь твое внимание.") print("Он произнес бы твое имя так: " + name * 5) seconds = age * 36...
false
94fcc18a0b3265087ebbfb6e224c898e95364a9d
acmachado14/ListasCCF110
/Lista10/06.py
1,714
4.25
4
#6. Faça um programa que funciona como uma agenda telefônica. A agenda deve #ser guardada em uma lista com o seguinte formato: [[‘Ana’, ‘99999-1234’], [‘Bia’, #‘99999-5678’]]. (Não utilize esses dados. Isso é só um exemplo da estrutura. Leia #todos os dados do teclado). O programa deve ter um menu que tenha as seguinte...
false
0ee0d2873e2aec1ab8e74319127281ac81eb79c6
Arween/PythonMIT-lessons
/Lecture-test/lect2_t2.py
753
4.25
4
outstandingBalance = float(raw_input("Enter the outstanding balance on your credit card: ")); interestRate = float(raw_input("Enter the annual credit card interest rate as a decimal: ")); monthlyPayment = 0; monthlyInterestRate = interestRate/12; balance = outstandingBalance; while balance > 0: monthlyPayment +=...
true
7cf7a34d09d0a5889a577850391ebf14d486d535
ImwaterP/learn-Python
/Python note/元组.py
323
4.1875
4
""" 元组: 特点:元组内元素无法修改,以圆括号括起来 """ location = (1,2,3) print(location) location[0] = 10 print(location) #重新创建新元组,覆盖旧元组即可 location = (10, 2, 3) print(location) #遍历元组内所有元素 for i in location: print(i)
false
646d6816429c5dac188fd8693ffb4406aa57e752
aamartinez25/effective-system
/cpu.py
1,482
4.1875
4
# #Author: Adrian Martinez #Description: takes a few inputs on CPU specs and organizes them accordingly # # cpu_ghz = float(input('Enter CPU gigahertz:\n')) #input for CPU specs cpu_core = int(input('Enter CPU core count:\n')) cpu_hyper = input('Enter CPU hyperthreading (True or False):\n') print() if cpu_...
true
9a576e7335c48f855798d6c1e42d8be4da138fd5
niksanand1717/TCS-434
/03 feb/solution_2.py
499
4.15625
4
num1 = eval(input("Enter the first number: ")) num2 = eval(input("Enter the second number: ")) count1, count2 = 0, 0 print("\n\nNumbers divisible by both 3 and 5") for num in range(num1, num2+1): if num%3 == 0 and num%5 == 0: print(num) count1+= 1 print("Total numbers of numbers:",count1) print(...
true
360b2dba16714f2e2fee62d85537d49faefab8c1
niksanand1717/TCS-434
/28 april/fourth.py
292
4.34375
4
"""Input a string and return all the words starting with vowels""" import re pattern = '^[aeiou]' str1 = input("enter string: ") print("Following are the words in entered string starting with vowel: ", end=' ') [print(word, end=' ') for word in str1.split(" ") if re.match(pattern, word)]
true
e3c9452a5563afe71101af97ced7f3834d042b83
niksanand1717/TCS-434
/28 april/first.py
276
4.5
4
"""Print all the words from a string having length of 3""" import re pattern = '(...)$' input_data = input("input string: ") print("Following are the words which have length 3: ") for words in input_data.split(" "): if re.match(pattern, words): print(words, end=" ")
true
04680654bc17937b0d8f2939891f622784a66a56
farmani60/coding_practice
/topic5_sorting/InsertionSortPart1.py
340
4.15625
4
# Description: # https://www.hackerrank.com/challenges/insertionsort1/problem?h_r=internal-search def insertionSort1(arr): for i in range(len(arr)): if arr[i] > arr[-1]: temp = arr[i] arr[i] = arr[-1] arr[-1] = temp input_list = [2, 4, 6, 8, 3] insertionSort1(input_list...
false
d448f3cebeff50b9eb66a2d1749d703c7a4f635e
farmani60/coding_practice
/topic10_bigO/log_n.py
1,147
4.15625
4
""" Logarithmic time complexities usually apply to algorithms that divide problems in half every time. If we implement (Algorithm A) going through all the elements in an array, it will take a running time of O(n). We can try using the fact that the collection is already sorted. Later, we can divide in half as we look ...
true
0f8fe20a3d49ce95591f9d9c46dd57d17e007866
nomatterhowyoutry/GeekPython
/HT_1/Task6.py
263
4.28125
4
# 6. Write a script to check whether a specified value is contained in a group of values. # Test Data : # 3 -> [1, 5, 8, 3] : True # -1 -> (1, 5, 8, 3) : False list = [1, 5, 8, 3] tuple = tuple(list) print(3 in list) print(-1 in tuple)
true
96819f1bdd9469451af6089d77a9c6a979709856
vanTrant/py4e
/ex3_try_exec/script.py
361
4.1875
4
# hours = input('Enter Hours: ') # rate = input('Enter Rate: ') try: hours = float(input('Enter Hours: ')) rate = float(input('Enter Rate: ')) except: print('Please enter a valid number') quit() if hours > 40: overtime_pay = (hours - 40) * (rate * 1.5) pay = 40 * rate + overtime_pay else: ...
true
d5b0514e7c3e53f7f1bf6ec53717c79f81325591
yevgenybulochnik/lp3thw
/ex03/drill1.py
859
4.375
4
# Simple print statement that prints a string print("I will count my chickens:") # Prints a string then divides 30 by 6 then adds 25 print("Hens", 25 + 30 / 6) # Prints a string then gives you the remainder of 75/3 or 3 and subtracts from 100 print("Roosters", 100 - 25 * 3 % 4) print("Now I will count the eggs:") # ...
true
8905a8a1c3bd892fef8604ff4e1c8741c730654a
PaulSweeney89/squareroot
/sqrt_test.py
830
4.3125
4
# defining a fuction to calculate the square root of a positive real number # using Newton's method (ALTERNATIVE) while True: A = float(input("Please input positive value ")) if A > 0: break else: ...
true
0ad794722abfb826b414f7d7eeb51f6b59293c5f
ljsauer/DS-From-Scratch
/Notes/Chapter 4.py
1,188
4.375
4
"""Linear Algebra: the branch of math that deals with vector spaces """ # # Vectors - objects that can be added together to form new vectors, # and that can be multiplied by scalars; points in some # finite-dimensional space from typing import List Vector = List[float] height_weight_age = [70, ...
true
6b997548a37e7a761a789a4b44df67cfa69651d8
blainekuhn/Python
/Reverse_text.py
255
4.15625
4
def reverse(text): word = [text] new_word = "" count = len(text) - 1 for letter in text: word.insert(0, letter) for a in range(len(word) - 1): new_word = new_word + word[a] return new_word print reverse("This is my text to reverse")
true
494d979b41757904cbcc0e9f10a6adfb0d5132f2
Gopi3998/UPPERCASE-AND-LOWERCASE
/Uppercase and Lowercase...py
527
4.34375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: print('Starting the program for count the upper and lower case'.center(80,'*')) sample = input('enter string: ') uppercase = 0 lowercase = 0 for ch in sample: if str .isupper(ch): uppercase+=1 elif str.islower(ch): lowercase+=1 print('No of upper...
true
6e9034990271d7ed4549663f9d537dd7ac8f6a86
Veletronic/Farmville
/Sheep_class.py
1,217
4.125
4
from Animal import * class Sheep(Animal): #Cow inherits from Animal """A sheep""" #Constructor def __init__(self): #Call the parent class constructor with default value #Growth rate =1; food requirement = 3; water requirement = 3 super().__init__(1,3,3) self._type...
true
14025dd27c8f83cf0fed8b4cfea0c76badea0319
sarahovey/AnalysisOfAlgos
/hw1/mergesort.py
1,995
4.15625
4
#Sort #Merge Sort def merge_sort(numbers): #Divide the list into halves recursively if len(numbers) > 1: #get midpoint of list mid = len(numbers)/2 left = numbers[:mid] right = numbers[mid:] merge_sort(left) merge_sort(right) #index varia...
true
2ad2891489db9ee7ddfd36acf02fbf71eac598bf
codeaudit/tutorial
/exercises/exercise01.py
1,863
4.125
4
# The goal of this exercise is to show how to run simple tasks in parallel. # # EXERCISE: This script is too slow, and the computation is embarrassingly # parallel. Use Ray to execute the functions in parallel to speed it up. # # NOTE: This exercise should work even if you have only one core on your # machine because t...
true
cf3480dca530bcedcb764f2cb0655914d004a409
Abhishek-kr7/Basic-Python-Programming
/09_Functions_in_python.py
1,759
4.375
4
def hello(): """This function will print the Hello Message when called""" print('Hey there! Hello') # hello() def hello_user(user): '''This function will take a parameter or name and will print hello with the parameter/name''' print("Hello",user, "How are you") hello_user('abhi') print(help(hell...
true
5fc1530a3fb637127abf517484c0e96f3940fdd4
Axl11475581/Projects-Folder
/Python Exercises/Python Basics/Practical Exercise.py
2,256
4.53125
5
# 7 Exercise to practice the previous topics viewed 1 price_product_1 = input("What is the price of the product 1?: \n ") quantity_product_1 = input("How many of the product 1 will you buy?: \n ") price_product_2 = input("What is the price of the product 2?: \n ") quantity_product_2 = input("How many of the product 2 ...
true
b8f090d72c4065c18bfd430e24ce11254b369fee
boluocat/core-python-programming
/Fiboacci.py
1,147
4.4375
4
'''递归 recursion ''' def Fibonacci_recursion(n): if n == 0: return 0 elif n ==1: return 1 else: return Fibonacci_recursion(n-1)+Fibonacci_recursion(n-2) '''迭代 iteration 前一个数字+当前数值=下一个数值 ''' def Fibonacci_interation(n): if n ==0 : return 0 elif n == 1...
false
770dfec0ac2a38cd1d55cd33087dde8caf87db28
ikamesh/Algorithms
/inputs.py
1,314
4.375
4
import random """This is file for generating input list for algorithms""" #input method1 -- filling list with try-except def infinite_num_list(): print(""" Press enter after each input. Press 'x' to when done...! """) num_list = [] while True: num = input("Enter num to fill the list : "...
true
7504bbb277af091a8b5b4bd1230ea416f169a5b3
uit-inf-1400-2021/uit-inf-1400-2021.github.io
/lectures/oop-02-03-oo-concepts/code/extending.py
1,281
4.375
4
#!/usr/bin/env python3 """ Based on code from the OOP book. """ class ContactList(list): def search(self, name): '''Return all contacts that contain the search value in their name.''' matching_contacts = [] for contact in self: if name in contact.name: m...
true
d0fec4e684b774cbc4b07cce6c7d7bacfa6681ca
shortma1/Coyote
/day6.py
615
4.25
4
# # functions # print("Hello") # print() is a function # num_char = len("Hello") # len() is also a function # print(num_char) # def my_function(): # def defines function, my_function() is the name of the function, and : finished the function definition # print("Hello") # print("Bye") # my_function() # to...
true
d2748867ecdaa65218c7ffecaf74fbaec0149789
Vitaee/Python-Basic-Projects-5
/BinarytoHexadecimal.py
1,387
4.34375
4
print("Welcome to the Binary/Hexadecimal Converter App\n") a = int(input("Compute binary and hexadecimal values up to the following decimal number: ")) decimal = list(range(1, a+1)) #a+1 dedik çünkü range fonksiyonu son sayıyı almıyor. binary = [] hexadecimal = [] for i in decimal: #for döngüsü oluşturarak decimal bin...
false
a08f76a2e3ccc91b0e0ebae2c191fd09f7c43063
piluvr/Python
/max.py
233
4.125
4
# your code goes here nums =[] input1 = int(input("Enter a number: ")) input2 = int(input("Enter a number: ")) input3 = int(input("Enter a number: ")) nums.append(input1) nums.append(input2) nums.append(input3) print(str(max(nums)))
true
d8c92e58919689ff644004479aad9cbae61218e2
shanjiang1994/LeetCode_for_DataScience
/Solutions/Array/88.Merge Sorted Array.py
2,809
4.34375
4
''' Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is equal to m + n) to hold additional elements from nums2. Example: Input: nums...
true
92b23cdfa9a34ba5230c0353dbc1958a63a38658
Skryvvara/DS1-Soullevel-Calculator
/soullevelcalc.py
1,287
4.1875
4
# returns cost of the given level # when level = 12 the returned cost is from level 11 -> 12 def get_level_cost(level: int) -> int: return int(round((0.02 * pow(level, 3)) + (3.06 * pow(level, 2)) + (105.6 * level) - 895, 0)) # returns the amount of possible levelups # takes the current level and the amount of hel...
true
cf79d548cfb65bb4ea3073cd0d1723981cea1400
sydoruk89/math_series
/math_series/series.py
1,177
4.1875
4
def fibonacci(n): """ The function return the nth value in the fibonacci series. Args: n (int): integer """ if n >= 0: if n < 2: return n else: return fibonacci(n - 1) + fibonacci(n - 2) else: return 'Please provide a positive number' ...
true
94e9bebee541b227fee0713a50ef389e0089f1bf
anshdholakia/Python_Projects
/setters and property_decorators.py
1,179
4.21875
4
class Employee: def __init__(self,fname,lname): self.fname=fname self.lname=lname # self.email=f"{self.fname}.{self.lname}@gamil.com" def explain(self): return f" This Employee is {self.fname} {self.lname}" @property def email(self): if self.fname==No...
false
45521599af6d990c059840b0f1b70c9d3c482c6f
anshdholakia/Python_Projects
/map_filter.py
1,387
4.21875
4
# numbers=["1","2","3"] # # # for i in range(len(numbers)): # not suitable every-time to use a for loop # # numbers[i]=int(numbers[i]) # # # using a map function # numbers=list(map(int,numbers)) # # # numbers[2]=numbers[2]+5 # # print(numbers[2]) # def sq(a): # return a*a # num=[1,2,124,4,5,5,12...
true
6c465540793c7d032822d027ff5e58837b8fcf31
lovaraju987/Python
/learning concepts and practising/basics/sep,end,flash.py
443
4.15625
4
''' sep, end, flash''' print('slfhs',2,'shalds',end = ' ') # by default print statement ends with \n(newline).so, this 'end' is used to change to ending of the print statement when we required it print('sfjsaa',3,'hissa') print('sfjsaa',2,'hissa',sep = ' ') # by default multiple statemnets in one print without any s...
true
5733608db00de58d07cd64754e9592302e8e7dd6
badri-venkat/Computational-Geometry-Algorithms
/PolygonHelper.py
849
4.21875
4
def inputPolygon(numberOfPoints): polygonArray = [] print( "Enter the points in cyclic order. Each point is represented by space-separated coordinates." ) i=0 while i<numberOfPoints + 1: x, y = map(int, input().split()) polygonArray.append(tuple([x, y])) i+=1 if i...
true
e01e7b007f7041fccc232fc3e9ab9ecacb44dec4
kradical/ProjectEuler
/p9.py
467
4.15625
4
# A Pythagorean triplet is a set of three # natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # There exists exactly one Pythagorean triplet # for which a + b + c = 1000. # Find the product abc. def test(): for a in range(1, 333): for b in range(1000-a): ...
true
732c172fbce4e4cac32875feb880b5e1c6ac59f4
CucchiettiNicola/PythonProgramsCucchietti
/Compiti-Sistemi/Es32/Es32.py
1,475
4.75
5
the_count = [1,2,3,4,5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quartiers'] # this first kind of for-loop goes trough a list for number in the_count: print(f"This is count {number}") # same as above for fruit in fruits: print(f"A fruit of type: {fruit}") #...
true
b0dfa1327acc7c44cf0c80db63aa3a2afb2dc23f
Gauravsahadev/Udemy-Python3-BootCamp-Practice-Problems
/Dictionary/two_lists.py
201
4.21875
4
list1 = ["CA", "NJ", "RI"] list2 = ["California", "New Jersey", "Rhode Island"] answer={list1[i]:list2[i] for i in range(3)} print(answer) #method second answer2=dict(zip(list1,list2)) print(answer2)
false
272d6b26253dfb3573be18709097920d1dbb07ab
cb-kali/Python
/Day13.py
1,021
4.1875
4
''' Introduction to python class: Class --> it's like a blueprint of codedesing. class method --> A function writen inside a class is called a method. attributes --> a variable writen inside a class is called an attributes. Introduction of a class/object ''' # req:- ''' You have to create a class, it should your ...
true
e4063d8bc9fa4a3a89eb99209c699aa2c667b722
GibsonCool/python_Basis
/ptythonProject/python_basis/knowledgePoint/1.list_tuple_dict_set.py
734
4.34375
4
""" list 一个可变的有序表 """ listSimple = ['a', 'b', 'c'] print(listSimple) print(listSimple[2]) print(listSimple[-2]) # print(listSimple[3]) # 会奔溃,越界 listSimple.append("sss") print(listSimple) listSimple.insert(2, "555") print(listSimple) """ tuple 一个不可变的有序表""" tupleSimple = (1,) # 为了避免歧义定义只有一个元素的tuple时候需要在末尾加个逗号 prin...
false
5107df9089c13654010da7dc262f5812d84fd508
GibsonCool/python_Basis
/ptythonProject/python_basis/knowledgePoint/13.浅拷贝、深拷贝.py
944
4.34375
4
""" ==:比较的是值 is:比较的是地址值 """ a = [11, 22, 33] b = [11, 22, 33] print(id(a)) print(id(b)) print(a == b) print(a is b) print("__________________________________________________________________________________") """ 浅拷贝(copy.copy()):正常的赋值操作,只拷贝地址值或者叫内存引用,如果有多层只拷贝第一层,如果第一层是不可变比如元组,那么一层都不拷贝直接复制 深拷贝(copy.d...
false
29e91abac0e3e1202cd2fef2f4666bfe681dc9be
robert0525/Python-
/hello.py
393
4.1875
4
first_name = input("What's is your first name? ") print("Hello", first_name) if first_name == "Robert": print(first_name, "is learning Python") elif first_name == "Maxi": print(first_name, " is learning with fellow students in the Comunity! Me too!") else: print("You should totally learn Python, {}!".form...
true
a8cb384dc0440a3f8ae962d3c543af8e179fa9cd
riteshelias/UMC
/ProgramFlow/guessgame.py
1,734
4.125
4
import random answer = random.randint(1, 10) print(answer) tries = 1 print() print("Lets play a guessing game, you can exit by pressing 0") guess = int(input("try count - {}. Please enter a number between 1 and 10: ".format(tries))) while guess != answer: if guess == 0: print("Bye, have a nice day!") ...
true
16f595b7e1ff1b8b22ab8ba1221d96448a03d15e
daniel10012/python-onsite
/week_01/03_basics_variables/07_conversion.py
526
4.375
4
''' Celsius to Fahrenheit: Write the necessary code to read a degree in Celsius from the console then convert it to fahrenheit and print it to the console. F = C * 1.8 + 32 Output should read like - "27.4 degrees celsius = 81.32 degrees fahrenheit" NOTE: if you get an error, ...
true
9e6b89661cd68140884634d1a7978e4afc899e98
daniel10012/python-onsite
/week_02/11_inheritance/01_class_attributes.py
910
4.40625
4
''' Flush out the classes below with the following: - Add inheritance so that Class1 is inherited by Class2 and Class2 is inherited by Class3. - Follow the directions in each class to complete the functionality. ''' class Class1: def __init__(self, x): self.x = x # define an __init__() met...
true
fe26c3fa3494717d2cb65c234594323fae19a5f0
daniel10012/python-onsite
/week_04/intro_apis/01_countries.py
1,117
4.375
4
''' Use the countries API https://restcountries.eu/ to fetch information on your home country and the country you're currently in. In your python program, parse and compare the data of the two responses: * Which country has the larger population? * How much does the are of the two countries differ? * Print the native ...
true
06774114cb67d9626933f4f3d752b8beb4f9f2b2
daniel10012/python-onsite
/week_03/01_files/04_rename_doc.py
1,156
4.125
4
''' Write a function called sed that takes as arguments a pattern string, a replacement string, and two filenames; it should read the first file and write the contents into the second file (creating it if necessary). If the pattern string appears anywhere in the file, it should be replaced with the replacement string. ...
true
cd99f695faa50653c2ca9488547a528059c94d62
daniel10012/python-onsite
/week_02/06_tuples/01_make_tuples.py
502
4.34375
4
''' Write a script that takes in a list of numbers and: - sorts the numbers - stores the numbers in tuples of two in a list - prints each tuple Notes: If the user enters an odd numbered list, add the last item to a tuple with the number 0. ''' my_list = [5,3,32,1,3,9,5,3,2,2,5] my_list.sort() if len(...
true
fd1561a9a0a9c1cf29c24efbf299c0e3e135fa19
balaramhub1/Python_Test
/Tuple/Tuple_03.py
668
4.125
4
''' Created on Jul 17, 2014 @author: HOME The script is to see the function of T.index[x] and T.count(x) methods of Tuple ''' list1=['hello','balaram'] color = ("red","green","blue",list1) fruit =(5,"lemon",8,"berry",color,"grapes","cherry") numtup=(4,6,3,2,5,23,3,2,4,2,3,5) print("Elements of List1 are : ",...
true
bd2ca872c954096e50e818e402969a3bc9a1ff8b
balaramhub1/Python_Test
/Math/math_03.py
394
4.125
4
''' Created on Jun 14, 2020 Usage of Random module @author: beherb2 ''' import random print(random.random()) # Choose a random number from a list l=[1,2,3,4,5,6] print(random.choice(l)) # generate a random number between a range print(random.randint(10,100)) # end number is not included print(random.randrange(10...
true
9b1e5b1a994bc633e8eabe5131f79db0bbfd2c21
jage6277/Portfolio
/Discrete Structures/Unsorted to Sorted List.py
1,559
4.21875
4
# This function takes two sorted lists and merges them into one sorted list # Input: L1,L2 - Two sorted lists # Output: L - One sorted list def merge(L1,L2): L = [] # Array where the sorted list will be stored while len(L1) != 0 and len(L2) != 0: # While L1 and L2 are both nonempty if ...
true
8364b704a8261dc3ffc774e747dfd430550cc587
jarmer7043/Functions_Parameters-Global_Variables
/diceRoller.py
1,748
4.21875
4
#Dice rolling program #Aim is to roll a 6 or roll a number twice in a row import random import time s1 = "- - - - -\n| |\n| O |\n| |\n- - - - -\n" #the dice prints s2 = "- - - - -\n| O |\n| |\n| O |\n- - - - -\n" s3 = "- - - - -\n| O |\n| O |\n| O |\n- - - - -\n" s4 = "- - - ...
false
f74a9179d69a3f625a19a7688a9ff452c2b2b651
samahmood1/Python-Basic
/for_challenge2.py
854
4.375
4
#!/usr/bin/env python3 farms = [{"name": "NE Farm", "agriculture": ["sheep", "cows", "pigs", "chickens", "llamas", "cats"]}, {"name": "W Farm", "agriculture": ["pigs", "chickens", "llamas"]}, {"name": "SE Farm", "agriculture": ["chickens", "carrots", "celery"]}] animals = ["cats", "chickens", "cows",...
false
9ca92b5f121723702b7901dfa4d2d3f86885b077
rnagle/pycar
/project1/step_2_complete.py
810
4.25
4
# Import built-in python modules we'll want to access csv files and download files import csv import urllib # We're going to download a csv file... # What should we name it? file_name = "banklist.csv" # Use urllib.urlretrieve() to download the csv file from a url and save it to a directory # The csv link can be found...
true
2f00505d175bd72b047b898d367fc9a201b9c0e8
vivekbhadra/python_samples
/count_prime.py
684
4.125
4
''' COUNT PRIMES: Write a function that returns the number of prime numbers that exist up to and including a given number count_primes(100) --> 25 By convention, 0 and 1 are not prime. ''' """ Spyder Editor This is a temporary script file. """ def isprime(num): flag = True for n in range(2, (num // 2) + 1): ...
true
559e6721d46d0156427efb46a07815d8852c85d8
jfxugithub/python
/面向对象的高级编程/staticmethod.py
475
4.15625
4
""" 静态方法定义: 通过修饰器staticmethod来进行修饰,可以不用传参数,第一参数默认为cls 加载时机:随着类的加载而加载 """ class Student: address = "太阳系" def __init__(self, name, age): self.name = name self.age = age @staticmethod #修饰静态方法 def get_address(): return Student.address print(Student.get_addr...
false
717f322356962fb6fd13819bdeb5f133f56a0553
Mathtzt/Python
/collections/src/Collections-pt1/aula2.2.py
1,502
4.34375
4
##Esse arquivo foi criado para o estudo das Coleções no python em especial as listas e tuplas. from abc import ABCMeta, abstractmethod, ABC class Conta(metaclass=ABCMeta): def __init__(self, codigo): self._codigo = codigo self._saldo = 0 def deposita(self, valor): self._saldo += valo...
false
3c043341d16e6c27c947230779d248f00b72a6c6
glennpantaleon/python2.7
/doughnutJoe.py
2,197
4.4375
4
''' A program designed for the purpose of selling coffee and donuts. The coffee and donut shop only sells one flavor of coffee and donuts at a fixed price. Each cup of coffee cost seventy seven cents and each donut cost sixty four cents. This program will imediately be activated upon a business. \/\/\/\\/\/\/\...
true
7f7d73dd0b2be68187d745c8a3893d52a587a2e3
erickclasen/PMLC
/xor/xor_nn_single_layer.py
1,571
4.21875
4
import numpy as np # sigmoid function def nonlin(x,deriv=False): if(deriv==True): return x*(1-x) return 1/(1+np.exp(-x)) print("XOR: With a hidden layer and the non-linear activation function on the output layer.") print("Fails!") ''' 2 inputs 1 output l0 is the input layer values, aka X l1 is the hi...
true
71716899604df84cc40aa5650cad8dc91df5c05c
shouvikbj/IBM-Data-Science-and-Machine-Learning-Course-Practice-Files
/Python Basics for Data Science/loops.py
532
4.34375
4
num = 2 # for loop in a range for i in range(0, num): print(i + 1) for i in range(num): print(i + 1) # for loop in case of tuples names = ("amrita", "pori", "shouvik", "moni") for name in names: print(name) # for loop in case of lists names = ["amrita", "pori", "shouvik", "moni"] for name in names: ...
true
a2318f87b16e2a7ddbb2a2a14fea964e69923972
MichalKotecki/DataCiphering
/ModularInverse/ModularInverse.py
1,517
4.1875
4
# Title: Modular Inverse in Python # Author: Michał Kotecki # Date: 5/09/2020 # Description: # This algorithm is used to find S in (a * S) mod b = 1, given that a and b are known. # This kind of problem is called 'Prime Factorization'. class TableRow: def __init__(self, q, r, s): self.q = q self.r ...
false
c1649abbfeea25a8b318f96a8dfe086a1d8a1a40
cyphar/ncss
/2014/w2/q4complex.py
1,806
4.1875
4
#!/usr/bin/env python3 # Enter your code for "Mysterious Dates" here. # THIS WAS MY INITAL SOLUTION. # IT DOES NOT PASS THE TEST CASES. # However, the reason I added this is because this code will take any date # format (not just the given ones) and brute-force the first non-ambiguous # representation. It is (in my op...
true
954ecbf16326abddafe9b391a88fabe0393cc50e
dhwani910/w18c-fizzbuzz
/app.py
409
4.125
4
numbers = [10, 22, 27, 30, 29, 18, 21, 1, 28, 20, 18, 5, 19, 9, 11, 22, 15, 20, 0, 6, 12, 7, 17] def fizzbuzz(number): if(number % 3 == 0 and number % 5 == 0): print("fizzbuzz") elif(number % 3 ==0): print("fizz") elif(number % 5 == 0): print("buzz") else: print...
false
76c2a205292169daea9e1c5c085dea4525992e94
javedbaloch4/python-programs
/01-Basics/015-print-formatting.py
490
4.125
4
#!C:/python/python print("Content-type: text/html\n\n") s = "string" x = 123 # print ("Place my variable here: %s" %s) # Prints the string and also convert this into string # print("Floating point number: %0.3f" %1335) # Prints the following floating number .3 is decimal point # print("Convert into string %r" %x) # ...
true