blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
16a137e575032e1435d56629409f9b01d6d665c7
kshitijvr93/Django-Work-Library
/modules/sqlalchemy_tools/core/try_alchemy.py
1,519
4.28125
4
''' Basic demo python3 code to use SqlAlchemy (SA) to create a table in a database. ''' import os import sys import sqlalchemy from sqlalchemy import ( Column, ForeignKey, Integer,create_engine, String, Table, MetaData, ForeignKey, Sequence,) print("Sqlalechemy version='{}'".format(sqlalchemy.__version__)) engine...
false
2ed66b56971d82556312f1a1ab8139cb62d5378c
nkat66/python-1-work
/noble_kaleb_tipcalculatorapp.py
996
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 25 19:00:12 2019 Kaleb Noble 2/27/2019 Python 1 - DAT-119 - Spring 2019 Tip Calculator Assignment This program takes an input of a meal bill, then calculates and presents the user with the 10%, 15%, and 20% tip values. @author: katnob8 """ ...
true
7b9f94392c28ae061f682df6ae65e2d4d3bbfcec
gwccu/day2-rachelferrer
/day3.py
283
4.21875
4
# my code prints my name, then stores it as a variable which I can then add things to such as my last name and repeating it multiple times print("Rachel") myName = "Rachel" print(myName) print(myName + "Ferrer") print(myName*78) print("What comes first the 'chicken' or the 'egg'?")
true
0647977b57c82a9ed439437957b7bafd13c0f406
kumarsourav1499/Miniproject-Python-
/mini_project.py
432
4.21875
4
first = int(input("enter first number : ")) operator = input("enter operator (+,-,*,/,%) : ") second = int(input("enter second number : ")) if operator == "+": print(first + second) elif operator == "-": print(first - second) elif operator == "*": print(first * second) elif operator == "/": ...
false
fa61cb6964caf46d16e3c390a51921bd0371d2f2
mRse7enNIT/Guess_The_Number_Python
/main.py
1,975
4.21875
4
# input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import math import random range = 100 no_of_guess = 0 secret_number = 0 # helper function to start and restart the game def new_game(): # initialize global variables used in your code here ...
true
49df8291b778d88203f849ee8fc7e39b37fede67
inwk6312winter2019/week4labsubmissions-praneethm45
/lab5T3.py
305
4.1875
4
class Time: """this class represents time""" """def print_time(self,t): print('the time is:','%.2d:%.2d:%.2d'%(t.hour,t.minute,t.second))""" time=Time() time.hour=9 time.minute=35 time.second=25 def print_time(t): print('the time is:','%.2d:%.2d:%.2d'%(t.hour,t.minute,t.second)) print_time(time)
false
08f8c4c315469294ebfedf93a8338cd3c6c368e5
qdaniel4/project3Finished
/validation.py
1,223
4.28125
4
def topic_validation(user_input): while user_input.isnumeric() is False or int(user_input) <= 0 or int(user_input) > 3: print('Please enter a whole number between 1 & 3:') user_input = input() user_input = int(user_input) if user_input == 1: topic = 'Sports' return topic ...
true
db0e1096127e695e22eb59543b0329f8bbdad662
isi-frischmann/python
/exercise.py
1,611
4.28125
4
# 1. # SET greeting AS 'hello' # SET name AS 'dojo' # LOG name + greeting greeting = 'hello' name = 'dojo' print greeting +" "+ name # 2. # Given an array of words: ['Wish', 'Mop', 'Bleet', 'March', 'Jerk'] # Loop through the array # Print each word to consol array = ['Wish', 'Mop', 'Bleet', 'March', 'Jerk'] for i...
true
6b7d0b73e2881d111d33dd98118593847032d83f
isi-frischmann/python
/multiplication_table.py
579
4.125
4
''' pseudocode: -create two lists from 0 - 12 (listHorizontal and listVertical) - create a for loop which goes through each index of listVertical -create a for loop in the for loop which goes through each index in listHorizontal -and multiplies it with index 0 from listVertical ''' #first row (horizontal) is wrong...
true
621db9104577cb2de94faa182aaae81ec2d7a855
gpereira-blueedtech/BlueTurma2B-mod1
/Aula08/Aula08_revisao_funcoes.py
1,454
4.46875
4
# Criando as funções: # "Ensinando" ao programa o que ele deve fazer quando a função for chamada # Importante lembrar que nesse momento a função não é executada, apenas criada! # Para executar, eu preciso chamar a função pelo nome dela no programa def testa_idade(idade=18): print(idade) if idade >= 18: ...
false
e302581c0b1983a2f8f02cdde2372ab78899d151
qimo00/timo
/def1_huiwen.py
348
4.21875
4
def Palindrome(str_in): len_s=len(str_in) i=0 flag=1 while i<len_s/2: if str_in[i]==str_in[len_s-1-i]: i+=1 else: flag=0 break if flag==1: print("it is a Palindrome") else: print("it is not a Palindrome") string=input("input a ...
false
aa1bdb2b6f2dfc31f467de5d05807bbd3a3ac8c9
sirinsu/GlobalAIHubPythonHomework
/project.py
2,657
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: """Student Management System""" def calculateFinalGrade(grades):#takes a dictionary including midterm, final and project grades then returns the final grade after some calculations. midterm = int(grades.get('midterm')) final = int(grades.get('final')) proje...
true
d9eae7edf62fa1c37699ee15d4a7b7a63c065bf9
hemanth9516/pythonlab
/function1.py
320
4.15625
4
def func(num1,num2,num3): if (num1 >= num2) and (num1 >= num3): return num1 elif (num2 >= num1) and (num2 >= num3): return num2 else: return num3 a= float(input("Enter first number: ")) b= float(input("Enter second number: ")) c= float(input("Enter third number: ")) largest=func(a,b,c) print(largest)
false
8ba1f5a63053442a3d804fff31c0af7554fb8d1d
GuillemGodayol/Ironhack_Data_Labs
/Week_3/lab-code-simplicity-efficiency/your-code/challenge-3.py
1,120
4.625
5
""" You are presented with an integer number larger than 5. Your goal is to identify the longest side possible in a right triangle whose sides are not longer than the number you are given. For example, if you are given the number 15, there are 3 possibilities to compose right triangles: 1. [3, 4, 5] 2. [6, 8, 10] 3. ...
true
7dcb240d949c5299263b562fbb1bb3a76943e44b
Matt-GitHub/Sprint-Challenge--Data-Structures-Python
/reverse/reverse.py
2,019
4.21875
4
class Node: def __init__(self, value=None, next_node=None): self.value = value self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.next_node def set_next(self, new_next): self.next_node = new_next class LinkedList...
true
919fc9a46afa10b97448ff531296f4d33966717e
raresteak/py
/collatz.py
1,203
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # def collatz(checkNum): if checkNum % 2 == 0: newNum = checkNum // 2 #print('Entered EVEN branch, value is now: ' + str(newNum) ) return newNum else: newNum = 3 * checkNum +1 #print('Entered ODD branch, value is now: ' + str(newNum) ) return newNu...
true
6f7eb3a41ec46526088ff54b4eff82c032c09a30
rasna-skumar1306/mini_problems
/age_detect.py
473
4.125
4
from datetime import datetime as date def detect(): if (dy-int(yyyy)) >= 18: if int(mm) < dm: print("you are eligible to vote") elif int(mm) == dm: if int(dd) <= da: print("you may proceed to vote") print("you may proceed to vote") else: print("you are not allowed to vote") da = date.now().d...
false
ab26864a12aa195190b3d3b24d29b1d97f17eb1a
Kratharth/1BM17CS035
/string experiments/reverse.py
242
4.125
4
def reverse(s): l=s.split() l=l[::-1] for word in l: print(word,end=" ") print('\n') l=l[::-1] for i in range(len(l)): l[i] = l[i][::-1] for word in l: print(word, end=" ") print('\n') st = input('enter a string :') reverse(st)
false
17edae88160faec456d5c69ca2b7ac0f05cd3b1e
linkdesu/python-lessons
/lesson5/range.py
503
4.3125
4
# -*- coding: utf-8 -*- """ range """ # ==== 基础 ==== print(range(10)) # range(start, stop) c = list(range(1, 11)) print("c: ", c) # range(start, stop[, step]) d = list(range(1, 11, 2)) print("d: ", d) e = list(range(0, -10, -1)) print("e: ", e) # ==== 深入 ==== # range 函数返回的是一个可遍历的 Range 对象。 a = range(10) prin...
false
5ac87e9ccf3322d89904858defb1134deded6633
linkdesu/python-lessons
/lesson4/if_else.py
766
4.34375
4
# -*- coding: utf-8 -*- """ if """ # 当条件为真,执行 if 代码块的代码。 if True: print('This code will be execute.') else: print('This code will not be execute.') if True or False: print('This code will be execute.') else: print('This code will not be execute.') if 1 <= 2: print('This code will be execute.'...
false
9536c136bf37e24b80ad48d59e667010b8b20cdc
beowlf/exercicio-python
/Modifique o programa anterior para imprimir de 1 ate o numero digitado pelo usuario mas dessa vez apensas o numeros impares.py
235
4.21875
4
''' Modifique o programa anterior para imprimir de 1 ate o numero digitado pelo usuario mas dessa vez apensas o numeros impares ''' fim = int(input("Digite um numero: ")) x = 1 while x <= fim == 1: print (x) x = x + 1
false
8f0b416ef147905aa8de95a096079e793270370f
ssciere/100-days-of-python
/days_ago.py
530
4.25
4
"""promblem solved for the Talk Python course https://github.com/talkpython/100daysofcode-with-python-course""" import datetime from datetime import date, timedelta print("This program allows you to enter a date to find out how many days ago it occurred") day = int(input("Enter the day: ")) month = int(input("Enter ...
true
e59230a3886cb74b298041992eabf99d2247bd94
gaylonalfano/blockchain-cryptocurrency
/loops_conditionals_assignment.py
1,003
4.34375
4
# My attempt: # 1) Create a list of names and use a for loop to output the length of each name (len() ). names = ['Robert', 'Archie', 'Rudolph', 'Cloud', 'Raistlin', 'Miller', 'Fitz', 'Falco', 'Jon'] # for name in names: # print(len(name)) # 2) Add an if check inside the loop to only output names longer ...
true
43d613bf1f83f8951017fd296bebfe5b0e094360
samuelleonellucas/Aulas-impacta
/AULAEX25.py
1,370
4.1875
4
''' num = float(input(" ")) if 1 <= num and num <= 100: print("dentro do intervalo") num = float(input(" ")) if 30 < num and num <70: print("dentro do intervalo") else: print ("fora do intervalo") ''' ''' num1 = int(input( )) num2 = int(input( )) num3 = int(input( )) if num1 < num2 < num3: print(num...
false
00fe8b198e8cf153a2ada8b8236033e9f801856b
mradoychovski/Python
/PAYING OFF CREDIT CARD DEBT/bisection_search.py
863
4.25
4
# Uses bisection search to find the fixed minimum monthly payment needed # to finish paying off credit card debt within a year balance = float(raw_input("Enter the outstanding balance on your credit card: ")) annualInterestRate = float(raw_input("Enter the annual credit card interest rate as a decimal: ")) monthlyInt...
true
726f473731b428a8e9cb2268c125088f15f410bd
skeapskeap/learn-homework-1
/1_if1.py
1,214
4.15625
4
""" Домашнее задание №1 Условный оператор: Возраст * Попросить пользователя ввести возраст при помощи input и положить результат в переменную * Написать функцию, которая по возрасту определит, чем должен заниматься пользователь: учиться в детском саду, школе, ВУЗе или работать * Вызвать функцию, передав ей воз...
false
fa01852f7695ac8e0530932e47a49641d4f99e8a
fekisa/python
/lesson_3/homework_3_4.py
1,001
4.28125
4
''' 4. Программа принимает действительное положительное число x и целое отрицательное число y. Необходимо выполнить возведение числа x в степень y. Задание необходимо реализовать в виде функции my_func(x, y). При решении задания необходимо обойтись без встроенной функции возведения числа в степень. ''' def my_func(x,y...
false
52a2b99fac1e18fd1579af864e8443a001bae6de
kgashok/algorithms
/leetcode/algorithms/spiral-matrix/solution.py
1,391
4.21875
4
#!/usr/bin/env python class Solution(object): def spiralOrder(self, matrix): """ Returns the clockwise spiral order traversal of the matrix starting at (0, 0). Modifies the matrix to contain all None values. :type matrix: List[List[int]] :rtype: List[int] """ ...
true
53a441d1adf62e68789c06718842ae64aae974a7
Kha-Lik/Olimp-Informatics-I_10-11_2021
/calculate_function.py
308
4.125
4
from math import sqrt, sin, cos def calculate(x, y): first_part = (x**3)/(3*y) third_part = 3*sin(y)/cos(x/y) num = x**3-8*x if num < 0: print("Error: cannot get sqrt of negative number") return second_part = sqrt(num) return first_part + second_part + third_part
true
482b59bb08c334c1c689197ea222fe4d6e68a19d
finjo13/assignment_II
/FinjoAss2/Qno8.py
234
4.1875
4
''' 8. Write a Python program to remove duplicates from a list. ''' someList=[23,43,33,23,12,13,13,13,67,89,89] newList=[] for item in someList: if item not in newList: newList.append(item) print(newList)
true
e57364064fc0ffd7f176bea85eded3e22fc2cb37
Levintsky/topcoder
/python/leetcode/math/970_powerful_int.py
1,278
4.1875
4
""" 970. Powerful Integers (Easy) Given two positive integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i >= 0 and j >= 0. Return a list of all powerful integers that have value less than or equal to bound. You may return the answer in any order. In your answer, each value should...
true
2ebfad24c9d71a8889f98b6f2f668e3e6d8cce56
Levintsky/topcoder
/python/leetcode/array/subarray_cont/992_subarray_K_diff_int.py
2,475
4.3125
4
""" 992. Subarrays with K Different Integers (Hard) Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that subarray is exactly K. (For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.) Return the number of good ...
true
b3a226938dbe7c5b8ed39e06d8486edcec65fec0
Levintsky/topcoder
/python/leetcode/numerical/1073_add_negbin.py
2,526
4.25
4
""" 1073. Adding Two Negabinary Numbers (Medium) Given two numbers arr1 and arr2 in base -2, return the result of adding them together. Each number is given in array format: as an array of 0s and 1s, from most significant bit to least significant bit. For example, arr = [1,1,0,1] represents the number (-2)^3 + (-2)...
true
69c850829a9c6a9bded7752eb4f485eaccc8e8e1
NenadPantelic/GeeksforGeeks-Must-Do-Interview-preparation
/Queues/StackUsingTwoQueues.py
888
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Feb 21 20:11:12 2020 @author: nenad """ ''' :param x: value to be inserted :return: None queue_1 = [] # first queue queue_2 = [] # second queue ''' queue_1, queue_2 = [],[] def push_in_stack(x): # global declaration g...
true
c8ab858fae3988afeca03d06a5eb669bbc614be9
Connor-Cahill/call-routing-project
/project/trie.py
2,423
4.28125
4
#!python class TrieNode: """ TrieNode is the node for our Trie Class """ def __init__(self): """ Initializes new TrieNode """ self.children = [None]*10 self.cost = None def __repr__(self): return f"NODE({self.children})" class Trie: def ...
true
f43f784dcb819b4408f0578ac590b4e2fcbc12e4
fwr666/ai1810
/aid/day05/shengdanshu.py
419
4.15625
4
# 3.输入一个整数,此整数代表树干的高度,打印一颗如下 # 形状的圣诞树 #  如: #    输入 3  #     打印如下: #    * # *** # ***** # * # * # * height = int(input('请输入树干高度')) for blank in range(1,height+1): print(' '*(height-blank)+'*'*(2*blank-1)) for _ in range(height): print(' '*(height-1)+'*')
false
c92eb2d64a506f56af0ce03156176b1766f67d22
gdesjonqueres/py-complete-course
/generators/map.py
842
4.15625
4
friends = ['Rolf', 'Jose', 'Randy', 'Anna', 'Mary'] friends_lower = map(lambda x: x.lower(), friends) print(next(friends_lower)) # this is equivalent to: friends_lower = [f.lower() for f in friends] friends_lower = (f.lower() for f in friends) # prefer generator comprehension over the other two class User: def _...
true
65163e63c3495fa837d8d3ae7cb0f3a320b63bed
djpaguia/SeleniumPythonProject1
/Demo/PythonDictionary.py
1,360
4.34375
4
# There are 4 Collection data types in Python # List | Tuple | Set | Dictionary # List - [] - ordered | indexed | changeable | duplicates # Tuple - () - ordered | indexed | unchangeable | duplicates # Set - {} - unordered | unindexed | no duplicates # Dictionary - {K:V}...
true
7bb8a309c528e4d676b9cd88a38a02a44dd171b1
djpaguia/SeleniumPythonProject1
/Demo/PythonSet.py
2,007
4.5
4
# There are 4 Collection data types in Python # List | Tuple | Set | Dictionary # List - [] - ordered | indexed | changeable | duplicates # Tuple - () - ordered | indexed | unchangeable | duplicates # Set - {} - unordered | unindexed | no duplicates # Dictionary - {K:V}...
true
36542eea9c4084eab54698adf5cb8f56f31c16f8
wanderleibittencourt/Python_banco_dados
/Modulo-2/Aula2-ClassesHerança/aula1.py
1,667
4.34375
4
# Agora que já conhecemos sobre classes e alguns dos seus comportamentos # Vamos conhecer uma outra pratica muito usada a Herança # Existem dois tipos de Herança # - Herança Simples # - Herança Multipla # Para este curso abordaremos a Herança simples # O que é Herança na programação? # # Herança como o proprio nome ...
false
335c2bdee5d841a95132706f8a5a3924c3ab05f0
Esther-Wanene/training101
/lists.py
1,181
4.46875
4
empty_string = "" my_first_number = 0 empty_list = [] noise_makers= ["Brian", "Mike", 9, True] days_of_the_week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] print(days_of_the_week) number_of_days_in_a_week = len(days_of_the_week) print(number_of_days_in_a_week) # list indexing to ret...
true
90aa42e73081e6f1177ccb48753d847c18243855
Esther-Wanene/training101
/Trainee_task3.py
569
4.40625
4
#Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and #makes a new list of only the first and last elements of the given list. For practice, #write this code inside a function # define the list you want to use as input a = [7,5, 10, 15, 20, 25] # function to slice the list with para...
true
6382d8350f3b9e57274a3154075ab165e089f5d5
NazmulMilon/problem-solving
/if_else_condition.py
302
4.125
4
n=int(input("Enter a integer number:")) if(n%2==0): if (n>=2 and n<6): print("Not Weird") #print("Weird") #elif (n>=2 and n<6): #print("Not Weird") elif (n>6 and n<=20): print("Weird") elif(n>20): print("Not Weird") else: print("Weird")
false
b1de842fe2c8dd3ce6ca046b074ef97b3fcf9571
rRamYah/Python-Basics
/1_Swap2Nos.py
425
4.15625
4
#n1 = 10 #n2 = 20 n1 = input('Enter number 1: ') n2 = input('Enter number 2: ') print('value of number 1 before swapping:', n1) print('value of number 2 before swapping:', n2) #Approach 1 using temporary variables #temp = n1; #n1 = n2; #n2 = temp; # Approach 2 without using temp variable n1,n2 = n2,n1 ...
false
5c33fea35ba7602309c76f301a95950656aedffe
CellEight/Interest-Rate-Prediction
/interestRatePrediction.py
240
4.3125
4
def stringTo3TupleList(string): """Takes as input a string and returns a list of all possible 3-tuples of ajacent words""" output = [] string = string.split() for i in range(len(string-2)): output.append(string[i:i+3]) return ouput
true
d33c6ade75a190274d1b81d472fe55b2b3702ebf
laurmertea/simple-chatty-bot-python-developer
/scripts/simple_counting_interaction.py
1,788
4.53125
5
# Description # Now you will teach your bot to count. It's going to become an expert in numbers! # Objective # At this stage, you will program the bot to count from 0 to any positive number users enter. # Example # The greater-than symbol followed by space (> ) represents the user input. Notice that it's not the part...
true
12f05b5978590f815410b84095b880e3c48c3c0e
jfenton888/AdvancedCompSciCode
/CS550 Fall/September 19/helloWorld.py
490
4.125
4
import sys names = ["John", "Henry", "Palmer", sys.argv[1]] for x in range(0, 3): currentName = names[x] print("Hello, "+ currentName + "!") #if names[3] == "Mrs. Healy" or names[3] == "Healy" or names[3] == "Meghan" or names[3] == "Ms. Hoke" or names[3] == "Mrs Healy": print(names[3].find("Healy")) if names[3] i...
false
a0ae3540f2e8420fb821634146e3cf63b8363221
quanganh1996111/30days-python
/day-09-conditionals/exercise-3.py
363
4.28125
4
# Get two numbers from the user using input prompt. If a is greater than b return a is greater than b, if a is less b return a is smaller than b, else a is equal to b. Output: a=float(input('Nhap a bang: ')) b=float(input('Nhap b bang: ')) if a>b: print('a is greater than b') elif a<b: print('a is smaller than ...
true
052db6ab09a5a9d85d0b54202c84037aa55eb657
Rishabhjain-1509/Python
/Python Project/HomeEx3.py
389
4.25
4
# Area of the triangle Side1 = int( input( "Enter the First side of the triangle = " ) ) Side2 = int( input( "Enter the Second side of the triangle = " ) ) Side3 = int( input( "Enter the Third side of the triangle = " ) ) SSum = ( Side1 + Side2 + Side3 ) / 2 Area = (SSum * ( SSum - Side1 ) * ( SSum - Side2 ) * ( S...
false
b8c68289d8c60b9311eb440f5ba84cd28ce0f94e
jeremysong/rl-book-exercises
/chap_4/jacks_car_rental/jacks_car_rental.py
2,317
4.25
4
"""Jack manages two locations for a nationwide car rental company. Each day, some number of customers arrive at each location to rent cars. If Jack has a car available, he rents it out and is credited $10 by the national company. If he is out of cars at that location, then the business is lost. Cars become available fo...
true
b3cd1a9c0b97e05dc5c1de8eeafbaf665e8e0227
cwdbutler/python-practice
/Algorithms/binary search.py
680
4.15625
4
def binary_search(array, element): # return the index of the element left = 0 right = len(array) while left < right: # this should always be true so it makes the if statements loop mid = (left + right) // 2 if array[mid] == element: # if mid = element we are looking for just ret...
true
99a13ff2ab97c4222f0a82d951b9d843a40fe9c5
adisonlampert/include-projects
/Advanced-Concepts/starter-code/rock-paper-scissors/rockpaperscissors.py
1,365
4.5
4
import random import tkinter #NOTE: A function that determines whether the user wins or not # Passes the user's choice (based on what button they click)to the parameter def get_winner(call): # Access variables declared after the function so that the variables can be changed inside of the function global ...
true
a6659ece35f1f6c0f03446c1a11278f7c25d7288
lin0110/Data-Science---Unit-1-Python
/PythonBreak.py
1,145
4.53125
5
#Scenario #The break statement is used to exit/terminate a loop #Design a program that uses a while loop and continuously asks the user to enter a word unless the user enters “Chupacabra” as the secret exit word. In which case, the message “You’ve successfully left the loop.” should be printed to the screen, and the l...
true
c46c747b079d3422b9646de1390a8670e29257b9
ghostklart/python_work
/08.03.py
277
4.15625
4
def make_shirt(size, text): rmsg = f"You have ordered a {size} size shirt with '{text}' print!" print(rmsg) prompt_0 = "What size are you: " prompt_1 = "What text would you like to have printed on: " size = input(prompt_0) text = input(prompt_1) make_shirt(size, text)
true
1892d459ba8f4a64d381fe10cee41fd6270bf173
ninux1/Python
/decorators/simple_deco1.py
936
4.28125
4
#!/usr/bin/env python """ Plz refer to simple_deco.py for some reference on decorators. This syntax may not be exactly like the decorator but its the same for exact syntax plz refer to actual_deco.py at same location. """ def called(func): # This is a function to receive the function to be modified/decorated. i.e de...
true
2653c8b66067aa50c5701f2bec1c69e468c6b664
rajsingh7/Cracking-The-Machine-Learning-Interview
/Supervised Learning/Regression/question13.py
942
4.3125
4
# When would you use k-Nearest Neighbors for regression? from sklearn import neighbors import numpy as np import matplotlib.pyplot as plt # Let's create a small random dataset np.random.seed(0) X = 15 * np.random.rand(50, 1) y = 5 * np.random.rand(50, 1) X_test = [[1], [3], [5], [7], [9], [11], [13]] # We will use k...
true
d2dbe7bb9c6eee567fb4ad09a449e2ac2a0ac31c
EmirVelazquez/thisIsTheWay
/lists.py
1,716
4.28125
4
# Working with lists basics (similar to an array from JS) random_numbers = [44, 4, 5, 24, 42, 10] office_char = ["Michael", "Jim", "Dwight", "Pam", "Karen", "Toby", "Dwight", "Dwight"] print(office_char) # Return element index 4 print(office_char[4]) # Return element from index 2 and forward print(office_char[2:]) # R...
true
4fd7fe64bf80f30b56911568b72a5cfa2371bb60
Vinodkannojiya/PythonStarter1
/8_Swapping_numbers.py
318
4.125
4
#method 1 Swapping with temp/extra variable a,b=5,2 print("a before is ",a," and b before is ",b) temp=a a=b b=temp print("a after is ",a," and b after is ",b) #Method swapping wothout extra variable c,d=5,2 print("c before is ",c," and d before is ",d) d=c+d c=d-c d=d-c print("c after is ",c," and d after is ",d)
true
db4b0b8eb0c68c5275b092287821c4a45deb47f1
SenpaiPotato/gwc
/chatbot.py
2,169
4.1875
4
import random # --- Define your functions below! --- def introduction(): acceptable_answers = ["hey", "hello", "hi", "holla", "what's up"] answer = input("Hello? ") if answer in acceptable_answers: print("I am nani nice to meet you ") else: print("That's cool!") def rock_paper_s...
true
80531e604b5a016e89fc250874f79126dffb3a76
mikej803/digitalcrafts-2021
/python/homework/shortS.py
265
4.15625
4
strings = ['work', 'bills', 'family', 'vacation', 'money'] def shortest(strings): shortest = strings[0] for i in strings: if i <= shortest: shortest = i print('This is the shortest string:', shortest ) shortest(strings)
true
9cf48628d1fb72c1396ff5e5482e494bfb7ee98d
vtt-info/ECE40862
/glasere_lab1/part1/program3a.py
238
4.15625
4
num = int(input("How many Fibonacci numbers would you like to generate? ")) fib = [1, 1] while len(fib) < num: fib.append(fib[-1] + fib[-2]) fibs = [str(val) for val in fib[:num]] print("The Fibonacci Sequence is: " + ", ".join(fibs))
false
c5ef5a96108672e690cbe1c15b2e0a47660fadbe
SaranyaEnesh/luminarpython
/luminarpython1/regularexpression/quantifiers.py
392
4.25
4
from re import * #pattern="a+"#it check only the position of more than a #pattern="a*"#it check all positions #pattern="a?"#it check all position individually #pattern="a{2}"#chk 2 num of a pattern="a{2,3}"#mini 2 and max 3 num of a matcher=finditer(pattern,"aabaaaabbabbaaaa") count=0 for match in matcher: print(ma...
true
7e63ab3efe3060db6eacb498029fb8971ff9c4e2
SaranyaEnesh/luminarpython
/luminarpython1/operators/arithemeticoperator.py
538
4.125
4
num1=int(input("enter value for num1")) num2=int(input("enter value for num2")) addresult=num1+num2 print("additional rslt=",addresult) num1=int(input("enter value for num1")) num2=int(input("enter value for num2")) subresult=num1-num2 print("sub rslt=",subresult) num1=int(input("enter value for num1")) num2=int(inpu...
false
9b82843212c68e9143b61223a32880523f094253
Jiangfengtime/PythonDemo
/Test02/Class2.py
2,894
4.125
4
# 类中如果属性名和方法名相同的话,属性会覆盖方法 # class C: # def x(self): # print("x-man") # # # c = C() # c.x() # c.x = 1 # print(c.x) # c.x() # 绑定 # class BB: # def printAA(): # print("printAA") # # def printBB(self): # print("PrintBB") # # # BB.printAA() # 如果没有加self,则可以通过类名访问 # # BB.printBB() ...
false
a4e978fb0aa774bc27dfef08caf8767008a5fe16
Jiangfengtime/PythonDemo
/Test02/Turtle.py
2,127
4.15625
4
# class Animal: # # 属性 # legs = 4 # name = 'animal' # shell = False # # 方法 # def run(self): # print('动物向前爬') # # def sleep(self): # print("动物要睡觉") # # # class Turtle(Animal): # # 属性 # color = 'green' # weight = 10 # legs = 4 # shell = True # mouth = '大...
false
9f3a411c0a1d10705d11edb67c292267deafce42
nathphoenix/DataScience
/python/class.py
310
4.28125
4
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # for loop # for number in numbers: # if 5 > 3 : # print(number **2) # for number in numbers: # if number > 3 : # print(number) 10 in numbers # greater_than_three = 5 > 3 # greater_than_three if not 3 > 5 : print('This is weird')
false
a024de3e492cbcfe653c2b6e7a08a9c58c313e98
Mahalakshmi7619523920/Mahalakshmi.N
/maxofthreenumbers.py
218
4.15625
4
def max (a,b,c): if a>b and b>c: l=a elif b>a and a>c: l=b else: l=c return l print("enter three values") a=input() b=input() c=input() l=max(a,b,c) print("largest is",l)
true
b9adbdd32cf3825be8c02145d9c8db7d11deeee0
afarica/Task2.16
/p26.py
426
4.15625
4
# If you were on the moon now, your weight will be 16,5% of your earth weight. # To calculate it you have to multiple to 0,165. If next 15 years your weight will # increase 1 kg each year. What will be your weight each year on the moon next # 15 years? your_weight=float(input("Enter your weight:")) years=int(input("How...
true
87515d27267a8b3e56be0a458a530192473f3a7f
jeromepeng183/Warehouse
/Quadratic_solutions.py
1,276
4.3125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import math # In[8]: def main(): print('This program find the real solutions to a quadratic\n') a,b,c=eval(input('Please enter the coefficients(a,b,c):')) delta=pow(b,2)-4*a*c if delta>=0: discRoot=math.sqrt(delta) root1=(-b+discRoot)...
false
c972456c92ebe364ca07cec941b0de83d664e4bd
INOS-soft/Python-LS-LOCKING-Retunning-access
/3.3 Weighted Independent Set.py
2,175
4.15625
4
""" 3.Question 3 In this programming problem you'll code up the dynamic programming algorithm for computing a maximum-weight independent set of a path graph. This file (mwis.txt) describes the weights of the vertices in a path graph (with the weights listed in the order in which vertices appear in the path). It ha...
true
121db2d5907a4251729c7ecf67ebe77673f90bc4
trainingpurpose/python_exercises
/src/py_exercises/lists.py
339
4.21875
4
# -*- coding: utf-8 -*- from py_exercises.recursion import * def my_last(arr): """Find the last element of a list""" return arr[-1] def my_last_recursive(arr): return head(arr) if not tail(arr) else my_last_recursive(tail(arr)) def my_but_last(arr): """Find the last but one element of a list""" ...
true
691e45c3e27dd22286408a645c9b3de691002632
theamurtagh/exercises
/fibo.py
1,486
4.34375
4
# Ian McLoughlin # A program that displays Fibonacci numbers. def fib(n): """This function returns the nth Fibonacci number.""" i = 0 j = 1 n = n - 1 while n >= 0: i, j = j, i + j n = n - 1 return i # Test the function with the following value. x = 21 ans = fib(x) print("Fibonacci number", x,...
true
315c8e3a35b4cfb73c61ac77cafd96d11d22e9e3
zardra/Book_Catalog
/books.py
2,144
4.5
4
class Book(object): """Class for creating individual book objects. The defaults for bookcase and shelf are empty strings because a book can be created without placing it on a bookcase shelf. The default for the has_read setting is False because it is assumed that books are being cataloged ...
true
2d9092c4d466439da70443d490dbb13fd5fbe574
edimaudo/Python-projects
/daily_coding/coding_bat/Warmup-1/front3.py
315
4.21875
4
#Given a string, we'll say that the front is the first 3 chars of the string. If the string length is less than 3, the front is whatever is there. Return a new string which is 3 copies of the front. def front3(str): if len(str) >= 3: return 3*(str[0]+str[1]+str[2]) else: return 3*str
true
235a331f4571490ddcafe04dddabe5662af7eb0c
edimaudo/Python-projects
/daily_coding/coding_bat/List-2/centered_average.py
1,151
4.1875
4
##Return the "centered" average of an array of ints, which we'll say is the mean average of the values, except ignoring the largest and smallest values in the array. If there are multiple copies of the smallest value, ignore just one copy, and likewise for the largest value. Use int division to produce the final aver...
true
073075a4df76770564bc9de4ddf3e0eb6360f74c
AntonioZZanolli/Calculadora
/calculadora.py
1,067
4.34375
4
print("Super calculadora!!") def soma(numero): numero2 = input("Dígite outro número: ") return print(float(numero) + float(numero2)) def subtracao(numero): numero2 = input("Dígite outro número: ") return print(float(numero) - float(numero2)) def divisao(numero): numero2 = input("...
false
85b30fa9b54a1d41fbd1bccaa44ec96e21f8cade
tanlangqie/coding
/暴力递归与动态规划/不同路径.py
1,698
4.1875
4
[typeq''' 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。 机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。 问总共有多少条不同的路径? 深度优先遍历 栈 递归 ''' class Solution(object): def move(self,m, n): num = 0 if (m == 1 & n == 1): return 1 if (m > 1): num += self.move(m - 1, n) ...
false
501da8583c29b6287991d0bf2f849ce92d8f0980
uykykhj/hometask-2
/hometask076/main.py
326
4.1875
4
sp=[] for i in range(3): n=input('ведите имя') sp.append(n) x = input('Хотите добавить новые имена?') if x=='yes': while x!='no' : n1=input('Введите имя') sp.append(n1) x = input('Хотите добавить новые имена?') print(sp)
false
2b7d614e8999eaed17d15fb4b89c9907d2263044
marangoni/nanodegree
/Rascunhos/Aula 04 - classes - turtle/turtle1.py
808
4.21875
4
# Programa para desenhar um quadrado # # # # # import turtle def draw_square(): zeca = turtle.Turtle() zeca.shape("turtle") zeca.color("yellow") zeca.speed("normal") nsides = 4 for n in range(0, nsides): zeca.forwa...
false
bab6f2a3306cbc34bc355d2b07b1e97238668921
marangoni/nanodegree
/Rascunhos/Lição 12 - Resolução problemas/aniversario.py
1,476
4.1875
4
# Given your birthday and the current date, calculate your age # in days. Compensate for leap days. Assume that the birthday # and current date are correct dates (and no time travel). # Simply put, if you were born 1 Jan 2012 and todays date is # 2 Jan 2012 you are 1 day old. # IMPORTANT: You don't need to solve the p...
true
22b165f8dcee9d2c1caad06e83e45085952cade8
Wanna101/CSC119-Python
/accountBalance.py
863
4.125
4
""" David Young CSC119-479 6/14/2020 Julie Schneider """ def main(): # initial balance is $1000 # 5% interest per year # find balance after first, second, and third year # expected answers: # year 0 = 1000 # year 1 = 1050 # year 2 = 1102.5 # year 3 = 1157....
true
b9d441dfd55730285e13e86e7a476f6ee62c0e7b
dugiwarc/Python
/old/find_factors.py
288
4.1875
4
def find_factors(num): """ parameters: a number returns: a list of all of the numbers which are divisible by starting from 1 and going up the number """ factors = [] i = 1 while i <= num: if num % i == 0: factors.append(i) i += 1 return factors print(find_factors(100))
true
ff90e6c18e4b2de09c1ff1e8c240b87b9e3a7211
kerslaketschool/Selection
/if_improvement_excercise.py
905
4.21875
4
#Toby Kerslake #25-09-14 #selection improvement exercise month = int(input("Please enter a month as a number between 1-12: ")) if month == 1: print("The first month is January") elif month == 2: print("The second month is February") elif month == 3: print("The third month is March") elif month...
true
8dd68555cb736710a37048ec57c3d34d0bf042d1
algorithm006-class01/algorithm006-class01
/Week_02/G20190343010191/LeetCode_144_191.py
906
4.125
4
""" 给定一个二叉树,返回它的 前序 遍历。  示例: 输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,2,3] """ """ 思路: 这周主要练习递归,所以迭代的方法后续再补上 对于N 叉树, 不仅有左子树与右子树 而且是 child1,child2,child3,....childN 于后序而言 先走访 (由左至右) 所有的儿子 最后访问根结点 """ # Definition for a binary tree node. # class TreeNode: # def __init__(self,...
false
570355c3e6194b38f10fc7c0d72d1a829b08c60e
Pranjul-Sahu/Assignment
/Assignment 1 Question2.py
263
4.5
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: #Write a Python program that accepts a word from the user and reverse it. rev_word = input() print("Enter the Word -", rev_word) reversed_word = rev_word[-1::-1] print("After reversing the word -",reversed_word)
true
91427a056a6b775cc3a27efba4e79939b8d495eb
JacobFrank714/CSProjects
/cs 101/labs/lab07.py
2,114
4.5
4
# ALGORITHM : # 1. display the main menu and ask user what task they want performed # 2. check what their answer is # 3. depending on what the answer is, ask the user what the want encoded/decoded or quit the program # 4. ask how many numbers they want to shift the message by # 5. p...
true
a2b93cfc53ae35c80dba5f35d37c9832d49604bd
JacobFrank714/CSProjects
/cs 101/programs/program 1.py
1,393
4.3125
4
#Jacob Frank, session 0002, Program #1 #getting the values of all the ingredients for each recipe set recipe_cookies = {'butter':2.5, 'sugar':2, 'eggs':2, 'flour':8} recipe_cake = {'butter':0.5, 'sugar':1, 'eggs':2, 'flour':1.5} recipe_donuts = {'butter':0.25, 'sugar':0.5, 'eggs':3, 'flour':5} print('Welcome t...
true
1606161e3c414654b506c6879b60761229ed0244
mandarvu/project_euler
/python3/prob19.py
1,598
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jul 20 20:13:15 2020 @author: mandarupasani projecteuler.net problem 19 : Counting Sundays """ n_months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, ...
false
1fb7869848da06f165db950213f1d56ac07524d7
joshuajweldon/python3-class
/exercises/ch08/calc.py
1,020
4.15625
4
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x*y def divide(x, y): try: r = x / y except ZeroDivisionError: r = "Undef." return r operators = { '+': add, '-': subtract, '*': multiply, '/': divide } input("Calcula...
true
49df67062148f557043a9005b57a7ca95b8c8ae5
General-Blue/Intro-to-Python
/py_basics_1.py
466
4.1875
4
# print hello to the world print("hello world") # ask the user of your program their name and save it into a variable x = input("What is your username? ") # say hello to the user print("hello "+ x) # import the random library import random # use the random library to save a random number into a variable x = random.rand...
true
685c3c74dd8bf3a85f02ebff4e51e5d80d124f82
juliakastrup/estudos
/Ex016.py
473
4.25
4
#criar um program aque ao ler um numero quebrado (ex: 6.13652) mostre sua porção inteira (ex: 6) import math num = float(input('Digite um numero: ')) a = math.trunc(num) print('O numero arredondado de {} é {}.'.format(num, math.floor(num))) # poderia ser usado a variável com o math.floor(num) ou math.trunc ao invés de ...
false
786ad1354e9d9a8ed76fd34cce4d72c2ede568d4
isidoraorellana/IntensivoNivelacion
/26082019/000500.py
489
4.1875
4
# -*- coding: utf-8 -*- """ """ e = {"George": 24, "Tom": 32} #se crea diccionario #valores pueden ser de cualquier tipo #las keys generalmente son strings o numeros e[10] = 100 #se agrega una key que es un numero asociado a un valor que tambien es un numero print e #iterar en pares key-valor for key, va...
false
5fa811d85c8c128549e67f391425a37f164363a3
aakashp4/Complete-Python-3-Bootcamp
/ch01_overview/task1_2_starter.py
1,348
4.6875
5
""" task1_2_starter.py For this task, you are to manually extract the domain name out of the URLs mentioned on our slide. The URLs are: https://docs.python.org/3/ https://www.google.com?gws_rd=ssl#q=python http://localhost:8005/contact/501 Additional Hints: 1. Prompt for a URL input ...
true
721df54252575dfe9319dee08d2fac9f19f7a2c5
memelogit/python
/module3/numpy - reshape.py
218
4.1875
4
# RESHAPE # ------- import numpy as np arreglo = np.array([2, 3, 9, 4, 6, 7, 2, 1, 0]) print(arreglo.shape) # transforma el arreglo 9, en uno de 3x3 arreglo = arreglo.reshape(3,3) print(arreglo.shape) print(arreglo)
false
ee32e2ec51a0e67de543feca29072aaed27a606b
memelogit/python
/module1/control - actividad if.py
627
4.1875
4
# ACTIVIDAD # --------- # 1.- Escribir un programa que pida al usuario dos números y muestret # por pantalla su división. Si el divisor es cero el programa debe # mostrar un error n = float(input('Introduce el dividendo: ')) m = float(input('Introduce el divisior: ')) if m == 0: print('¡Error! No se puede dividir...
false
b2f2f3f0e57dd0a23e8a55cbe46a847d895c0ce5
vinozy/data-structures-and-algorithms
/interviews/reverse-LL/linked_list.py
1,396
4.15625
4
from node import Node class LinkedList: """ create a linked list """ def __init__(self, iterable=[]): """Constructor for the LinkedList object""" self.head = None self._size = 0 if type(iterable) is not list: raise TypeError('Invalid iterable') for ...
true
7fc2af4757d2fbce2d4281ce60fd73113963db01
vinozy/data-structures-and-algorithms
/interviews/reverse-LL/reverse_ll.py
666
4.125
4
from linked_list import LinkedList as LL from node import Node # def reverse_ll(list1): # """Reverse a singly linked list.""" # current = list1.head # list2 = LL() # while current is not None: # # list2.insert(current) # list2.head = Node(current.val, list2.head) # current = cu...
true
1f355ae733498d81e81f2192451550b24b0427f8
vinozy/data-structures-and-algorithms
/data_structures/binary_search_tree/bst_binary_search.py
596
4.375
4
def bst_binary_search(tree, value): """Use binary search to find a value in a binary search tree. Return True if value in tree; return False if value not in tree.""" if not tree.root: return False current = tree.root while current: if current.val == value: return True ...
true
27b78e6e7bd39d439dc0437aeb61205f157435dd
Karan-21/Database
/database.py
1,576
4.375
4
# name,address,phone # 1) add data 2) show data 3) delete data name = [] address = [] phone = [] while True: print("1. Add data\n2. Show data\n3. Delete data\n4. Exit") ch = int(input("Enter your choice:")) if ch == 1: # while n.isalpha() == False: n = input("Enter ...
false
ffba3a558382e3802c9c3437b90df9d983f26bc3
Amazon-Lab206-Python/space_cowboy
/Fundamentals/fun.py
729
4.5
4
# Odd/Even: # Create a function called odd_even that counts from 1 to 2000. As your loop executes have your program print the number of that iteration and specify whether it's an odd or even number. def odd_even(x): for x in range(1,2001): if (x % 2 == 0): print "This is an even number." ...
true