blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
d9657338aa5ce5c4be2b5f189f5d6ea7b3bae1a6
anti401/python1
/python1-lesson1/easy-2.py
555
4.21875
4
# coding : utf-8 # Задача-2: Исходные значения двух переменных запросить у пользователя. # Поменять значения переменных местами. Вывести новые значения на экран. a = input('A = ') b = input('B = ') print('Вы ввели A = ' + str(a) + ' и B = ' + str(b)) # перестановка значений через временную переменную t = a a = b b =...
false
4ef007bae17e06e2f2f81f160d2d07e8e029375f
kahnadam/learningOOP
/Lesson_2_rename.py
688
4.3125
4
# rename files with Python import os def rename_files(): #(1) get file names from a folder file_list = os.listdir(r"C:\Users\adamkahn\learningOOP\lesson_2_prank") #find the current working directory saved_path = os.getcwd() print("Current Working Directory is "+saved_path) #change directory to the one with t...
true
966c55fb0d234a61e5b66999b41be525a979d8c9
MarcusVinix/Cursos
/curso-de-python/funcoes_def/criando_as_proprias_funcoes.py
1,062
4.34375
4
print("Sem usar funções, a soma é: ", (5+6)) def soma(num1, num2): print("Usando funções (DEF), a soma é: ", (num1+num2)) def subtracao(num1, num2): print("Usando funções (DEF), a subtração é: ", (num1 - num2)) def divisao(num1, num2): print("Usando funções (DEF), a divisão é: ", (num1 / num2)) def mult...
false
7118bf76fbb295f78247342b3b341f25d2d0a5c0
adikadu/DSA
/implementStack(LL).py
1,181
4.21875
4
class Stack: def __init__(self): self.top = None self.bottom = None self.length = 0 def node(self, value): return { "value": value, "next": None } def peek(self): if not self.length: return "Stack is empty!!!" return self.top["value"] def push(self, value): node = self.node(value) node["nex...
true
c27205377f4de9ef50f141c30b502a795c6dc118
wmjpillow/Algorithm-Collection
/how to code a linked list.py
2,356
4.21875
4
#https://www.freecodecamp.org/news/python-interview-question-guide-how-to-code-a-linked-list-fd77cbbd367d/ #Nodes #1 value- anything strings, integers, objects #2 the next node class linkedListNode: def __init__(self,value,nextNode=None): self.value= value self.nextNode= nextNode def insertNode(h...
true
ca845b51f55cef583bfc6b9ff05741d56f474fec
mbravofuentes/Codingpractice
/python/IfStatement.py
625
4.21875
4
import datetime DOB = input("Enter your DOB: ") CurrentYear = datetime.datetime.now().year Age = CurrentYear-int(DOB) #This will change the string into an integer if(Age>=18): print("Your age is {} and you are an adult".format(Age)) if(Age<=18): print("Your age is {} and you are a Kid".format(Age)) #In Pyt...
true
4ad51b29bc544a7061347b6808da4fa6896e2a6b
StanislavHorod/LV-431-PythonCore
/Home work 2/2(3 task)_HW.py
401
4.15625
4
try: first_word = str(input("Write 1 word/numb: ")) second_word = str(input("Write 2 word/numb: ")) first_word, second_word = second_word, first_word print("The first word now: " + first_word + "\nThe second word now: " + second_word) if first_word == " " or second_word == " ": ra...
false
6e07857a742c76f44fef1489df67d00f8b118cf6
sanjaykumardbdev/pythonProject_2
/59_Operator_overloading.py
1,272
4.46875
4
#59 Python Tutorial for Beginners | Operator Overloading | Polymorphism a = 5 b = 6 print(a+b) print(int.__add__(a, b)) a = '5' b = '6' print(a+b) print(str.__add__(a, b)) print(a.__str__()) # when u r calling print(a) behind it is calling like this : print(a.__str__()) print('-----------------------------') c...
false
9bb1168da52c3bdbb7015f7a61f515b10dc69267
ubercareerprep2019/Uber_Career_Prep_Homework
/Assignment-2/src/Part2_NumberOfIslands.py
2,348
4.28125
4
from typing import List, Tuple, Set def number_of_islands(island_map: List[List[bool]]) -> int: """ [Graphs - Ex5] Exercise: Number of islands We are given a 2d grid map of '1's (land) and '0's (water). We define an island as a body of land surrounded by water and is formed by connecting adjacent la...
true
bd829c3ee9c8593b97d74d5a1820c050013581f0
lepy/phuzzy
/docs/examples/doe/scatter.py
924
4.15625
4
''' ============== 3D scatterplot ============== Demonstration of a basic scatterplot in 3D. ''' from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np def randrange(n, vmin, vmax): ''' Helper function to make an array of random numbers having shape (n, ) with each n...
true
529738259a0398c322cda396cfc79a6b3f5b38d3
nancydyc/algorithms
/backtracking/distributeCandies.py
909
4.21875
4
def distributeCandies(candies, num_people): """ - loop through the arr and add 1 more candy each time - at the last distribution n, one gets n/remaining candies - until the remaining of the candies is 0 - if no candy remains return the arr of last distribution >>> distributeCand...
true
f0fa4b9c13b33806a80c6582e15bda397fafe5b9
JonRivera/cs-guided-project-time-and-space-complexity
/src/demonstration_1.py
1,053
4.3125
4
""" Given a sorted array `nums`, remove the duplicates from the array. Example 1: Given nums = [0, 1, 2, 3, 3, 3, 4] Your function should return [0, 1, 2, 3, 4] Example 2: Given nums = [0, 1, 1, 2, 2, 2, 3, 4, 4, 5] Your function should return [0, 1, 2, 3, 4, 5]. *Note: For your first-pass, an out-of-place solut...
true
0e9bb8e8d914754431f545af8cf6358012c52ca1
MikeyABedneyJr/python_exercises
/challenge7.py
677
4.1875
4
''' Write one line of Python that takes a given list and makes a new list that has only the even elements of this list in it. http://www.practicepython.org/exercise/2014/03/19/07-list-comprehensions.html ''' import random from random import randint given_list = random.sample(xrange(101),randint(1, 101)) # even_numbe...
true
e6a688b5a85a54fedd45925b8d263ed5f79a5b41
shardul1999/Competitive-Programming
/Sieve_of_Eratosthenes/Sieve_of_Eratosthenes.py
1,018
4.25
4
# implementing the function of Sieve of Eratosthenes def Sieve_of_Eratosthenes(n): # Creating a boolean array and # keeping all the entries as true. # entry will become false later on in case # the number turns out to be prime. prime_list = [True for i in range(n+1)] for number in range(2,n): # I...
true
30aad0e938f726ba882dddb5f6b66cb3f9140011
javad-torkzadeh/courses
/python_course/ch5_exercise3.py
553
4.21875
4
''' Author: Javad Torkzadehmahani Student ID: 982164624 Instructor: Prof. Ghafouri Course: Advanced Programming (Python) Goal: working with function ''' def get_students_name (): names = [] for _ in range (0 , 6): X = input("Enter your name: ") names.append(X) return names def include_odd_...
false
548e5b007a816be6cbbc83d3675a03a97fd65758
javad-torkzadeh/courses
/python_course/ch6_exercise2.py
817
4.1875
4
''' Author: Javad Torkzadehmahani Student ID: 982164624 Instructor: Prof. Ghafouri Course: Advanced Programming (Python) Goal: working with collection ''' my_matrix = [] for i in range (0 , 3): row = [] for j in range(0 , 2): X = float(input("Enter (%d , %d): " %(i , j))) row.append(X) my_...
false
bb8cb835b829d3d25ed0546c702f38bb840e1157
Vansh-Arora/Python
/fibonacci.py
202
4.21875
4
# Return the nth term of fibonacci sequence. def fibonacci(n): if n==1: return 1 elif n==0: return 0 return fibonacci(n-1)+fibonacci(n-2) print(fibonacci(int(input())))
false
b0d523e2c88a10526e3ebb98ac771ad84d352260
TPOCTO4KA/Homework-Python
/Задание 4 Урок 1.py
607
4.15625
4
''' Пользователь вводит целое положительное число. Найдите самую большую цифру в числе. Для решения используйте цикл while и арифметические операции. ''' while True: number = input('Введите положительное число, пустая строка - окончание \n') if number == '': print('ну ты дурной') break else...
false
a888361d9dd3b74a13385787fb297d2246d44c43
TPOCTO4KA/Homework-Python
/Задание 2 Урок 2.py
868
4.28125
4
''' Для списка реализовать обмен значений соседних элементов, т.е. Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т.д. При нечетном количестве элементов последний сохранить на своем месте. Для заполнения списка элементов необходимо использовать функцию input() ''' user_answer = input 'Введите список через...
false
94a4e95a13557630c6e6a551f297a934b01e72f1
gadamsetty-lohith-kumar/skillrack
/N Equal Strings 09-10-2018.py
836
4.15625
4
''' N Equal Strings The program must accept a string S and an integer N as the input. The program must print N equal parts of the string S if the string S can be divided into N equal parts. Else the program must print -1 as the output. Boundary Condition(s): 2 <= Length of S <= 1000 2 <= N <= Length of S Ex...
true
cb332c445ab691639f8b6fb76e25bf95ba5f7af4
gadamsetty-lohith-kumar/skillrack
/Remove Alphabet 14-10-2018.py
930
4.28125
4
''' Remove Alphabet The program must accept two alphabets CH1 and CH2 as the input. The program must print the output based on the following conditions. - If CH1 is either 'U' or 'u' then print all the uppercase alphabets except CH2. - If CH1 is either 'L' or 'l' then print all the lowercase alphabets except CH2....
true
51edd7c35ccfe2b7d07bcbfe97395f0c88c251fa
TAMU-BMEN207/Apple_stock_analysis
/OHLC_plots_using_matplotlib.py
2,535
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 13 21:20:18 2021 @author: annicenajafi Description: In this example we take a look at Apple's stock prices and write a program to plot an OHLC chart. To learn more about OHLC plots visit https://www.investopedia.com/terms/o/ohlcchart.asp #Dataset...
true
68bb040d0e9828fc34660de7b3d0d4ffa6e36d2d
s-nilesh/Leetcode-May2020-Challenge
/14-ImplementTrie(PrefixTree).py
1,854
4.40625
4
#PROBLEM # Implement a trie with insert, search, and startsWith methods. # Example: # Trie trie = new Trie(); # trie.insert("apple"); # trie.search("apple"); // returns true # trie.search("app"); // returns false # trie.startsWith("app"); // returns true # trie.insert("app"); # trie.search("app"); // re...
true
d532d34c6b8d7c523ec14f8dc974ffc4eef4ddf2
shensg/porject_list
/python3/python_dx/pyc2.py
882
4.125
4
class Start(): name = 'hello' age = 0 # 区分开 '类变量' '实际变量' # 类变量和类关联在一起的 # 实际变量是面向对象的 def __init__(self, name, age): #构造函数 __int__是双下滑线 '_' # 构造函数 # 初始化对象的属性 self.name = name self.age = age # print('student') def do_homework(se...
false
e8b6ef6df71a327b6575593166873c6576f78f7b
SirazSium84/100-days-of-code
/Day1-100/Day1-10/Bill Calculator.py
911
4.1875
4
print("Welcome to the tip calculator") total_bill = float(input("What was the total bill? \n$")) percentage = int(input( "What percentage tip would you like to give ? 10, 12 or 15?\n")) people = int(input("How many people to split the bill? \n")) bill_per_person = (total_bill + total_bill * (percentage)/100)/(peopl...
true
24a69e38cdc2156452898144165634fd6579ef6c
keyurgolani/exercism
/python/isogram/isogram.py
564
4.375
4
def is_isogram(string): """ A function that, given a string, returns if the string is an isogram or not Isogram is a string that has all characters only once except hyphans and spaces can appear multiple times. """ lookup = [0] * 26 # Assuming that the string is case insensitive string =...
true
6cad9846462ac6a7aa725031f48f3cb593ed1815
marianohtl/LogicaComPython
/CV Python - Mundo 1/exe042.py
1,559
4.3125
4
#Desafio35 from math import fabs a = int(input('Digite um número que represente uma medida de um dos lados de um triãngulo: ')) b = int(input('Digite a medida referente ao outro lado: ')) c = int(input('Typing the mitters of other side the triangle: ')) n = 0 if fabs(a - b) < c and (a + b) > c: print ('Temos um ...
false
8af76392fb8ade32aa16f998867a9312303cd2fa
porigonop/code_v2
/linear_solving/Complex.py
2,070
4.375
4
#!/usr/bin/env python3 class Complex: """ this class represent the complex number """ def __init__(self, Re, Im): """the numer is initiate with a string as "3+5i" """ try: self.Re = float(Re) self.Im = float(Im) except: raise TypeError("please enter a correct number") def __str__(self): """ a...
true
af2c02c975c53c1bd12955b8bbe72bac35ab54fd
BryanBain/Statistics
/Python_Code/ExperimProbLawOfLargeNums.py
550
4.1875
4
""" Purpose: Illustrate how several experiments leads the experimental probability of an event to approach the theoretical probability. Author: Bryan Bain Date: June 5, 2020 File: ExperimProbLawOfLargeNums.py """ import random as rd possibilities = ['H', 'T'] num_tails = 0 num_flips = 1_000_000 # change this value ...
true
d2e63bfba6fdfa348260d81a84628cacc6243a18
Yasthir01/Bootcamp-Tasks-and-Projects-Part1
/Level 1/Task 7/investment_calculator.py
986
4.125
4
"""A program on an Investment Calculator""" import math # user inputs # the amount they are depositing P = int(input("How much are you depositing? : ")) # the interest rate i = int(input("What is the interest rate? : ")) # the number of years of the investment t = int(input("Enter the number of years of the investm...
true
720fefd121f1bc900454dcbfd668b12f0ad9f551
Yasthir01/Bootcamp-Tasks-and-Projects-Part1
/Level 1/Task 2/conversion.py
445
4.25
4
"""Declaring and printing out variables of different data types""" # declare variables num1 = 99.23 num2 = 23 num3 = 150 string1 = "100" # convert the variables num1 = int(num1) # convert into an integer num2 = float(num2) # convert into a float num3 = str(num3) # convert into a string string1 = int(string1) # c...
true
1143957f959a603f694c7ed6012acf2f7d465a4c
Yasthir01/Bootcamp-Tasks-and-Projects-Part1
/Level 1/Task 7/control.py
258
4.125
4
"""Program that evaluates a person's age""" # take in user's age age = int(input("Please enter in your age: ")) # evaluate the input if age >= 18: print("You are old enough!") elif age >= 16: print("Almost there") else: print("You're just too young!")
true
aa41b93ab44deded12fa4705ea497d2c6bbc74e8
Yasthir01/Bootcamp-Tasks-and-Projects-Part1
/Level 1/Task 10/logic.py
648
4.1875
4
"""A program about fast food service""" menu_items = ['Fries', 'Beef Burger', 'Chicken Burger', 'Nachos', 'Tortilla', 'Milkshake'] print("***MENU***") print("Pick an item") print("1.Fries\n2.Beef Burger\n3.Chicken Burger\n4.Nachos\n5.Tortilla\n6.Milkshake") choice = int(input("\nType in number: ")) for i in menu_i...
true
ac6d9333960c992aef690fa764d7f98ffdc9963c
Yasthir01/Bootcamp-Tasks-and-Projects-Part1
/Level 1/Task 17/animal.py
815
4.1875
4
"""Inheritance in Python""" class Animal(object): def __init__(self, numteeth,spots,weight): self.numteeth = numteeth self.spots = spots self.weight = weight class Lion(Animal): def __init__(self, numteeth, spots, weight): super().__init__(numteeth, spots, weight) self.type() def type(self): """D...
false
7eafe6d1231ff66b56fdeab6c409922e82ec5691
purvajakumar/python_prog
/pos.py
268
4.125
4
#check whether the nmuber is postive or not n=int(input("Enter the value of n")) if(n<0): print("negative number") elif(n>0): print("positive number") else: print("The number is zero") #output """Enter the value of n 6 positive number"""
true
0fc620866a5180d3a6d0d51547d74896a6d3c193
ky822/assignment7
/yl3068/questions/question3.py
734
4.3125
4
import numpy as np def result(): print '\nQuestion Three:\n' #Generate 10*3 array of random numbers in the range [0,1]. initial = np.random.rand(10,3) print 'The initial random array is:\n{}\n'.format(initial) #Question a: pick the number closest to 0.5 for each row initial_a = abs(initial-0...
true
39e36aeb85538a4be57dd457d005fd12bc642e25
ky822/assignment7
/ql516/question3.py
1,927
4.1875
4
# -*- coding: utf-8 -*- import numpy as np def array_generate(): """ generate a 10x3 array of random numbers in range[0,1] """ array = np.random.rand(10,3) return array def GetClosestNumber(array): """ for each row, pick the number closest to .5 """ min_index = np.argmin(np.ab...
true
7d82924a9a4123d5a340cbbd352ddea2bd4b3e18
ky822/assignment7
/wl1207/question1.py
694
4.125
4
import numpy as np def function(): print "This is the answer to question1 is:\n" array = np.array(range(1,16)).reshape(3,5).transpose() print "The 2-D array is:\n",array,"\n" array_a = array[[1,3]] print "The new array contains the 2nd column and 4th rows is:\n", array_a, "\n" array_b = array[:, 1] prin...
true
81f5a75d870f8e67f5694b03307f80a98a879c0d
f287772359/pythonProject
/practice_9.py
2,983
4.125
4
from math import sqrt # 动态 # 在类中定义的方法都是对象方法(都是发送给对象的消息) # 属性名以单下划线开头 class Person(object): def __init__(self, name, age): self._name = name self._age = age # 访问器 - getter方法 @property def name(self): return self._name # 访问器 - getter方法 @property def age(self): ...
false
6779c9a4de1ac252d6c913d5de26aff3cbc64153
Kamilet/learning-coding
/python/ds_reference.py
534
4.25
4
print('Simple Assignment') shoplist = ['apple', 'mango', 'carrot', 'banana'] # mylist只是指向同一对象的另一名称 mylist = shoplist # 购买了apple删除 del shoplist[0] #和在mylist中删除效果一样 print('shoplist is', shoplist) print('my list is', mylist) #注意打印结果 #二者指向同一对象,则会一致 print('Copy by making a full slice') mylist = shoplist[:] #复制完整切片 #删除第一个...
false
ae63f36897ced379ec1f7b20bc399182c36682c5
Kamilet/learning-coding
/python/ds_str_methods.py
305
4.1875
4
#这是一个字符串对象 name = 'Kamilet' if name.startswith('Kam'): print('Yes, the string starts with "Kam"') if 'a' in name: print('Yes, contains "a"') if name.find('mil') != -1: print('Yes, contains "mil"') delimiter='_*_' mylist = ['aaa', 'bbb', 'ccc', 'ddd'] print(delimiter.join(mylist))
true
5b01a489805c58909979dae65c04763df722bfaa
Sauvikk/practice_questions
/Level6/Trees/Balanced Binary Tree.py
1,233
4.34375
4
# Given a binary tree, determine if it is height-balanced. # # Height-balanced binary tree : is defined as a binary tree in which # the depth of the two subtrees of every node never differ by more than 1. # Return 0 / 1 ( 0 for false, 1 for true ) for this problem # # Example : # # Input : # 1 # / \ ...
true
9cea8f90b8556dcacec43dd9ae4a7b4500db2114
Sauvikk/practice_questions
/Level6/Trees/Sorted Array To Balanced BST.py
951
4.125
4
# Given an array where elements are sorted in ascending order, convert it to a height balanced BST. # # Balanced tree : a height-balanced binary tree is defined as a # binary tree in which the depth of the two subtrees of every node never differ by more than 1. # Example : # # # Given A : [1, 2, 3] # A height balance...
true
7708927408c989e6d7d6a297eb62d27ca489ee49
Sauvikk/practice_questions
/Level6/Trees/BinaryTree.py
2,379
4.15625
4
# Implementation of BST class Node: def __init__(self, val): # constructor of class self.val = val # information for node self.left = None # left leef self.right = None # right leef self.level = None # level none defined self.next = None # def __str__(self): ...
true
4a0eca90de3ce7fb0ab6decb0ec6aadb32c1a9fa
Sauvikk/practice_questions
/Level6/Trees/Identical Binary Trees.py
998
4.15625
4
# Given two binary trees, write a function to check if they are equal or not. # # Two binary trees are considered equal if they are structurally identical and the nodes have the same value. # # Return 0 / 1 ( 0 for false, 1 for true ) for this problem # # Example : # # Input : # # 1 1 # / \ / \ # 2 3 ...
true
8bf85ec04b5f5619a235f1506b7226597a75bef0
Kaushikdhar007/pythontutorials
/kaushiklaptop/NUMBER GUESS.py
766
4.15625
4
n=18 print("You have only 5 guesses!! So please be aware to do the operation\n") time_of_guessing=1 while(time_of_guessing<=5): no_to_guess = int(input("ENTER your number\n")) if no_to_guess>n: print("You guessed the number above the actual one\n") print("You have only", 5 - time_of_gue...
true
be99bff4b371868985a64a79a23e34be58a0831f
KrishnaPatel1/python-workshop
/theory/methods.py
1,722
4.28125
4
def say_hello(): print("Hello") print() say_hello() # Here is a method that calculates the double of a number def double(number): result = number * 2 return result result = double(2) print(result) print() # Here is a method that calculates the average of a list of numbers def average(list_of_numbers): ...
true
06bea009748a261e7d0c893a18d60e4b625d6243
hoanghuyen98/fundamental-c4e19
/Session05/homeword/Ex_1.py
1,302
4.25
4
inventory = { 'gold' : 500, 'pouch': ['flint', 'twine', 'gemstone'], 'backpack' : ['xylophone', 'dagger', 'bedroll', 'bread loaf'] } # Add a Key to inventory called 'pocket' and Set the value of 'pocket' to be a list print("1: Add a Key to inventory called 'pocket' and Set the value of 'pocket' to be a...
true
05ba21e69dab1b26f1f98a48fc3c186d37f8097b
hoanghuyen98/fundamental-c4e19
/Session02/Homeword/BMI.py
373
4.25
4
height = int(input("Enter the height : ")) weight = int(input("Enter the weight : ")) BMI = weight/((height*height)*(10**(-4))) print("BMI = ", BMI) if BMI < 16: print("==> Severely underweight !!") elif BMI < 18.5: print("==> Underweight !!") elif BMI < 25: print("==> Normal !!") elif BMI < 30: print("...
false
e1139905c3f17bd9e16a51a69853a0923160c84f
bbaja42/projectEuler
/src/problem14.py
1,496
4.15625
4
''' The following iterative sequence is defined for the set of positive integers: n n/2 (n is even) n 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 40 20 10 5 16 8 4 2 1 It can be seen that this sequence (starting at 13 and finishing at 1) contains 10...
true
d38ca5318a0687d16c49517fcaf6cac030cc1601
sys-ryan/python-django-fullstack-bootcamp
/10. Python Level One/string.py
598
4.40625
4
# STRINGS mystring = 'abcdefg' print(mystring) print(mystring[0]) # Slicing print(mystring[:3]) print(mystring[2:5]) print(mystring[:]) print(mystring[::2]) # upper print(mystring.upper()) # capitalize print(mystring.capitalize()) # split mystring = 'Hello World' x = mystring.split() print(x) mystring = 'Hello/W...
false
dee3f47d3b1befb9835946b10a6b96a711383dbd
drednout5786/Python-UII
/hwp_5/divisor_master.py
1,945
4.125
4
def is_prime(a): """ :param a: число от 1 до 1000 :return: простое или не простое число (True/False) """ if a % 2 == 0: return a == 2 d = 3 while d * d <= a and a % d != 0: d += 2 return d * d > a def dividers_list(a): """ :param a: число от 1 до 1000 :return...
false
fc846895589cb0b3d0227622ca53c4c6a62b61bc
Mahedi522/Python_basic
/strip_function.py
384
4.34375
4
# Python3 program to demonstrate the use of # strip() method string = """ geeks for geeks """ # prints the string without stripping print(string) # prints the string by removing leading and trailing whitespaces print(string.strip()) # prints the string by removing geeks print(string.strip(' geeks')) a = list...
true
0b9e842cbeb52e819ecc2a10e135008f4380f8ed
monadplus/python-tutorial
/07-input-output.py
1,748
4.34375
4
#!/user/bin/env python3.7 # -*- coding: utf8 -*- ##### Fancier Output Formatting #### year = 2016 f'The current year is {year}' yes_votes = 1/3 'Percentage of votes: {:2.2%}'.format(yes_votes) # You can convert any variable to string using: # * repr(): read by the interpreter # * str(): human-readable s = "Hello,...
true
c6145249ef56fe9890f142f597766fdb55200466
Ahmad-Saadeh/calculator
/calculator.py
810
4.125
4
def main(): firstNumber = input("Enter the first number: ") secondNumber = input("Enter the second number: ") operation = input("Choose one of the operations (*, /, +, -) ") if firstNumber.isdigit() and secondNumber.isdigit(): firstNumber = int(firstNumber) secondNumber = int(secondNumber) if opera...
true
4f603beccd737bea2d9ebd9d92bf3013dc91b9d1
surajkumar0232/recursion
/binary.py
233
4.125
4
def binary(number): if number==0: return 0 else: return number%2+10 * binary(number//2) if __name__=="__main__": number=int(input("Enter the numner which binary you want: ")) print(binary(number))
true
86cbf381166e71e7b50d958c67cc156f81426078
ksambaiah/python
/educative/fr.py
208
4.15625
4
friends = ["xyz", "abc", "234", "123", "Sam", "Har"] print(friends) for y in friends: print("Hello ", y) for i in range(len(friends)): print("Hello ", friends[i]) z = "Hello ".join(friends) print(z)
false
0cf3d8481c243de3b9d354ad30ce1a281461aca4
ksambaiah/python
/educative/find_string_anagrams.py
439
4.375
4
#!/usr/bin/env python3 import itertools ''' ''' def find_string_anagrams(str, pattern): arr = [] for p in itertools.permutations(pattern): p = "".join(p) #arr.append(str.find(p)) if p in str: arr.append(str.index(p)) arr.sort() return arr if __name__ == '__main__': ...
false
4afc4191fd6650dac57415404d36803373e071e4
ksambaiah/python
/hackerRank/arraySum.py
436
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Dec 23 00:41:04 2020 @author: samkilar """ def addArray(arr): y = 0 for i in range(len(arr)): y = y + arr[i] return y if __name__ == "__main__": # We are taking array, later we do take some random values arr = [0, ...
false
4647a038acd767895c4fd6cdbfcc130ef60a87ce
shreeyash-hello/Python-codes
/leap year.py
396
4.1875
4
while True : year = int(input("Enter year to be checked:")) string = str(year) length = len(string) if length == 4: if(year%4==0 and year%100!=0 or year%400==0): print("The year is a leap year!") break else: print("The year isn't a leap year...
true
b74ba7ee11dafa4f0482c903eeee240142181873
bengovernali/python_exercises
/tip_calculator_2.py
870
4.1875
4
bill = float(input("Total bill amount? ")) people = int(input("Split how many ways? ")) service_status = False while service_status == False: service = input("Level of service? ") if service == "good": service_status = True elif service == "fair": service_status = True elif service_...
true
7626ba157020a6e67630d783a958221ad18ace0d
0xJinbe/Exercicios-py
/Ex 021.py
1,241
4.3125
4
"""Faça um programa que calcule as raízes de uma equação do segundo grau, na forma ax2 + bx + c. O programa deverá pedir os valores de a, b e c e fazer as consistências, informando ao usuário nas seguintes situações: Se o usuário informar o valor de A igual a zero, a equação não é do segundo grau e o programa não deve ...
false
d3379c4e3a7e371830181a9c671d33b77048399e
0xJinbe/Exercicios-py
/Ex 025.py
652
4.125
4
"""Faça um Programa para leitura de três notas parciais de um aluno. O programa deve calcular a média alcançada por aluno e presentar: A mensagem "Aprovado", se a média for maior ou igual a 7, com a respectiva média alcançada; A mensagem "Reprovado", se a média for menor do que 7, com a respectiva média alcançada; A me...
false
e54410cf9db5300e6ef5c84fd3432b1723c017c6
MeganTj/CS1-Python
/lab5/lab5_c_2.py
2,836
4.3125
4
from tkinter import * import random import math # Graphics commands. def draw_line(canvas, start, end, color): '''Takes in four arguments: the canvas to draw the line on, the starting location, the ending location, and the color of the line. Draws a line given these parameters. Returns the handle of the l...
true
f84fdef224b8a97d88809dcf45fb0f574dc61ed4
SnarkyLemon/VSA-Projects
/proj06/proj06.py
2,181
4.15625
4
# Name: # Date: # proj06: Hangman # ----------------------------------- # Helper code # (you don't need to understand this helper code) import random import string WORDLIST_FILENAME = "words.txt" def load_words(): """ Returns a list of valid words. Words are strings of lowercase letters. Depending on t...
true
d7736ee0897218affa62d98dbb4117ff96d59818
djmgit/Algorithms-5th-Semester
/FastPower.py
389
4.28125
4
# function for fast power calculation def fastPower(base, power): # base case if power==0: return 1 # checking if power is even if power&1==0: return fastPower(base*base,power/2) # if power is odd else: return base*fastPower(base*base,(power-1)/2) base=int(raw_input("Enter base : ")) power=int(raw_i...
true
ca5fa437808e1935217bc2230a062cdd1a28e7d3
nilasissen/python-rookie
/india.py
607
4.28125
4
#!/usr/local/bin/python print 'Legal age in INDIA' driving_age=16 voting_age=18 smoking_age=19 marriage_age=21 age = int(raw_input('enter your age :) ')) def get_age(age): """this program will teach you about the if and else and elif statements """ if age >= marriage_age: print 'you can get marriad,sm...
false
1496c17e367409805481ebc32afc64d50f5449ce
JIAWea/Python_cookbook_note
/07skipping_first_part_of_an_iterable.py
1,321
4.15625
4
# Python cookbook学习笔记 # 4.8. Skipping the First Part of an Iterable # You want to iterate over items in an iterable, but the first few items aren’t of interest and # you just want to discard them. # 假如你在读取一个开始部分是几行注释的源文件。所有你想直接跳过前几行的注释 from itertools import dropwhile with open('/etc/passwd') as f: for l...
false
c1b83c2ac9d096558fa7188d269cc55f2a25ecf1
tolu1111/Python-Challenge
/PyBank.py
2,088
4.1875
4
#Import Dependencies perform certain functions in python import os import csv # define where the data is located bankcsv = os.path.join("Resources", "budget_data.csv") # define empty lists for Date, profit/loss and profit and loss changes Profit_loss = [] Date = [] PL_Change = [] # Read csv file with op...
true
cfa342710536f41de8ec8967c38b8fc1b23a3fd6
krishna07210/com-python-core-repo
/src/main/py/10-StringMethods/String-working.py
850
4.21875
4
def main(): print('This is a string') s = 'This is a string' print(s.upper()) print('This is a string'.upper()) print('This is a string {}'.format(42)) print('This is a string %d' % 42) print(s.find('is')) s1 = ' This is a string ' print(s1.strip()) print(s1.rstrip()) s2 =...
false
317e92540d3a6e00bec3dcddb29669fe4806c7fa
Frank1963-mpoyi/REAL-PYTHON
/FOR LOOP/range_function.py
2,163
4.8125
5
#The range() Function ''' a numeric range loop, in which starting and ending numeric values are specified. Although this form of for loop isn’t directly built into Python, it is easily arrived at. For example, if you wanted to iterate through the values from 0 to 4, you could simply do this: ''' for n in (0, 1, 2, 3...
true
1eec2e1904286641b7140f572c19f7b860c3427e
Frank1963-mpoyi/REAL-PYTHON
/WHILE LOOP/whileloop_course.py
2,036
4.25
4
''' Iteration means executing the same block of code over and over, potentially many times. A programming structure that implements iteration is called a loop''' ''' In programming, there are two types of iteration, indefinite and definite: With indefinite iteration, the number of times the loop is executed isn’t sp...
true
cf38d3bf5f83a42c436e46a934f2557763ab0ff4
utkarsht724/Pythonprograms
/Replacestring.py
387
4.65625
5
#program to replace USERNAME with any name in a string import re str= print("Hello USERNAME How are you?") name=input("Enter the name you want to replace with USERNAME :") #taking input name from the user str ="Hello USERNAME How are you?" regex =re.compile("USERNAME") str = regex.sub(name,str) #repla...
true
f81f22047a6538e19c1ef847ef365609646ed2df
utkarsht724/Pythonprograms
/Harmonicno.py
296
4.46875
4
#program to display nth harmonic value def Harmonic(Nth): harmonic_no=1.00 for number in range (2,Nth+1): #iterate Nth+1 times from 2 harmonic_no += 1/number print(harmonic_no) #driver_code Nth=int(input("enter the Nth term")) #to take Nth term from the user print(Harmonic(Nth))
true
5b74b55cbc8f0145d125993fc7ac34702d8954f7
rawatrs/rawatrs.github.io
/python/prob1.py
819
4.15625
4
sum = 0 for i in range(1,1000): if (i % 15 == 0): sum += i elif (i % 3 == 0): sum += i elif (i % 5 == 0): sum += i print "Sum of all multiples of 3 or 5 below 1000 = {0}".format(sum) ''' **** Consider using xrange rather than range: range vs xrange The range function creates a list containing numbers defin...
true
6936a4fbce24ffa6be02883497224eb0fc6ad7e5
nirmalshajup/Star
/Star.py
518
4.5625
5
# draw color filled star in turtle import turtle # creating turtle pen t = turtle.Turtle() # taking input for the side of the star s = int(input("Enter the length of the side of the star: ")) # taking the input for the color col = input("Enter the color name or hex value of color(# RRGGBB): ") # set the ...
true
cd03b7b76bfb8c217c0a82b3d48321f8326cc017
jnassula/calculator
/calculator.py
1,555
4.3125
4
def welcome(): print('Welcome to Python Calculator') def calculate(): operation = input(''' Please type in the math operation you would like to complete: + for addition - for substraction * for multiplication / for division ** for power % for modulo ''') number_1 = int...
true
6741dfd84673f751765d5b93a377a462b82da315
BatuhanAktan/SchoolWork
/CS121/Assignment 4/sort_sim.py
2,852
4.21875
4
''' Demonstration of time complexities using sorting algorithms. Author: Dr. Burton Ma Edited by: Batuhan Aktan Student Number: 20229360 Date: April 2021 ''' import random import time import a4 def time_to_sort(sorter, t): ''' Returns the times needed to sort lists of sizes sz = [1024, 2048, 4096, 8192] ...
true
a38ccc08bc8734389f11b1a6a9ac15eca5b7d53a
sammhit/Learning-Coding
/HackerRankSolutions/quickSortPartion.py
521
4.1875
4
#!/bin/python3 import sys #https://www.hackerrank.com/challenges/quicksort1/problem def quickSort(arr): pivot = arr[0] left = [] right = [] for i in arr: if i>pivot: right.append(i) if i<pivot: left.append(i) left.append(pivot) return left+right # Co...
true
d3d50cb016ef1554a59452a806d959796ef53b45
quangvinh86/Python-HackerRank
/Python_domains/2-Basic-Data-Types-Challenges/Code/Ex2_4.py
297
4.21875
4
#!/usr/bin/env python3 def find_second_largest(integer_list): return sorted(list(set(integer_list)))[-2] if __name__ == '__main__': # n = int(input()) # arr = map(int, input().split()) integer_list = map(int, "1 -4 0 -2 -4".split()) print(find_second_largest(integer_list))
false
78a204b4a7ddcc8d39cab0d2c92430d292ad204a
bswood9321/PHYS-3210
/Week 03/Exercise_06_Q4_BSW.py
1,653
4.34375
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 7 19:50:39 2019 @author: Brandon """ import numpy as np import numpy.random as rand import matplotlib.pyplot as plt def walk(N): rand.seed() x = [0.0] y = [0.0] for n in range(N): x.append(x[-1] + (rand.random() - 0.5)*2.0)...
true
70fe8fdf2f0d12b61f21f5d9bd825d2f0a0ec93f
LiuJLin/learn_python_basic
/ex32.py
639
4.53125
5
the_count = [1, 2, 3, 4, 5] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] #this first kind of for-loop goes through a list for number in the_count: print("This is count %d"% number) #also we can go through mixed lists too #notice we have use %r since we don't know what's in it for i in change: print("I g...
true
8b8945a9936304593b65b5648bcb882365ba5ad3
Phongkaka/python
/TrinhTienPhong_92580_CH05/Exercise/page_145_exercise_06.py
469
4.1875
4
""" Author: Trịnh Tiến Phong Date: 31/10/2021 Program: page_145_exercise_06.py Problem: 6. Write a loop that replaces each number in a list named data with its absolute value * * * * * ============================================================================================= * * * * * Solution: Display resu...
true
fc399182e128c75611add67a65ddfe18d180dc55
gamershen/everything
/hangman.py
1,151
4.25
4
import random with open(r'C:\Users\User\Desktop\תכנות\python\wordlist.txt', 'r') as wordfile: wordlist = [line[:-1] for line in wordfile] # creates a list of all the words in the file word = random.choice(wordlist) # choose random word from the list letterlist = [letter for letter in word] # the word convert...
true
e0d6812a81d0a65fb8998b63ac1af09247fc803e
Nihilnia/June1-June9
/thirdHour.py
1,283
4.21875
4
""" 7- Functions """ def sayHello(): print("Hello") def sayHi(name = "Nihil"): print("Hi", name) sayHello() sayHi() def primeQ(number): if number == 0 or number == 1: print(number, "is not a Primer number.") else: divs = 0 for f in range(2, number): ...
true
af4c141fc364f89f4d1ad14541b368c164f40b81
stephenfreund/PLDI-2021-Mini-Conf
/scripts/json_to_csv.py
1,116
4.15625
4
# Python program to convert # JSON file to CSV import argparse import csv import json def parse_arguments(): parser = argparse.ArgumentParser(description="MiniConf Portal Command Line") parser.add_argument("input", default="data.json", help="paper file") parser.add_argument("out", default="data.csv", he...
true
ae7922f1cd7be6def39e113f61390b4ceebcb016
gngoncalves/cursoemvideo_python_pt1
/desafio18.py
510
4.1875
4
from math import sin, cos, tan, radians num = int(input('Insira um ângulo: ')) print('Valores em Rad:') print('O seno de {}º é {:.2f}.'.format(num,sin(num))) print('O cosseno de {}º é {:.2f}.'.format(num,cos(num))) print('A tangente de {}º é {:.2f}.\n'.format(num,tan(num))) print('Valores em Deg:') print('O seno de {...
false
f49b75b94eeceac8906b6f812c706f31439e8240
gngoncalves/cursoemvideo_python_pt1
/desafio09.py
616
4.125
4
num = int(input('Insira um número inteiro: ')) n1 = num*1 n2 = num*2 n3 = num*3 n4 = num*4 n5 = num*5 n6 = num*6 n7 = num*7 n8 = num*8 n9 = num*9 n10 = num*10 print('Tabuada de {0}:'.format(num)) print('-'*12) print('{} x 1 = {:2}'.format(num,n1)) print('{} x 2 = {:2}'.format(num,n2)) print('{} x 3 = {:2}'.format(n...
false
c64c542b57107c06de2ce0751075a81fcb195b61
DmitriiIlin/Merge_Sort
/Merge_Sort.py
1,028
4.25
4
def Merge (left,right,merged): #Ф-ция объединения и сравнения элементов массивов left_cursor,right_cursor=0,0 while left_cursor<len(left) and right_cursor<len(right): if left[left_cursor]<=right[right_cursor]: merged[left_cursor+right_cursor]=left[left_cursor] left_cursor+=1...
true
1605bc14384fc7d8f74a0af5f3eb1b03f23b1cd5
Oussema3/Python-Programming
/encryp1.py
343
4.28125
4
line=input("enter the string to be encrypted : ") num=int(input("how many letters you want to shift : ")) while num > 26: num = num -26 empty="" for char in line: if char.isalpha() is True: empty=chr(ord(char)+num) print(empty, end = "") else: empty=char print(...
true
aa3efd739891956cf40b7d50c8e4b8211039eccd
Oussema3/Python-Programming
/conditions2.py
417
4.1875
4
#if elif age = input("please enter your age :") age = int(age) if age > 100: print("no such age haha") exit else: if age <= 13: print("you are a kid") elif age >13 and age < 18: print("You are a teenager") elif age >= 18 and age < 27: print("You are young enough") eli...
false
162acf35104d849e124d88a07e13fbdbc58e261b
stevewyl/chunk_segmentor
/chunk_segmentor/trie.py
2,508
4.15625
4
"""Trie树结构""" class TrieNode(object): def __init__(self): """ Initialize your data structure here. """ self.data = {} self.is_word = False class Trie(object): def __init__(self): self.root = TrieNode() def insert(self, word): """ Inserts a...
true
eb1ba8ee65ab19dad296f9793e0a0f6ba6230100
LeilaBagaco/DataCamp_Courses
/Supervised Machine Learning with scikit-learn/Chapter_1/1-k-nearest-neighbors-fit.py
2,163
4.28125
4
# ********** k-Nearest Neighbors: Fit ********** # Having explored the Congressional voting records dataset, it is time now to build your first classifier. # In this exercise, you will fit a k-Nearest Neighbors classifier to the voting dataset, which has once again been pre-loaded for you into a DataFrame df. # I...
true
160fdeed8bd2c5b06b68270bad80a238962bcb67
Arthyom/PythonX-s
/metodos.py
867
4.25
4
#### revizando los metodos de las structuras principales # diccionarios D = {1:"alfredo", 2:"aldo", 3:"alberto",4:"angel"} print D.has_key(9) print D.items() print D.keys() ##print D.pop(1) #lista = [1,2] #print D.pop(1[0,1]) print D.values() print D # cadenas cadena = "esta es una cadena de prueba esta ...
false
2e98af33d4218cbf5c05240826e5916e19fb931e
Rainlv/LearnCodeRepo
/Pycode/Crawler_L/threadingLib/demo1.py
949
4.15625
4
# 多线程使用 import time import threading def coding(): for x in range(3): print('正在写代码{}'.format(threading.current_thread())) # 当前线程名字 time.sleep(1) def drawing(n): for x in range(n): print('正在画画{}'.format(threading.current_thread())) time.sleep(1) if __name__ == "__main__": ...
false
39d5510129b23fc19a86740a018f61f19638570c
duchamvi/lfsrPredictor
/utils.py
599
4.28125
4
def bitToInt(bits): """Converts a list of bits into an integer""" n = 0 for i in range (len(bits)): n+= bits[i]*(2**i) return n def intToBits(n, length): """Converts an integer into a list of bits""" bits = [] for i in range(length): bits.append(n%2) n = n//2 re...
true
04320d7cad5a0aff770a50170feb284ac231117d
Lukasz-MI/Knowledge
/Basics/02 Operators/math operators.py
718
4.25
4
# math operators a = 12 b = 7 result = a + b; print(result) result = a - b; print(result) result = a * b; print(result) result = a / b; print(result) result = a % b; print(result) result = a % 6; print(result) result = a ** 3; print(result) # 12*12*12 result = a // b; print(result) #assignment operators a = 12 ...
false
8e0148c31c798685c627b54d2d3fe90df4553443
Lukasz-MI/Knowledge
/Basics/01 Data types/06 type - tuple.py
907
4.28125
4
data = tuple(("engine", "breaks", "clutch", "radiator" )) print (data) # data [1] = "steering wheel" # cannot be executed as tuple does not support item assignment story = ("a man in love", "truth revealed", "choice") scene = ("new apartment", "medium-sized city", "autumn") book = story + scene + ("length",) # Tuple ...
true
164fcb27549ae14c058c7eaf3b6c47b58d198e6d
Dan-krm/interesting-problems
/gamblersRuin.py
2,478
4.34375
4
# The Gambler's Ruin # A gambler, starting with a given stake (some amount of money), and a goal # (a greater amount of money), repeatedly bets on a game that has a win probability # The game pays 1 unit for a win, and costs 1 unit for a loss. # The gambler will either reach the goal, or run out of money. # W...
true
8babc659615885331c025a366d21e21dd701ee2c
Ckk3/functional-programming
/imperative.py
1,583
4.46875
4
def get_names(peoples_list): ''' Function to get all names in a list with dictionaries :param peoples_list: list with peoples data :return: list with all names ''' for people in peoples_list: names_list.append(people['name']) return names_list def search_obese(peoples_list): ''...
false