blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ad192701a9d26d6324acd9d85ec8af2711fd1b8a
linpeijie-python/linpeijiecode
/python_practice/demo1.py
1,832
4.15625
4
""" 题目: 一个多回合制游戏,每个角色都有hp 和power, hp代表血量,power代表攻击力,hp的初始值为1000, power的初始值为200。打斗多个回合 定义一个fight方法: my_hp = my_hp - enemy_power enemy_hp = enemy_hp - my_power 谁的hp先为0,那么谁就输了 """ """ 思路: 1、自定义一个关键字函数,后续调用关键字函数可以输入对应的角色血量值和角色的攻击力 2、定义方法fight,游戏规则: 初始化回合数 角色血量=初始血量-对方攻击力 每一轮攻击完成后使用while(true)进行比较,判断是否有角色血量为0 ...
false
504d10f25cf93020095f593154fda4f8f0b296e8
AbrahamdelaMelena/PC4Datux
/MODULO 02/Modulo_02_Ej_01_Abraham_dela_Melena.py
2,829
4.25
4
""" Realizar una función que permita la carga de n alumnos. Por cada alumno se deberá preguntar el nombre completo y permitir el ingreso de 3 notas. Las notas deben estar comprendidas entre 0 y 10. Devolver el listado de alumnos. """ encabezado = ["NOMBRE", "APELLIDO", "NOTA 01", "NOTA 02", "NOTA 03"] lista_alumno...
false
042f57686f14c99820de9f91218d3a7ff4b994e5
katel85/Labs-pands
/labsweek07/quizB.py
726
4.28125
4
# the with statement will automatically close the file # when it is finished with it with open("test-b.txt", "w") as f: data = f.write("test b\n") # returns the number of chars written print (data) #with open("test-b.txt", "w") as f2: # open file again # data = f2.write("another line\n") # print (data) ...
true
261280bfba8cf9a15f3168a46132b3fc46068910
katel85/Labs-pands
/labsweek06/week06-functions/Menudisplay.py
716
4.28125
4
# Write a program that will keep displaying menu until the user chooses to quit. Call a function for A called do add() # call a function for V if the user chooses to view called do view(). # Catherine Leddy def displaymenu () : print("what would you like to do?") print("\t(a) Add a new student") print("\t(v) Vi...
true
53d6088de5a24a7a52af91768dc30bf34a58ce5e
katel85/Labs-pands
/labsweek02/Lab2.2/hello2.py
787
4.25
4
# ask for name and set up for reading out name in response to prompt # Kate Leddy name= input('What is your name') print ('Hello ' + name) #first pose the question this is the input # In order to save the answer to the question it must be saved as "name " = input age= int(input('Hey what is your age?:')) newNumber...
true
b4d45800e40d2fc5e1c661aacb32960a63ded9a4
shayroy/ChamplainVR
/Week 7/Class1/Class_review.py
902
4.3125
4
class Shape: colour = "" # colour is an attribute of Shape # Constructor def __init__(self, input_colour): # variable colour that we input # how do we set the colour to the input_colour. We have to use Self.colour = input_colour self.colour = input_colour # if we want shape to do so...
true
faad8b7f53bde558d0c5f720dc7d5a2cc41b3cad
shayroy/ChamplainVR
/Assignments/Order_System_Team/Input_From_User.py
2,290
4.125
4
from Item import Item from Order import Order answer_string = "" users_new_order = Order() while answer_string != "FIN": answer_string = input("\nWhat do you want to do next?"+ "\n\tTo add a new item to your order type 'ADD'"+ "\n\tTo delete any item from your or...
true
380772852b0996806e2594b22a2af4e08efdc47a
shayroy/ChamplainVR
/Week 10/Class1/TestDir.py
484
4.28125
4
import os dirname = "TestDir" def create_dir_if_not_existing(name): """Checks the existance of a directory and creates it if necessary.""" if not os.path.isdir(name): # if not statement is negation of if statement. # can also use and add another part, such as another if not os.mkdir(name) ...
true
95e1950dc090d4fa0d7caa575ea2fcad4115d91b
shayroy/ChamplainVR
/Week 3/Class 1/review strings.py
451
4.34375
4
#Uppercase, Titlecase, lowercase, length and replacement are important. #for length "The Length of the string is x". #for replacement, he would like us to change all "!" to ".". myString = input(">") print(myString.upper()) print(myString.title()) print(myString.lower()) print(">the length of the entered string is " + ...
true
56ba88a7773b328e42b979090c850a25865a4db9
shayroy/ChamplainVR
/Week 5/Class1/iterate_over_list.py
602
4.375
4
# see printing all keys and values slide #for x in countries: # print(x) # # to print keys, values and items (which prints both keys and values): countries = {'us': 'USA', 'fr': 'France', 'uk': 'United Kingdom'} for k, v in countries: print(k,v) print ("------------") for i in count...
true
69e99ef3541c8affa35caba01b26ff8454bbb1fb
saikumargu/EDA
/Functions.py
1,234
4.3125
4
#Functions def square(num): out = num**2 return(out) square square(7) square(9) q = square(4) print("Square of number is "+str(q)) def factorial(n): if n>1: return n*factorial(n-1) else: return n fact = factorial(5) print(fact) def factorial(n): if n>1: ...
true
f535ff6aac32d39c32f89a6b16b87e9337e85bce
edelvandro/Python
/condicionais/exer036.py
946
4.1875
4
''' Escreva um programa para aprovar um empréstimo bancário para a compra de uma casa. O programa vai perguntar o valor da casa, o salário do comprador e em quantos anos ele vai pagar. Calcule o valor da prestação mensal, sabendo que ela não pode exceder 30% do salário ou então empréstimo será negado. ''' ...
false
d1ce9a494bac48ded881380bfaf3ba9479f27298
deeprane1/Basics
/setexer.py
889
4.5625
5
#Sets - Exercise #1. Check if ‘Eric’ and ‘John’ exist in friends #2. combine or add the two sets #3. Find names that are in both sets #4. find names that are only in friends #5. Show only the names who only appear in one of the lists #6. Create a new cars-list without duplicates friends = {'John','Michael',...
true
de67e0e3476b1aa3783ee7081906c585f54ef152
deeprane1/Basics
/ifelexer.py
569
4.1875
4
mode = input('Enter math operation(+,-,*,/) or f for Celsius to Fahrenheit conversion: ') a = float(input('Enter first number: ')) if mode.lower() == 'f': print(f'{a} Celsius is equivalent to {(a*9/5)+32 } fahrenheit') else: b = float(input('Enter second number: ')) if mode == '+': print(f'...
false
7c0b21f3e2d15be9b90b025696abb5379ee11627
thulethi/grokking-algorithms
/python/selection_sort.py
445
4.25
4
# Sort an array from smallest to largest def find_smallest(arr): smallest = arr[0] smallest_index = 0 for i in range(1, len(arr)): if arr[i] < smallest: smallest = arr[i] smallest_index = i return smallest_index def selection_sort(arr): new_arr = [] for i in range(len(arr)): smallest_...
true
ad520839492f31eaf65efc14bbcb2b36c219bf02
reazwrahman/DataStructureAndAlgorithmProblems
/search and sort algorithms/selection_sort.py
1,065
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 1 17:04:56 2020 @author: Reaz selection sort algorithm Documentation: We start by assuming that the first element is the smallest one. Then we look for something smaller in the list. If we find a smaller number we swap it with our assumed val...
true
0591afafec2c5e60f43e9972ecedca6a0ba5f4c2
Hieumoon/C4E_Homework
/Session05/Homework/Homework5_exercise3.py
319
4.375
4
# Write a Python function that draws a square, named draw_square, takes 2 arguments: length and color, where length is the length of its side and color is the color of its bound (line color) import turtle def draw_square(length,colorr): color(colorr) for i in range(4): forward(length) left(90)
true
05ea50b9397485c4184faa0d2deda49a799eff84
gagemm1/Machine-Learning-Experimentation
/Regression/Simple Linear Regression/your work.py
2,197
4.375
4
""" simple linear regression: y = b(0) + b(1)*x(1) just like the equation for a slope y = mx + b just keep in mind which is the dependent/independent variables """ #first we'll pre-process the data just like we did before # Importing the libraries import numpy as np import matplotlib.pyplot as plt import...
true
35d749186a281eb328afd537249683d56b2be334
SummerGautier/sorting-algorithms
/bubblesort.py
1,908
4.21875
4
#Description: Recursive and Iterative Bubble Sort Implementations #Author: Summer Gautier #Date: May 10th 2020 import unittest #Recursive def recursiveSort(listOfItems:list, size: int)-> list: if(size == 1): return listOfItems #do a single pass of the bubble sort algorithm for index,item in enumer...
true
7a71d9c7da2476f52ca1f6070bbfb5449945ba1e
JOYFLOWERS/joyflowers.github.io
/github unit 1/Mod 5/sierra_python_module04-master orig/1_function_basics.py
1,655
4.4375
4
# Function Basics # function # A function is a named series of statements. # function definition # A function definition consists of the new function's name and a block of statements. # function call # A function call is an invocation of the function's name, causing the function's statements to exec...
true
1f61dc59136c46a693da96873504486e6a95b767
JOYFLOWERS/joyflowers.github.io
/github_unit_1/Mod_4/collz.py
797
4.5625
5
# Joy Flowers # 09/24/19 # This program shows the Collatz sequence. If the number is even, # divide it by 2 (no remainder) and if it is odd, multiply by 3 and add 1. # Also, make sure that only an integer is entered. while True: try: number = int(input('Enter number: ')) break except ValueError...
true
3ff95f1a91d0cc957e4f43c1eadee7552b12bf5d
sruthinamburi/K2-Foundations
/selectionsort.py
417
4.21875
4
#sorts a list in ascending order using selection sort strategy list = [6,2,1,4,6,0] length = len(list) def selectionsort(list): for i in range (0, length-1): minval = i for j in range(i+1, length): if list[j] < list[minval]: minval = j if minval!=...
true
e7a553e8a77ddb5963c6d7e71fdaf4c7f82b42af
zhanggiene/LeetCode
/88.py
843
4.21875
4
#merge sorted array ''' the trick is to sort from behind. [1,2,3,0,0,0] sort from behind so that there will always be spaces [3,4,5] ''' class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. ...
true
5011667bc901aa2fd7e45f1979f4eb0e6fd29c10
Silentsoul04/my_software_study
/SSAFY/week8_SQL,STRING/Day4/홍길동/ex.py
854
4.375
4
# 파일명 변경 금지 # 아래에 클래스 Point와 Circle을 선언하세요. class Point: def __init__(self, x, y): self.x=x self.y=y class Circle: def __init__(self,center,r): self.center=center self.r=r def get_area(self): return round(3.14*self.r*self.r,2) def get_perimeter(self): ...
false
e54852934ecb9d757819bbdf4fd8f46d92d36426
maydhak/project-euler
/028.py
1,258
4.25
4
""" Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 It can be verified that the sum of the numbers on the diagonals is 101. What is the sum of the numbers on the diagonals in a...
true
01257b2968f85147cc8809e6a1fd387340bd42a8
maydhak/project-euler
/009.py
1,007
4.1875
4
""" Problem 9: A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ """ Before writing the solution, here is what I came up with: ...
true
8eccdb60130b928fc5639bb141425c10c6da70f9
maydhak/project-euler
/019.py
2,022
4.21875
4
""" You are given the following information, but you may prefer to do some research for yourself. - 1 Jan 1900 was a Monday. - Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. - A leap year o...
true
fc1bdcfb3d3a14ba0c31a005ef9cc5870cbd6e7c
jhoncbox/PythonPractice
/Bootcamp/Regular Expressions -re/regularExpressions.py
2,863
4.375
4
import re # example with searching patterns using re.search() patterns = ['term1','term2'] text = 'this is a string with term1, and term1, but not the other term' for pattern in patterns: print('searching for "%s" in: \n"%s"' % (pattern, text),) # check for match if re.search(pattern, text): prin...
true
1136b377930e250ef2d9e8233e3a71e81130c9a0
nukarajusundeep/myhackerrank
/Forked_Solutions/Indeed_Prime_Codesprint/ultimate_question.py
1,670
4.46875
4
""" 42 is the answer to "The Ultimate Question of Life, The Universe, and Everything". But what The Ultimate Question really is? We may never know! Given three integers, a, b, and c, insert two operators between them so that the following equation is true: a (operator1) b (operator2) c = 42. You may only use the ad...
true
c601f6260a9263573713d4c14c39a535da8f3d52
EasterGeorge/PythonGames
/madlibs.py
698
4.4375
4
"""" The program will first prompt the user for a series of inputs a la Mad Libs. For example, a singular noun, an adjective, etc. Then, once all the information has been inputted, the program will take that data and place them into a premade story template. You’ll need prompts for user input, and to then print out th...
true
6f80000495ab222d1e73fd054f9793862992b09f
khang-le/unit4-05
/U4_05.py
729
4.25
4
#!/usr/bin/env python3 # Created by: Khang Le # Created on: Sep 2019 # This program does some calculation def main(): # comment su = 0 user_input = input("Enter how many time u want to add numbers: ") print("") # process & output try: user_number = int(user_input) for loop...
true
b8bf4db6efd89d3b3e44af0324263683f6094b10
zsannacsengeri/Happines-calculator
/Happiness_calculator.py
2,898
4.125
4
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("This program is going to calculate your happiness!") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("You should go though 7 questions.\nPlease select 1, 2 or 3 for answer...
true
344f6de3fc5a30b875e2c016b8bb4a3680c8367b
hirenpat/Python
/problem_set_1/ps1c.py
1,240
4.1875
4
#ps1c starting_salary = float(input('Enter the starting salary: ')) saving_rate = 0 total_cost = 1000000 semi_annual_raise = 0.07 portion_down_payment = 0.25*total_cost monthly_salary = starting_salary/12 r = 0.04 number_of_months = 0 total_salary = 0 while number_of_months < 36: if number_of_months % 6 == 0: ...
true
16939702bb50a76028cc8a7130d0a27b81fa585a
declanohara123/Weekly-Tasks
/Integer/Interger.py
370
4.375
4
# file where if you input a number, the program halves it if it is even, but tripples itand adds one if the number is odd a = int(input("Please enter a positive integer: ")) b = int (2) print (a , end=' ') while a > 1: if a % b == 0: a /= 2 print (a, end=' ') else: a = (a * 3) + ...
true
2d96707effcd964401025d837e181ed5da4cfb4c
bunshue/vcs
/_4.python/test02_if_else.py
1,635
4.125
4
# for-loop while-loop if-else print("語法 : while") a = 0; story = ""; while a < 10: a = a + 1; story += "hello" + " " #print("hello") #print(""); #空白一行 print(story) print("語法 : if-else") ans = input("Are you all right? ") if ans == "Yes": print("Great") elif ans == "yes": print("Yahoo") else: ...
false
272677d325e0890413ce815d4dd57a7330e272ab
bunshue/vcs
/_4.python/test00_syntax3_set.py
2,385
4.21875
4
set1 = {"green", "red", "blue", "red"} # Create a set print(set1) set2 = set([7, 1, 2, 23, 2, 4, 5]) # Create a set from a list print(set2) print("Is red in set1?", "red" in set1) print("length is", len(set2)) # Use function len print("max is", max(set2)) # Use max print("min is", min(set2)) # Use min print("sum is"...
true
87b85139e726c696a6ba31f6f48f45d59cbfd9b1
bunshue/vcs
/_4.python/_example/word_count/CountOccurrenceOfWordsFromFile.py
1,111
4.125
4
print('統計英文單詞出現的次數') # Count each word in the line def processLine(line, wordCounts): line = replacePunctuations(line) # Replace punctuations with space words = line.split() # Get words from each line for word in words: if word in wordCounts: wordCounts[word] += 1 else: ...
true
7c8398aea4cbb08cea8b4dab14015a529b502fca
bunshue/vcs
/_4.python/__code/tkinter-complete-main/2 layout/2_4_place.py
1,506
4.25
4
import tkinter as tk from tkinter import ttk # window window = tk.Tk() window.title('Place') window.geometry('400x600') def button1_click(): print('你按了Button 1') def button2_click(): print('你按了Button 2') # widgets label1 = ttk.Label(window, text = 'Label 1', background = 'red') label2 = ttk.Label(window, t...
true
83d4e602122ee0e6739c0cf7da40f4be20d9987d
bunshue/vcs
/_4.python/__old/turtle/turtle05.py
1,618
4.1875
4
import turtle def drawShape(sides, length): #畫多邊形 angle = 360.0 / sides for side in range(sides): turtle.forward(length) turtle.right(angle) def moveTurtle(x, y): turtle.penup() turtle.goto(x, y) turtle.pendown() def drawSquare(length): #畫正方形 drawShape(4, length) d...
true
30807fcce80097c000a86deebc2e42d7cd8be82a
ramoso5628/CTI110
/P5T2_ FeetToInches_OctavioRamos.py
550
4.3125
4
# Feet to Inches # 9 July 2019 # CTI-110 P55T2- Feet to Inches # Octavio Ramos # One foot equals 12 inches. # Write a program that will take a number of feet as an arguement and returns the number in inches # The user will be prompted to add the number in feet and the result will display in inches. inches_pe...
true
73dead08d7bb52ea1630d57635be2cafc51b3102
anyuhanfei/anyuhanfei-python-study
/other/python进阶实例/类与对象/派生内置不可变类型.py
902
4.28125
4
''' 派生内置不可变类型并修改其实例化行为 ''' ''' 定义一种新类型的元组,对于传入的迭代对象,只保留int类型且值大于0的元素 要求IntTiple是内置tuple的子类. tuple元组是__new__()魔法方法创建出来的,所以在__init__()魔法方法执行时,这个元组已经完成了创建 ''' class IntTuple(tuple): ''' 新类型的元组,对于传入的迭代对象,只保留int类型且值大于0的元素 ''' def __new__(cls, iterable): ''' 最先执行,筛选数据并创建元组 ''' g = (x...
false
d3c7854ad3340fe0e0f36ed75101931c2d5c6e3f
anyuhanfei/anyuhanfei-python-study
/other/python进阶实例/数据结构/元组元素命名.py
912
4.3125
4
''' 为元组中的每个元素命名,提高程序可读性 ''' ''' 学生信息系统中数据为固定格式:(名字,年龄,性别,邮箱地址) 学生数量很大,为了减少存储开销,对每个学生信息用元组表示 访问时,使用序列索引(index)访问,大量序列索引降低程序可读性,如何解决? ''' student = ('Jim', 18, 'male', '1234567@qq.com') ''' 方法1:定义常量,常量赋值为这些序列索引值(类似其他语言的枚举类型) ''' NAME, AGE, SEX, EMAIL = range(4) print(student[AGE]) # student[1] ''' ...
false
3603e8d09abd206f6466342826bdf1a9a31505f9
sulaiman666/Learning
/Language/Python/Input_Name.py
304
4.375
4
name = input("Enter your name: ") # If you want to take input from user you can use input function age = int(input("Enter your age: ")) # If you want a specific type of input from user you need to declare input fucntion as an integer print("Your name is:", name) print("Your age is:", age, "years old")
true
bacc9c68453826669e10d5a78270b9067996ccec
BramWarrick/Movie_Database
/media.py
1,284
4.375
4
# Lesson 3.4: Make Classes # Mini-Project: Movies Website # In this file, you will define the class Movie. You could do this # directly in entertainment_center.py but many developers keep their # class definitions separate from the rest of their code. This also # gives you practice importing Python files. import webb...
true
7fcb3486f0cf81f8bd5634494af8c86b3f8eb7f5
Sakshi2000-hash/Python-Dictionary
/UI.py
2,009
4.1875
4
import tkinter from tkinter import * from tkinter import messagebox import json data = json.load(open("data.json")) window = Tk() window.title("Find Your Words Here!") def search(): val = word_value.get() val = val.lower() if val in data: display_text.insert(END,data[val]) ...
true
759e1a1dfc6292b7a431ed7b0d17facf1dd592bd
yamendrasinganjude/200244525045_ybs
/day2/ConsecutiveNumSumRowWise.py
234
4.28125
4
''' 1 3 5 7 9 13 ... so on consecutive odd numbers suppose user gives row 2 then 3 + 5 = 8 so 8 is output ''' def row_wise_sum(num): return num ** 3 num = int(input("Enter a Num: ")) print("Sum is ",row_wise_sum(num))
false
d2122d9b06ae294a210c17cd9fdb01a924931855
yamendrasinganjude/200244525045_ybs
/day1.1/kidsAgeCheckAllowedOrNot.py
245
4.1875
4
''' its simple kids school eg: if kids between 8 to 12 then they are allowed otherwise not allowed ''' num = int(input("enter ur age:")) if num >= 8 and num <= 12: print("Welcome, U r allowed....") else: print("U r not allowed....")
true
9b231303febda81772454967e97fa2d156d3dd60
yamendrasinganjude/200244525045_ybs
/day8/LambdaSquCube.py
330
4.25
4
''' 5. Write a Python program to square and cube every number in a given list of integers using Lambda. ''' lst = list(map(int, input().split())) print("List :\n", lst) squareList = list(map(lambda x: x*x, lst)) print("Square Of List :\n", squareList) cubeList = list(map(lambda x: x**3, lst)) print("Cube of List :\n",...
true
4487065cbefc89779baad509f1ca5901556b3682
Ripsnorter/edX--6.00.1x-CompSci-2013
/L6_Problem_02.py
605
4.15625
4
''' L6 Problem 2 ------------ Write a procedure called oddTuples, which takes a tuple as input, and returns a new tuple as output, where every other element of the input tuple is copied, starting with the first one. So if test is the tuple ('I', 'am', 'a', 'test', 'tuple'), then evaluating oddTuples on this input wo...
true
e22751d4d5f9f513b0ca93d77c1ca404f6c8447e
DrBuddyO1/UT-MCC-VIRT-DATA-PT-08-2021-U-B
/Module-3_Python_Fundamentals/1/04-Ins_List/Solved/lists.py
606
4.3125
4
# Create a variable and set it as an List myList = ["Jesse","Tarana",5] # Adds an element onto the end of a List myList.append("Matt") # Returns the index of the first object with a matching value # Changes a specified element within an List at the given index myList[0] # Returns the length of the List # Remov...
true
8598d58efd83583615f0a13fd4874c6b2a43010d
Rui-FMF/FP
/Aula04/dates.py
1,923
4.28125
4
# This function checks if year is a leap year. # It is wrong: 1900 was a common year! def isLeapYear(year): return (year%4 == 0 and year%100 != 0 ) or (year%100 == 0 and year%400 == 0) # A table with the days in each month (on a common year). # For example: MONTHDAYS[3] is the number of days in March. MONTHDAYS =...
true
d7ef5d90def8eb0115963445368c515dd142587c
Rui-FMF/FP
/AulaX/twitter.py
841
4.15625
4
# Este programa demonstra a leitura e utilização de dados de um ficheiro JSON # com mensagens do Twitter. # Modifique-o para resolver o problema proposto. # O módulo json permite descodificar ficheiros no formato JSON. # São ficheiros de texto que armazenam objetos compostos que podem incluir # números, strings, list...
false
d30e421050f8d9b28da2626d1eb51929d0baca53
jayala-29/python-challenges
/advCalc2.py
2,832
4.15625
4
# function descriptor: advCalc2() # advanced calculator that supports addition, subtraction, multiplication, and division # note: input from user does NOT use spaces # part 2 of building PEMDAS-based calculator # this represents parsing an expression as an algorithm # for operations in general, we go ...
true
80b5f2c9d94be3af52a17ceab18881721189aa39
clc80/cs-module-project-iterative-sorting
/src/searching/searching.py
1,237
4.34375
4
def linear_search(arr, target): # Your code here for i in range(len(arr)): if target == arr[i]: return i return -1 # not found # Write an iterative implementation of Binary Search def binary_search(arr, target): # Your code here first = 0 last = (len(arr) - 1) found ...
true
527b524f5cc2cea6f5bd02f801e5d22328e9ea48
arpit-omprakash/CipherX
/cipherx/__main__.py
2,922
4.25
4
doc_string = """ Encrypt or Decrypt a provided file. The program takes in one file as an input, encrypts (or decrypts) it and saves the output as another file. ----------------------------------------------- The following cipher options are supported till now: 1 = Caesar Cipher 2 = ROT 13 Cipher ----------------------...
true
0a079e932af4e80b238c922685a6c154b4e7492e
aafreen22/launchpad-assignments
/pgm5.py
418
4.40625
4
# this program asks the user for a string and displays it in reverse order str = input("Enter a string:: ") list = str.split() #converts the string to a list rev = list[::-1] #reverses the list resu = "" for val in rev: resu = resu + " " + val #creates a string from the reverse of the list res = resu[1::] #removes fir...
true
e73be53c5870878ab396263b03b34d3c76d8c556
suku19/python-associate-example
/module/random_module.py
2,196
4.625
5
from random import random, seed ''' The most general function named random() (not to be confused with the module’s name) produces a float number x coming from the range (0.0, 1.0) –in other words: (0.0 <= x < 1.0). ''' print("random():::") for i in range(5): print(random()) ''' Pseudo-random number ge...
true
b64199ff0017c04675488835f4b3a7d512d1faad
suku19/python-associate-example
/functions/function_intro.py
660
4.25
4
# Write Fibonacci series up to n def fib(n): """Print a Fibonacci series up ro n.""" a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a + b print() # Now call the function we just defined: fib(2000) def fib2(n): # return Fibonacci series up to n """Return...
true
5e231cb48ca959af6481d2d32318446f703ebe37
suku19/python-associate-example
/classes/Inheritance/instance_method.py
2,146
4.3125
4
print("::Find the valid subclass : issubclass()::") class Vehicle: pass class LandVehicle(Vehicle): pass class TrackedVehicle(LandVehicle): pass for cl1 in [Vehicle, LandVehicle, TrackedVehicle]: for cl2 in [Vehicle, LandVehicle, TrackedVehicle]: print(issubclass(cl1, cl...
false
d8c1a54ccafbf6e8c3edc12c7824d3e66a5972bb
ammonshepherd/learning-python
/alpha-shift.py
615
4.21875
4
# TODO: # - make it work with lowercase letters, too def alphaShift(shift): for i in range(65,91): print(chr(i), end='') print() for i in range(65, 91): z = i + shift if z > 90: print(chr(z - 26), end='') if z <= 90: print(chr(z), end='') print() ...
false
ca608aab3d7a8fc4161c7254b51356a83a3d1552
lei-hsia/LeetCode
/341.FlattenNestedList_iterator.py
1,426
4.125
4
''' This is the interface that allows for creating nestedIterator you should not implement it, or speculate about its implementation ''' class NestedIngeter(object): def isInteger(self): ''' @return True if this NestedIngeter holds a single integer, rathen than a nested list. :rtype ...
true
0294a624b7a356f40544aafdfce80e1300b1876e
asheemchhetri/pythonClass
/Section 1/zip.py
875
4.71875
5
# >>> Zip: We use zip to combine multiple iterables into a single iterator, which is very helpful when we iterate through in a loop by expansion. # Returns a list of tuple # Note: Iterators can only be use ONCE, to save memory by only generating the iterators as we need them, rahter storing them in memory country = ['I...
true
f420a0c862dc51af92029904ff52f55734c9a439
Chupalika/Kaleo
/tools/integersearch.py
1,350
4.21875
4
#!/usr/bin/python #This tool searches for an integer value in a binary file by converting both to binary and comparing substrings of the binary file to the target binary #Argument 1: binary file name #Argument 2: target integer value from __future__ import division import sys #Converting a byte to binary apparently...
true
7c98cf3aeb49691a438392fe1f24da5bb23846f3
satishhirugadge/BOOTCAMP_DAY11-12
/Task1_Question4.py
316
4.34375
4
# 4. Write a program to print the value given # by the user by using both Python 2.x and Python 3.x Version. user1=input("Hey, What is your name???") print(user1) age1=int(input("What is your age???")) print(age1) # way to run on the python 2. # user2=raw_input("Hey, What is your name???") # print(user1)
true
f75d793ce584968faf5e83be54ef74398a557516
IvanovskyOrtega/project-euler-solutions
/solutions/004_largest_palindrome_product.py
1,414
4.34375
4
"""Solution to Project Euler Problem 4.""" def is_palindrome(n: int) -> bool: """is_palindrome. This function determines if a given integer number is a palindrome or not. Arguments --------- n : int The number to check if is palindrome. Returns ------- bool : `True` if i...
true
1624640bce16514ef264e08d3e8e61d91565b199
Heladitooo/challenges-Python
/challenge2/oddIndexs.py
829
4.1875
4
""" RETO 2: Diseña un programa que elimine de una lista todos los elementos de índice par y muestre por pantalla el resultado. (Ejemplo: si trabaja con la lista [1,2,1,5,0,3], ésta pasará a ser [2,5,3].) """ def oddIndexs(array): #saca los índices impares, o sea no el número si no la posición en la ...
false
54cbc490ae7023113e2692f86ba55c45e15f7fc6
Mahendra522/4Fire
/python/printInReverse.py
367
4.5
4
# Python program to print elements in the Reverse order array = [0]*30 n = 0 n = int(input("Enter number of elements you wanted to insert: ")) print("\n") print("Enter each number one by one: \n") for i in range(n): array[i] = int(input()) print("Printing Elements in the reverse order: \n") for i in reverse...
true
9d59fc835a3bf9bdb7c16f90e953a3e75974734d
Cjeb24/CreditCardCheck
/creditcardcheck.py
1,741
4.15625
4
#credit card validation program number = [] creditCard=str(input("please enter your credit card number(13-16 digits):")) number.append(creditCard) sumEven = 0 sumodd = 0 # Return True if the card number is valid def isValid(number): sumOfDoubleEvenPlace(number) sumOfOddPlace(number) prefixMatched(...
true
fea36651929c097b6376e4476b499d1f430ca623
RebeccaML/Practice
/Python/Games/rockPaperScissors.py
1,041
4.34375
4
# Project from https://www.udemy.com/the-modern-python3-bootcamp/ # Two player version print("Let's play 'Rock, Paper, Scissors!'") player1_choice = input("Enter Player 1's choice: ") player2_choice = input("Enter Player 2's choice: ") if player1_choice == player2_choice: print(f"Both players chose {player1_choi...
true
2ab46ba034d31a084a49779826c88f9adde76c21
RebeccaML/Practice
/Python/Basic/regex.py
1,019
4.1875
4
# Exercise from https://www.udemy.com/the-modern-python3-bootcamp/ import re def extract_phone(input): phone_regex = re.compile(r"\d{3} \d{3}-\d{4}\b") match = phone_regex.search(input) if match: return match.group() else: return None def extract_all_phones(input): phone_regex = ...
false
c123931ce12e35f08c0a0de438f63521c407d6f7
RebeccaML/Practice
/Python/Basic/addingReport.py
1,133
4.1875
4
# Create a function to add numbers input by the user. # Accepts one argument which determines whether numbers and total are printed ("A") # or just the total is printed ("T") # Exits the function and displays output once user enters Q to quit # Call twice; once using "A" and once using "T" # This would be better if the...
true
ac18a69c5373de6eb081f5d0090d72a8d1f4fa8d
qanm237/q_assessment
/question2.py
310
4.34375
4
def lastele(n): return n[-1] #find the last element def sort (tuples): return sorted(tuples, key=lastele)#sort with key stated as based on last element lt=input("enter the list of tuple: ") #input of tuples in a list print("the sorted list of tuple is :") #output print(sort(lt))
true
7c84e6e89a805b58125905b65148432c6e189677
kagomesakura/numBob
/numBob.py
280
4.15625
4
#print how many times the word bob occurs in string s = 'azcbobobegghakl' numBob = 0 for i in range(len(s)): if s[i:i+3] == "bob": # [i:i+3] checks the current char + the next three chars. numBob += 1 print ('Number of times bob occurs is: ' + str(numBob))
true
75a3c18ef6236bb8044af7e04914a22004d9697b
MinhowS/py
/study/1.求一个整数的绝对值.py
336
4.21875
4
# print absolute value of an integer # 求一个整数的绝对值 # 以#开头的语句是注释,注释是给人看的,可以是任意内容, # 解释器会忽略掉注释。其他每一行都是一个语句, # 当语句以冒号:结尾时,缩进的语句视为代码块。 a = -50 if a>= 0: print(a) else: print(-a)
false
d3e9ca28d8c7bfb6c93c3580ed3dffd5f0f6cabd
edubs/lpthw
/ex03.py
1,216
4.65625
5
# Study drills # 1 above each line, user the # to write a comment to yourself explaining what the line does # 2 remember in exercise 0 when you started python3.6? start python3.6 this way again and using the math operators, use python as a calculator # 3 find something you need to calculate and write a new .py file ...
true
28d3a98bb4676d39a73d6f5e522b35650d8bd6f1
bji6/Practice_Problems
/Cracking_Coding_Interview/Moderate/factorialZeros.py
523
4.15625
4
#ben isenberg 10/23/2016 #a function that finds number of trailing zeros in n factorial def factorialZeros(n): temp = n #compute n factorial for i in range(1,temp): n = n * (temp-i) #find number of trailing zeros trailingCount = 0 divisor = 10 #print(n) while (n % divisor == 0): trailingCount = trailingCo...
false
6c99118054f5d24b3d145b5902fb77c66802a8b2
Renjihub/code_training
/Python/Duplicates.py
446
4.34375
4
# Print duplicate characters from string # Take sample string and print all duplicate characters. sample_str = "Helloo" print("Sample String :",sample_str) duplicate = set() for char in sample_str: count = 0 for char_s in sample_str: if char.lower()==char_s.lower(): count = count+1 if count>1: d...
true
2d3c303813ec11805c04eaa1618963857e88ee64
mygerges/100-Days-of-Code
/Nested Condition.py
347
4.15625
4
height = float(input("Please enter your height: ")) age = int(input("Enter your age: ")) if height > 120: if age < 12 : print("You can Play, and payment $5") elif age <= 18: print("You can Play, and payment $7") else: print("You can Play, and payment $12") else: print("Sorry can'...
true
a6d8d8d27cdc5053037f52ce897fb6c6844277e3
naumanasrari/NK_PyGamesBook
/1-chap1-get-started.py
355
4.34375
4
x=3 y=2 mul = x * y add1 = x + y sub1 = x - y dev1 = x / y expon1 = x ** y print("multiplication of x and y: ",mul) print("Addition of x and y: ",add1) print("Substraction of x and y: ",sub1) print(" Divsion of x and y in Integer: ",int(dev1)) print(" Divsion of x and y in Float: ",float(dev1)) print("Exponent of x an...
true
9d93d0a24c3c8072c13e033f9ad8a6e1a3858eed
rbabaci1/CS-Module-Recursive_Sorting
/src/searching/searching.py
2,178
4.28125
4
# TO-DO: Implement a recursive implementation of binary search def binary_search(arr, target, start, end): midpoint = (start + end) // 2 if start > end: return -1 if arr[midpoint] == target: return midpoint if arr[midpoint] > target: return binary_search(arr, target, start, midp...
true
2fff7530868944972faeaee929f3a617c6693bfd
sagsam/learn-python
/string-manipulation.py
1,718
4.125
4
print('C:\some\name') # here \n means newline! # o/p : ########### # C:\some # # ame # ########### # If you don’t want characters prefaced by \ to be interpreted as special characters, # you can use raw strings by adding an r before the first quote: print(r'C:\some\name') # note the r before the quote # o/p : #...
true
f4d7d0ab00cc1438d2e66ba11b405006e1842922
mohitgauniyal/Python-Learning
/list.py
672
4.34375
4
shopping_list = ["Apple","Banana"] #to create items list print(shopping_list) print(shopping_list[0:1]) #to print first two items from the list. shopping_list.append("Mango") #to add items in the current list. print(shopping_list) del shopping_list[0] #to delete items from the list. print(shopping_list) shopping_list[1...
true
ef371444b4406e23c1be33ee8dce8449656f098d
MichealGarcia/code
/py3hardway/ex44f.py
2,026
4.46875
4
# Composition # Inheritance is useful, but another way to do it # is just to use other classes and modules # rather than rely on implicit inhereitance. # Two of three ways of inheritance involve writing new code # to replace or alter funcitonality. # This can be replicated by calling functions in a module. #EXAMPLE...
true
451431f093e7960dfa025130bb0b5a0d7f57794c
MichealGarcia/code
/py3hardway/ex9.py
683
4.3125
4
# variable containing a string of each day # of the week separated by a space days = "Mon Tue Wed Thu Fri Sat Sun" # using a back-slash n will print the following text in a new line. months = "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" print("Here are the days: ", days) print("Here are the months: ", months) # This is...
true
9c578c823109193ece1c066474eee5b76a6ab8eb
nzshow/pythonGb
/6.dictionary.py
474
4.15625
4
dict = {'Alice': '2341', 'Beth': '9102', 'Cecil': '3258'} print('Alice:',dict['Alice']) print('Beth:',dict['Beth']) print('Cecil:',dict['Cecil']) dict['School'] = "DPS School"; # 增加键为'School'的条目 print(dict) dict['Name']="Jim"; # 修改键为'Name'的条目的值 print(dict) del dict['Name']; # 删除键是'Name'的条目 print...
false
62d63d655efd9c5fdd3dbfd1a18dd33b6e085fdf
MichalKala/Python_Guess_the_Number_game
/Python_Guess_the_Number_game/Python_Guess_the_Number_game.py
1,004
4.3125
4
import random #generate computer's number Computer_number = random.randint(0, 20) print("Your opponent has secretly selected number between 0-20\nYour goal is to guess the number!") print("") #Set loop to let user repeat the choice until they win Outcome = 0 while Outcome < 6: #Let user to choose a number ...
true
2a4978c31422d1734b580661c46b018c7cae03b0
brayan0428/python_practice
/palindrome_word.py
312
4.1875
4
def palindrome(word): reversed_word = word[::-1] if reversed_word == word: return True return False if __name__=='__main__': word = str(input("Ingresa una palabra: ")) result = palindrome(word) if result: print("Es palindrome") else: print("No es palindrome")
false
4f981aeb86632e457a84bd74640e4b587d24e85e
pasu-t/myPython
/python_modules/sreedevi_modules/dict2_states.py
349
4.34375
4
# States / capitals x={'AP':'Hyd','TN':'Chennai','KN':'Bangalore','UP':'Lucknow'} name=input("Enter a state / capital name : ") for i,j in x.items() : if i==name : print(i,"Capital is :",j) break elif j==name : print(j,"State is : ",i) break else : print("Invalid st...
false
44b959d49f4f7c6ed97bbcb02cb11b7e3815c575
sriley86/Python-4th
/Python Chapter 5 Maximum of Two Values.py
567
4.53125
5
# Chapter 4 Exercise 12 Maximum of Two Values # Write a function named max that accepts two integer values as arguments # and returns the value that is the greater of the two. Use the function in a # program that prompts the user to enter two integer values. The program should # display the value that is the greate...
true
00899bc6681527a2f79b03a8fea5727a613d199a
sriley86/Python-4th
/Python Chapter 2 Sales Tax.py
1,939
4.21875
4
# Chapter2 Exercise 6 Sales Tax # This program displays the Sales tax on purchased amount # Definition of the main function def main(): # Get the purchase amount purchaseAmount = getinput() print("The amount of the purchase:", purchaseAmount) statesalestax = calstatesalestax(purchaseAmount) print(...
true
4b86009c40bf7db7bab264dda8e59da68ba1640b
Magictotal10/FMF-homework-2020spring
/homework6/pandas_exercise.py
1,264
4.25
4
import pandas as pd # Here you have to do some exercises to familiarize yourself with pandas. # Especially some basic operations based on pd.Series and pd.DataFrame # TODO: Create a Series called `ser`: # x1 1.0 # x2 -1.0 # x3 2.0 # Your code here ser = pd.Series([1.0, -1.0, 2.0],index=['x1','x2','x3']) # T...
true
f8a1793ff5557fc5e36cffa31f61d91aa6d76157
srp527/Data-Structure-Algorithms
/3-0插入排序.py
1,909
4.1875
4
# -*- coding:utf-8 -*- __author__ = 'SRP' '''插入排序(Insertion Sort) 插入排序(Insertion Sort)的基本思想是:将列表分为2部分,左边为排序好的部分, 右边为未排序的部分,循环整个列表,每次将一个待排序的记录, 按其关键字大小插入到前面已经排好序的子序列中的适当位置,直到全部记录插入完成为止。''' import random import time import functools list2 = [random.randrange(10000) for i in range(10000)] list = [15,2,5,9,8,3,4,52,4...
false
5acffb9fb1eae601653914242f88d2ed5fac2fa3
lightjameslyy/python-full-stack
/basics/02-python-basics/01_python_basics/lt_08_buy_apple_2.py
205
4.21875
4
# 1. input price of apple price = float(input("price of apple per Kg: ")) # 2. input weight of apples weight = float(input("weight of apples: ")) # 3. calculate money money = weight * price print(money)
true
2ef4486fcfbbc4d3cb84e17884e2285eb714d86b
preetesh0908/Python
/Assignment4/bubblyrock.py
992
4.25
4
import random def bubbleSort(xlst): for i in range(len(xlst)): for j in range(len(xlst) - 1): if (xlst[j] > xlst[j+1]): xlst[j], xlst[j+1] = xlst[j+1],xlst[j] size = int(input("Enter the number of random numbers to generate: ")) alist = [] for i in range(size): ...
false
3e91a965e8381d5742cff08340f6a369a137ba91
AswiniSankar/OB-Python-Training
/Assignments/Day-1/p9.py
372
4.4375
4
# program to find the given two string is equal or else which is smaller and bigger string1 = input("enter the string1") string2 = input("enter the string2") if string1 == string2: print("both strings are equal") elif string1 > string2: print(string1 + " is greater " + string2 + " is smaller") else: print(...
true
f36d87c95330bca12b4d2caab7acd19336466d1e
AswiniSankar/OB-Python-Training
/Assignments/Day-5/p1.py
334
4.15625
4
# python program to calculate BMI of Argo def BMIOfArgo(weight, height): return (weight / (height * height)) age = int(input("Hai Arge, what is your Age?")) weight = float(input("What is your weight in kg ?")) height = float(input("What is your Height in meters")) print("The MBI is {:.1f}".format(BMIOfArgo(weig...
true
6a229363003fbc4d6a16a91fb9d82140c5e4c030
AswiniSankar/OB-Python-Training
/Assignments/Day-5/p2.py
806
4.28125
4
# program to find BMI status def toFindBMI(weight, height): return round(weight / (height * height), 1) def BMIstatus(BMIvalue): if BMIvalue < 18.5: print("your BMI is " + str(BMIvalue) + " which means you are underweight") elif 18.5 <= BMIvalue and BMIvalue <= 24.9: print("your BMI is " ...
true
718fab3a92812374785b62fee3e140082e83626e
vikasbaghel1001/Hactoberfest2021_projects
/CDMA-Python/gen_file.py
760
4.40625
4
'''File Generator Module''' # modify PATH variable according to the filepath you want generate files in PATH = "./textfiles/input/input" file_no = int(input('Enter Number of Files : ')) msg = input('Enter text : ') print('Length of text is {}'.format(len(msg))) def generate_files(num): '''Function fo...
true
41dd03437d4a4bddca4781687897f8fc5a4a1abf
vikasbaghel1001/Hactoberfest2021_projects
/Weight conversion using Python Tkinter.py
1,689
4.25
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 8 12:27:42 2021 @author: DHIRAJ """ # Python program to create a simple GUI # weight converter using Tkinter from tkinter import * # Create a GUI window window = Tk() # Function to convert weight # given in kg to grams, pounds # and ounces de...
true
f5f565eacee20a64965707cef7501f4265c34b1d
ncaleanu/allthingspython
/advanced_func/collections.py
1,727
4.125
4
''' counter, defaultdict, ordereddict (not in this file), namedtuple, deque ''' # counter - keeps track of how many times an element appears from collections import Counter ''' device_temp = [14.0, 14.5, 15.0, 14.0, 15.0, 15.0, 15.5] temp_count = Counter(device_temp) print(temp_count) print(temp_count[...
true