blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f45f0ea56e2ab05a60c1b897cf1dc2076a13fd09
noevazz/learning_python
/027_negative_indeces.py
477
4.375
4
# Negative indexes are legal my_list = [4, 7, 10, 6] print("List=", my_list) # An element with an index equal to -1 is the last one in the list print("[-1] index=", my_list[-1]) # The element with an index equal to -2 is the one before last in the list print("[-2] index=", my_list[-2]) # We can also use the "del" i...
true
0d5eaf303605eeec6370c7a1b1caf06ef909a248
noevazz/learning_python
/105_polymorphism_and_virtual_methods.py
434
4.375
4
""" The situation in which the subclass is able to modify its superclass behavior (just like in the example) is called polymorphism. """ class One: def doit(self): print("doit from One") def doanything(self): self.doit() class Two(One): def doit(self): # overrides the partent's: doit() is...
true
6116132b63fe41387440472cd5846af34a8ab792
noevazz/learning_python
/045_recursion.py
468
4.375
4
# recursion is when you invoke a function inside the same function: def factorialFun(n): # Factorial of N number is equal to N*(N-1)*(N-2) ... *(1) if n < 0: return None if n < 2: return 1 return n * factorialFun(n - 1) print(factorialFun(3)) # Yes, there is a little risk indeed. If you fo...
true
6a022528eb1b7cd8400e72293bc12805dcd6aaef
noevazz/learning_python
/021_while_loop.py
1,988
4.25
4
# loops allow us to execute code several times while a boolean expression is True or while we do not break the loop explicit # while loop: money = 0 fanta = 43 while money < fanta: #save 11 dollar each day to buy a fanta money += 11 print("I have", money, "dollars") # there is also inifinite loops: mone...
true
58311959e0e85debd79c0aecdd11058d3ac97566
noevazz/learning_python
/037_you_first_function.py
903
4.4375
4
# in order to use our own function we first need to define them: def my_first_function(): print("Hello world, this is my first function") # Now we can call (INVOCATION) our function: my_first_function() # remember the "pass" keyword that we saw when we were learning about loops, it can be used if you don't know w...
true
2124475661e15275a16886dbb68fc430120db14b
shwetati199/Python-Beginner
/8_for_loop.py
1,158
4.59375
5
#For loop- it is used mostly to loop over a sequence #It works more like iterator method namelist=["Shweta","Riya", "Priya", "Supriya"] print("Namelist: ") for name in namelist: print(name) #For loop don't require indexing variable to get set. #For loop over String print("For loop for string") for i in...
true
d2bfb582e28f444727b40bdc7869b9d585450325
Squidjigg/pythonProjects
/wordCount.py
318
4.125
4
userInput = input(f"What is on your mind today? ") # split each word into a list wordList = userInput.split() #print(wordList) # this is here for debugging only # count the number of items in the list wordCount = len(wordList) print(f"That's great! You told me what is on your mind in {wordCount} words!")
true
4b5d6378165bf91c01788357a803c0d3caa7f077
tjkabambe/pythonBeginnerTutorial
/Turtle.py
851
4.28125
4
# Let's draw some drawings with the package turtle # Import turtle import turtle # Lets get a setup in turtle # 'bgcolor' is 'background color' turtle.bgcolor("black") turtle.pensize(2) turtle.color("red") turtle.speed(15) # # Draw a square # turtle.forward(50) # turtle.left(90) # turtle.forward(50) # turtle.left(90...
false
4f81440511b981bb636bf62c7d24afc3aed9172b
tjkabambe/pythonBeginnerTutorial
/Quiz.py
2,027
4.5
4
# Quiz time # Question 1: Assigning variables # create 2 variables x and y where any number you want # find sum of x and y, x divided by y, x minus y, x multiplied by y x = 4 y = 3 print(x + y) print(x - y) print(x * y) print(x / y) # Question 2: Lists # Create a list of all even numbers from 0 to 100 # Print first 1...
true
3d595b15d88d0e05bad1b86a5d21c9875aceced0
gehoon/fun
/birthday.py
1,138
4.25
4
#!~/bin/python ## Simulation of the birthday paradox (https://en.wikipedia.org/wiki/Birthday_problem) import random ## Each Birthdays class comprises n number of birthdays class Birthdays: def __init__(self, n=23): # initialization self.birthday = [] for x in range(n): self.birthday.app...
true
903aa0e96b97ceccddca8fd95c85305740457609
NollHyury/pythonStudies
/basico/exemplos/stringAdvanced.py
524
4.1875
4
seq = "Hyury Luis Da Silva Noll " + "\n" print(seq) # deixa a string em letra minuscula print(seq.lower()) # remove os caractéris especiais print(seq.strip()) # deixa a string em letra maiuscula seq = seq.upper() print(seq) # converte uma string em uma lista x = seq.split("Y") print(x) # busca o indice onde esta...
false
4978ac8ee5c526eb06d5df690de298c9ecba382b
KobiShashs/Python
/2_Strings/9_example.py
251
4.125
4
word = "spaceship" # e,p,p print('e' not in word) #False print(word.isspace()) #False print(word.count('p')) ##2 print(word.find('sh')) #5 print(word.endswith('e')) #False print(len(word)) #9 print(word[-2::-4]) #ic print(word.startswith('spa')) #True
false
bd227281abb94c8791e31ce464d1640e4c8502b0
Py-Contributors/AlgorithmsAndDataStructure
/Python/Algorithms/Maths/RomanToInt.py
596
4.1875
4
# !/usr/bin/env python3.6 ''' Converts Roman Numeral into Decimal Number''' mapping = ( ('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ('IV', 4), ('I', 1),) def romanToInt(s): an...
false
65fd056b3c9cdc37c72a927d314a1c83a21f3ebc
Py-Contributors/AlgorithmsAndDataStructure
/Python/Algorithms/Sieve Algorithms/sieveOfEratosthenes.py
867
4.34375
4
# Sieve of Eratosthenes # It is an efficient algorithm used to find all the prime numbers smaller than # or equal to a number(n) # We will create a list and add all the elements and then remove those elements # which are not prime def sieveOfEratosthenes(n): # Creating an empty list primeList = [] for i...
true
4746f743c4e0919f3a088284abcd9453c2ef3bd8
Py-Contributors/AlgorithmsAndDataStructure
/Python/Algorithms/Maths/MarathiToEnglish_number.py
934
4.21875
4
''' English_digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] Below is marathi numbers list This program will convert the input number into english number ''' marathi_digits = ['०', '१', '२', '१', '४', '५', '६', '७', '८', '९'] a = input("Enter marathi digit: ") if a in marathi_digits: print("English Digi...
false
23a893a893954dc4fea0aaaea5e0f927635b193e
Py-Contributors/AlgorithmsAndDataStructure
/Python/Algorithms/DivideAndConquer/MergeSort.py
1,462
4.46875
4
from typing import List def merge(left: List[int], right: List[int]) -> List[int]: """Merges two sorted lists into a single sorted list. Args: left (list): The left half of the list to be merged. right (list): The right half of the list to be merged. Returns: list: The sorted lis...
true
1be239ea81488d063113d858ea50bee5559e21f8
alitadodo/BTVN2
/exercises1.py
329
4.21875
4
height = float(input("Enter meters: ")) weight = float(input("Input kilogram: ")) BMI = (weight / ((height * height)/10000)) print (BMI) if BMI < 16: print ("Severely underweight") elif BMI < 18.5: print ("Underweight") elif BMI < 25: print ("Normal") elif BMI < 30 : print ("Overweight") else: print...
false
2185d883e7209cd249717e152153d6dfbed0cfbc
jmsrch8/codeDump
/HumphriesCHW10.py
1,266
4.125
4
#! /bin/python3 #name: HumphriesCHW10 #programmer: Cullen Humphries #date: friday, august 5, 2016 #abstract This program will add records to a file and display records using a module #===========================================================# import time from assign10_module import * # define main def main(): #pri...
true
6ad4dcbbc54350b53f555a6ca5246f5a40089957
Pereirics/Exercicios_Curso_Python
/ex037.py
351
4.21875
4
n1 = int(input('Escreva um número: ')) m = int(input("""Escolha um método de conversão: 1 para binário 2 para octal 3 para hexadecimal Insira o valor: """)) if m == 1: n1 = bin(n1) elif m == 2: n1 = oct(n1) elif m == 3: n1 = hex(n1) else: print('Valor inválido!') print(f'O valor convertido para a opçã...
false
408192181f07281e220e2a9b9380617a30b5f594
hujieying/python-learning
/LPTHW/ex33-1.py
615
4.1875
4
# coding:utf-8 # 将这个while循环写成一个函数,将测试条件(i < 6)中的6换成一个变量。 # 使用这个函数重写脚本,并用不同的数进行测试。 # 添加另一个参数,定义第八行的+1,这样可以让它任意递增。 i = 0 numbers = [] maxium = int(raw_input("please input a number!\n")) step = int(raw_input("please input a step!\n")) while i < maxium: print ("At the top i is %d" % i) numbers.append(i) i +...
false
251bfd3225531b67568ecb419113ccd5a99cf6b2
jonnytaddesky/taskPython
/ugol.py
654
4.21875
4
# Напишите программу , в которой по извесной начальной скорости # V и времени полета тела T определяется угол aльфа под которым # тело брошено по отношению к горизонту (воспользуйтесь соотношением a = arcsin(gT/2V) ). # Ниже показан вывод программы, которая у вас должна получиться: import math g = 9.8 v = float(in...
false
dbdd36983477cda4f79005891bc432a7ddc542fa
UnderGrounder96/mastering-python
/03. Implemented Data Structures/1.Stack.py
316
4.1875
4
##### 13. STACKS # Last In First OUT stack = [] stack.append(1) stack.append(2) stack.append(3) print(stack) last = stack.pop() print(last) print(stack) print(stack[-1]) # getting the item on top of the stack # checking if the stack is empty if not stack: # that means we have an empty stack # do something
true
823f785ada0a4688d09c16e06e7eed11c3c5b8ac
UnderGrounder96/mastering-python
/10. OOP/05.ClassVsInstanceMethods.py
539
4.1875
4
# 5. CLASS VS INSTANCE METHODS class Point: def __init__(self, x, y): # this is an instance method self.x = x self.y = y # 1. defining a Class Method @classmethod # this is called a decorator and it's a way to extend the behavior of a method def zero(cls): return cls(0, 0) def draw(se...
true
30882ebeb9098c8a1dfd0e587dbc8b23d3c4b00b
UnderGrounder96/mastering-python
/07. Functions/2.args.py
513
4.5
4
# *args (arguments) # *args behaves like a tuple of parameters that are coming in. # *args allows us to take random numbers of arguments. # * means a collection of arguments # EXAMPLE 1 def myfunc(*args): return sum(args) myfunc(40,60,100) # EXAMPLE 2 def myfunc(*args): for item in args: print(item) myfu...
true
eb3fb66e3983c8ea0d131c308cd32b0ed8c30b0c
UnderGrounder96/mastering-python
/02. Built-in Data Structures/4.sets.py
963
4.625
5
# EXAMPLE 1 myset = set(); myset.add(1) myset.add(2) myset.add(3) mylist = [1,2,3,4,5] myset2 = set(mylist) # EXAMPLE 2 numbers = [1, 1, 2, 2, 4, 3] print(numbers) # converting the list into a set set_uniques = set(numbers) print(set_uniques) # defining a new set set_new = { 1, 4} set_new.add(5) set_new.remove(5) l...
true
e083ac37956b22d92143b8cd5a89a807a5c15a01
asazonov28/andrei
/Student/Lesson2.py
2,463
4.1875
4
# string_sample = 'Hello World' # number = '12345678' # number2 = '-8-7-6-5-4-3-2-1' # print(len(string_sample)) # print(len(number)) # # # print(string_sample[6:11]) # # print(string_sample[-7:]) # # print(string_sample[0:11:2]) #индексация строки с шагом 2 # # print(string_sample[::-1]) #индексация с обратным ша...
false
c30c0b73aa515d1541962322d6b33079008d2a66
Efun/CyberPatriotTutoring
/practice/Archive_8-9_2020/practice_9_27_2020.py
1,624
4.1875
4
from classes.BankAccount import BankAccount # test = BankAccount('a', 'a', 100) # print(test.balance) # write a list of 5 elements containing tennis player names tennisPlayers = ["serena williams", "roger federer", "rafael nadal", "novak djokovic", "rod laver"] #print the second element of this list #print (tennisP...
true
155359354b2395e4c1b887ad8cb8c9312cb3f0fc
FisicaComputacionalPrimavera2018/ArraysAndVectorOperations
/vectoroperationsUpdated.py
1,620
4.28125
4
import math #### FUNCTIONS # The name of the function is "norm" # Input: array x # Output: the norm of x def norm(x): tmp = 0 for v in x: tmp += v*v norm_x = math.sqrt(tmp) return norm_x def vectorSum(x, y): #z = x + y This doesn't work for arrays! # First we check if the dimensions of x and y # ...
true
77d3c7c625dc887ddc8aaa848f0d199fbfa1a06b
JinalShah2002/MLAlgorithms
/LinearRegression/Prof.py
2,211
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author Jinal Shah Suppose you are the CEO of a restaurant franchise and are considering different cities for opening a new outlet. The chain already has trucks in various cities and you have data for profits and populations from the cities.You would like to use ...
true
751f1777faad91870b7079238aa8d840848021b7
prabhatpal77/Complete-core-python-
/typeconversion.py
390
4.125
4
#Type conversion function converse the data in the form of required format in the data is possible to convert.. a=input("enter int value") print(type(a)) b=int(a) print(type(b)) c=input("enter float value") print(type(c)) d=float(c) print(type(d)) i=input("enter complex value") print(type(i)) j=complex(i) print(type(j)...
true
0f5463149ed49570c867f233e6dbc145da9104d6
prabhatpal77/Complete-core-python-
/identityope.py
470
4.125
4
#Identity operators are used to compare the addresses of the objects which are pointed by the operators .. #there are 2 identity operators. # 1. is 2. is not a=1000 b=2000 c=3000 d=3000 p=[10, 20, 30] q=[40, 50, 60] x=[70, 80, 90] y=[70, 80, 90] print(a==b) print(a!=b) print(a is b) print(a is not b) print(c==d) print(...
true
94492c43f4f858d9e46e6484a4faf4cb1585d487
prabhatpal77/Complete-core-python-
/filehandl.py
323
4.4375
4
# Through the python program we can open the file, perform the operations on the file and we can close the file.. # 'r', 'w', 'a', 't', 'b', '+' for operations on file # Open function opens the given file into the specified mode and crete file object.. # reading from file... x=open("myfile.txt") print(x.read()) x.close...
true
cf89d81fa5fa2fc86a2770f9cf42954ffa049599
suzibrix/lpthw
/ex4.py
1,660
4.21875
4
# This line assigns 100 to the variable "cars" cars = 100 # This statement assigns the number "4.0" to the variable "space_in_car" space_in_a_car = 4.0 # Assigns the number 30 to the variable "drivers" drivers = 30 # Assigns the number 90 to the variable "passengers" passengers = 90 # Assigns the difference of varia...
true
8d33594f74c58174b463aba1f3b365e4ef01fd5e
micgainey/Towers-of-Hanoi
/towers_of_hanoi_count.py
1,979
4.15625
4
""" Towers of Hanoi rules 1. You can't place a larger disk onto a smaller disk. 2. Only 1 disk can be moved at a time. Towers of Hanoi moves is: 2^n - 1 OR 2 * previous + 1 example with 3 disks 3 towers: A. B. C. Starting point: 1 2 3 A B C ...
true
a5305f23d0038814f95207a3dba6199913518cbd
thewchan/impractical_python
/ch4/storing_route_cipher_key.py
1,387
4.25
4
""" Pseudo-code: ask for number of length of key initiate defaultdict for count in length of key ask for column number store as temp1 ask for direction store as temp2 defaultdict[temp1] = temp2 """ from collections import defaultdict while True: key_len = input("Enter length of key: ") try: ...
true
6a1716818b21e765ba02e275553467a060c21269
Kids-Hack-Labs/Fall2020
/Activities/Week02/Code/activity1_suggested_solution.py
737
4.125
4
""" Kids Hack Labs Fall 2020 - Senior Week 02: Python Review Activity 1 """ #Step 1: Function that takes 2 arguments and displays greater def greater(num_a, num_b): if num_a > num_b: print(num_a, "is greater than", num_b) else: print(num_b, "is greater than", num_a) #step 2: Inp...
true
1c7b497ffce28f0a1f2faa790eca25693b2814c1
Kids-Hack-Labs/Fall2020
/Activities/Week04/Code/act2.py
1,116
4.3125
4
""" Kids Hack Labs Fall 2020 - Senior Week 04: Introduction to Classes Activity 2 """ #Suggested answer: class Animal(): def __init__(self, _type, _name, _legs, _sound): self.type = _type self.name = _name self.legs = int(_legs) self.sound = _sound def walk(self)...
true
c58359a746beaaa275045aafa9d1509b028a2760
Kids-Hack-Labs/Fall2020
/Homework/W02/Code/w02_hw_suggested_solution.py
1,213
4.125
4
""" Kids Hack Labs Fall 2020 - Senior Week 02: Python Review Homework: Number guessing game """ #Step 1: random module import import random #Step 2: application main entry point def main(): #setup (steps 2.1 through 2.5) random.seed() tries = 5 #total tries granted guesses = 0 #total ...
true
5eb8e0b24c3f32f17ec1d13c07aee382aeef9a39
himajasricherukuri/python
/src/listfunctions.py
1,949
4.21875
4
lucky_numbers = [4,8,15,16,23,42] friends = ["kevin","karen","jim","oscar","toby"] friends.extend(lucky_numbers) print(friends) # extend function allows you take a list and append it on another list #append- adding individual elements lucky_numbers = [4,8,15,16,23,42] friends = ["kevin","karen","jim","oscar","toby"] f...
true
b33bd9fe0dffcc22d3f657b10d11d1aff016b5b1
yourpalfranc/tstp
/14challenge-2.py
671
4.21875
4
##Change the Square class so that when you print a square object, a message prints telling you the ##len of each of the four sides of the shape. For example, if you ceate a square with Square(29) ##and print it, Python should print 29 by 29 by 29 by 29. class Square(): square_list = [] def __init__(self, ...
true
e489a9c6d7e662cd125a74b2f014614bdc861a9f
yourpalfranc/tstp
/13challenge-2.py
937
4.1875
4
##Define a method in your Square class called change_size that allows you to pass in a number ##that increases or decreases (if the number is negative) each side of a Square object by that ##number. class Rectangle(): def __init__(self, width, length): self.width = width self.length = length ...
true
1cdbf36cf05b93addd8e5797b82747e5448462f8
druv022/Disease-Normalization-with-Graph-Embeddings
/nerds/util/file.py
1,216
4.21875
4
import shutil from pathlib import Path def mkdir(directory, parents=True): """ Makes a directory after checking whether it already exists. Parameters: directory (str | Path): The name of the directory to be created. parents (boolean): If True, then parent directories are created a...
true
e5b94f0ba5cadbd496e8bf15318db7ae8f4d31cf
Abhiram-Agina/PythonProjects_Algebra
/CHAPTER10_ExponentsProperties.py
1,776
4.25
4
# Type in an Expression that includes exponents and I will give you an Answer # Negative Exponents: Work in progress SEEquations = input(" Type in a simple expression using exponents, 1 operator, and the same constant (i.e. 3^2 * 3^6) \n ") terms2 = SEEquations.split(" ") ExponentTerms = [] for item in terms2: if...
true
9fbf604768140b0492442807d028f1c7673d54db
jansenhillis/Python
/A001-Python-HelloWorld/hello_world.py
514
4.34375
4
#1. Hello World print("Hello World") #2. Hello Your Name name = "Jansen" print("Hello " + name) print("Hello", name) #3. Hello Num # Convert num to a string so concatenation will work num = "111" print("Hello " + num) print("Hello", num) #4. I love food food1 = "Chinese" food2 = "Sushi" print("I love to eat {} and ...
false
9e25339de670199da3cab9de8a98cc88c58cb5ca
jansenhillis/Python
/A004-python-functionsBasic2/functionsBasic2.py
2,414
4.40625
4
# 1. Countdown - Create a function that accepts a number as an input. Return a new list that counts down by one, # from the number (as the 0th element) down to 0 (as the last element). # Example: countdown(5) should return [5,4,3,2,1,0] def countdown(seed): seedList = [] for i in range(seed, -1, -1): s...
true
aa2b452ad6dc250ff6af924bacd87a7d864a541f
mafdele20/TD_ALGO
/python/exo6.py
567
4.125
4
from math import sqrt def distance(): x1=int(input(" entrer la premiere coordonnée du point A\n")) y1=int(input(" entrer la deuxieme coordonnée du point A\n")) x2=int(input(" entrer la premiere coordonnée du point B\n")) y2=int(input(" entrer la deuxieme coordonnée du point B\n")) ...
false
2e129574ad41492e099ab2181717ed8aeb79fb1f
simoonsaiyed/CS303
/Payroll.py
1,620
4.15625
4
# Assignment 3: Payroll.py # A program that prints out the Payroll dependent on inputs. def calculate(worked, pay, fedtax, statetax): worked = float(worked) gross = worked * pay fedwitholding = fedtax * gross statewitholding = statetax * gross total = statewitholding + fedwitholding return worke...
true
7b683b972accd14c161f79cb23a585863a9ab556
rubayetalamnse/Basic-Python-Codes
/string-finction.py
1,224
4.5625
5
print(len("rubayet")) #string functions------->>>> passage = "nuclear energy provide zero carbon electricity, most reliable and cheap one. This energy is better than renewable energy! If we talk about wind power or solar or hydro, nuclear takes lowest place and produces maximum energy. And obviously we should come out...
true
eeb24838ff1e76e6e73c80e79741e364e5716782
rubayetalamnse/Basic-Python-Codes
/geeks-1.py
353
4.15625
4
#printing sum of two numbers num1 = 10 num2 = 45 sum = num1+num2 print("Sum of {0} and {1} is : {2}".format(num1,num2,sum)) #printing sum of two decimal or float numbers no1 = input("enter any decimal Number: ") no2 = input("enter another decimal number: ") sum2 = float(no1)+float(no2) print("The sum of {0} and {1...
true
8467ad15dcfeb454383e1ef26143328ccca9ec7d
rubayetalamnse/Basic-Python-Codes
/functions11.py
2,640
4.40625
4
"""You're planning a vacation, and you need to decide which city you want to visit. You have shortlisted four cities and identified the return flight cost, daily hotel cost, and weekly car rental cost. While renting a car, you need to pay for entire weeks, even if you return the car sooner. City Return Flight ($) Hote...
true
933857731a1e75f757c5f57ef7913ca5585b0f7e
rubayetalamnse/Basic-Python-Codes
/celsius-farenheit.py
598
4.3125
4
#Write a Python program to convert temperatures to and from celsius, fahrenheit. temperature = input("Input the temperature you like to convert? (e.g., 45F, 102C etc.) : ") degree = int(temperature[0:-1]) temp = temperature[-1] if temp.upper() == "F": celsius_temp = float((degree - 32) * 5/9 ) print("The tem...
true
94529887c259ec0c647cf90102487626a0b36fd5
rubayetalamnse/Basic-Python-Codes
/for-break.py
241
4.1875
4
for i in range(5,20): print(i) if i==10: break #when i ==10, the loop ends. We see values from 5 to 10 in the terminal. else: print("as we used break at 10, 5 to 10 is printed. after that this else loop won't be printed")
true
622019a68abba6e0c1d31bdec0ad3c2d7778809a
rubayetalamnse/Basic-Python-Codes
/functions6.py
1,310
4.15625
4
#If you borrow $100,000 using a 10-year loan with an interest rate of 9% per annum, what is the total amount you end up paying as interest? import math #for loan emi------------------------ loan = 100000 loan_duration = 10*12 #10 years interest_rate = .09/12 #compounded monthly #reusing our previous function to calc...
true
c906588466eab7370fdbf6f6c8ec7706130706a2
rubayetalamnse/Basic-Python-Codes
/basic-tuple2.py
250
4.1875
4
#got to know something new:---------------- #let's create a tuple-----> numbers = (1,2,3,4,5,6,7,8,9,10) #reverse tuple ---- b = numbers[::-1] print(b) #output---(10, 9, 8, 7, 6, 5, 4, 3, 2, 1) c = numbers[::2] print(c) #output--->(1, 3, 5, 7, 9)
false
c81b693f9dcca328b6d547ed885ed5403a266cbf
rubayetalamnse/Basic-Python-Codes
/q4b.py
845
4.125
4
#Use a for loop to display the type of each value stored against each key in person person = { "Name":"Rubayet", "Age": 21, "HasAndroidPhone": True } for i in range(len(person)): print(type(person.keys())) print(type(person.values())) for value in person: print(type(value)) for key in person...
true
59a8c9b981bb0203fae5aabe709451ef4706a7c5
edpretend/learn_python
/defs/def_txt.py
1,264
4.34375
4
"""文本处理函数库""" def watch_txt(filename): """watch txt and read""" try: with open(filename) as file_object: contents = file_object.read() except FileNotFoundError: message = "Sorry, the file " + filename + " does not exist." print(message) else: print(contents) ...
true
86e7af0c89f72ae192f7c2e6936f7cbb28c47068
Joyce-w/Python-practice
/09_is_palindrome/is_palindrome.py
752
4.1875
4
def is_palindrome(phrase): """Is phrase a palindrome? Return True/False if phrase is a palindrome (same read backwards and forwards). >>> is_palindrome('tacocat') True >>> is_palindrome('noon') True >>> is_palindrome('robert') False Should ignore capi...
true
fcc5cb61e1df70e4020dc3c6f25b76c55ba07533
alisson-fs/POO-II
/Lista de exercicios 1/Q2.py
2,729
4.15625
4
#Aluno: Alisson Fabra da Silva Matricula: 19200409 '''Neste exercício criei uma classe Biblioteca que recebe os livros que vão estar disponiveis e criei a classe livro, que recebe todas as cadacteristicas de cada livro.''' class Biblioteca: def __init__(self, livros: list): self.__livros = livros...
false
a53af1d873b2238aa568577ae9ebd48bd7d8a846
rgederin/python-sandbox
/python-code/src/collections/set.py
2,859
4.46875
4
x = {'foo', 'bar', 'baz', 'foo', 'qux', 'bar'} print(type(x)) print(x) x = set(['foo', 'bar', 'baz', 'foo', 'qux']) print(type(x)) print(x) x = set(('foo', 'bar', 'baz', 'foo', 'qux')) print(type(x)) print(x) _str = "quux" print(list(_str)) print(set(_str)) # A set can be empty. However, recall that Python inte...
true
113acba3954da223bf206b2f3c61df537db7f878
syedareehaquasar/Python_Interview_prepration
/Hashing_Questions/is_disjoint.py
982
4.21875
4
Problem Statement You have to implement the bool isDisjoint(int* arr1, int* arr2, int size1, int size2) function, which checks whether two given arrays are disjoint or not. Two arrays are disjoint if there are no common elements between them. The assumption is that there are no duplicate elements in each array. Inp...
true
f4b23e71cb3395d3f90a8f823407ddea41724000
shreyasandal05/HelloWorld
/utils.py
203
4.1875
4
def find_max(numbers): """This prints maximum number within a list""" maximum = numbers[0] for number in numbers: if maximum < number: maximum = number print(maximum)
true
01d4b92425ebe77a583c5c6b7ea257deeac918ce
pspencil/cpy5python
/practical02/q04_determine_leap_year.py
245
4.28125
4
#Filename:q04_determine_leap_year.py #Author:PS #Created:201302901 #Description:To determine whether a year is a leap year year=int(input("Enter a year: ")) if (year%4==0 and year%100!=0) or year%400==0: print("Leap") else: print("Not leap")
false
21334ff4ca556f71bdba054c54693575d5d94bfc
Yesid4Code/holbertonschool-higher_level_programming
/0x06-python-classes/6-square.py
2,921
4.5625
5
#!/usr/bin/python3 """ A Square class definition """ class Square: """ Initialization of the class """ def __init__(self, size=0, position=(0, 0)): """ Initialization of the class """ self.size = size self.position = position def area(self): ...
true
168d8066d57bbf9e622187a32f93bd123531092d
AJKemps/cs-module-project-recursive-sorting
/src/sorting/sorting.py
1,320
4.3125
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(left, right): # elements = len(left) + len(right) # merged_arr = [0] * elements merged_arr = [] # Your code here left_point = right_point = 0 while left_point < len(left) and right_point < len(right): if l...
true
5e653857300e785e7c2755977af5951cbd0bc909
HeyMikeMarshall/GWARL-Data
/03-Python/2/Activities/01-Stu_QuickCheckup/Solved/quick_check_up.py
483
4.15625
4
# Print Hello User! print("Hello User!") # Take in User Input hru = input("How are you doing today?") # Respond Back with User Input print(f"I am glad to hear you are {hru}.") # Take in the User Age age = int(input("If you don't mind my asking, how old are you?")) # Respond Back with a statement based on age if ...
true
d8e26246147eeb15860e2946038dea1519814e13
truongpt/warm_up
/practice/python/study/linked_list.py
1,004
4.1875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def append(self, data): new_node = Node(data) if self.head is None: self.head = new_node return ...
true
33de70bb95f336872fccd00f1445e1d8e8bc14d1
abhiwalia15/practice-programs
/num_divisible_by_another_num.py
271
4.4375
4
# Python Program to find numbers divisible by thirteen from a list using anonymous function # Take a list of numbers my_list = [12, 65, 54, 39, 102, 339, 221,13] def num_divisible_by_num(n): for i in my_list: if (i%n == 0): print(i) num_divisible_by_num(13)
false
d74f64f71ca96b45315053e9dc379be4c6e2384b
andrewermel/curso-em-video
/chefao 37.py
676
4.25
4
#escreva um programa que leia um numero interio qualquer e peça para o usuario escolher qual sera a base de conversão: # 1 para binario # 2 para octal # 3 para hexadecimal # exercicio num=int(input('digite um numero inteiro:')) print('''Escolha uma das bases para conversão: [1] converter para BINARIO [2] converter p...
false
837417ff10a136800d60313bca2657459e48b71b
sailskisurf23/sidepeices
/prime.py
556
4.28125
4
#Ask user for Inputs userinput1 = int(input("This program determines primality. Enter an integer greater than 0: ")) #Define function that returns divisors of a number def divisor(number): divisors = [] for x in range(1, (number+1)): if number % x == 0: divisors.append(x) return divisor...
true
bf34ef2231cd514deb40a267976b5b7ede184893
sailskisurf23/sidepeices
/factorial.py
337
4.21875
4
uservar = int(input("Enter an integer you would like to factorialize: ")) def factorialize(var1): """Returns the factorial of var1""" counter = 1 result = 1 while counter <= var1: result = result * counter counter = counter + 1 return result print(str(uservar) +"! = " + str(factori...
true
5e30f36955b95279a0e0c9cded56c35cf7d67184
sailskisurf23/sidepeices
/dice.py
2,879
4.34375
4
#1. Write a function that rolls two sets of dice to model players playing a game with dice. #It will accept two arguments, the number of dice to roll for the first player, and the number of dice to roll #for the second player. Then, the function will do the following: #* Model rolling the appropriate number of dice f...
true
9fa447c3fae1328014bd7775bd7688bb16b2a180
KSVarun/Coding-Challanges
/remove_consonents.py
825
4.1875
4
# Given a string s, remove all consonants and prints the string s that contains vowels only. # Input: The first line of input contains integer T denoting the number of test cases. For each test case, we input a string. # Output: For each test case, we get a string containing only vowels. If the string doesn't contain a...
true
879904d1eb93a81fde6a938d5802df3fb36094ff
ToWorkit/Python_base
/错误处理/try.py
967
4.1875
4
try: print('try') # 注意差看区别 # r = 10 / 0 r = 10 / 2 print('result:', r) except ZeroDivisionError as e: print('except: ', e) finally: print('finally') print('END') print('-----------------------------') # 多个except捕获不同类型的错误 try: print('try') r = 10 / int('5') print('result:', r) except ValueError as ...
false
847252b2b65da4adf71fedb141400e8f74d97e5e
remon/pythonCodes
/python_bacics_101/Arithemtic_operators_en.py
2,020
4.21875
4
# Examples on how to uses Python Arithmetic Operators ''' What is the operator in Python? Operators are special symbols in Python that carry out arithmetic or logical computation. The value that the operator operates on is called the operand. for example: 2 + 3 = 5 Here, + is the operator that performs addition. 2 and...
true
fb6b67ad09585fe97647f5fc40bf1934a4e7dfd7
remon/pythonCodes
/Lists/List_Methods/append_en.py
1,291
4.75
5
#added by @Azharoo #Python 3 """ The append() method adds an item to the end of the list. The item can be numbers, strings, another list, dictionary etc. the append() method only modifies the original list. It doesn't return any value. """ #Example 1: Adding Element to a List my_list = ['python', 'codes', 1, 2, 3] ...
true
1a9fa90752b2629767100945f27c5bffa4a9807f
remon/pythonCodes
/Turtle/draw_rectangle_en.py
755
4.5625
5
#added by @Azharoo #Python 3 #draw a simple rectangle # Example - 1 import turtle t = turtle.Turtle() window = turtle.Screen() window.bgcolor("black") t.hideturtle() t.color("red") def slanted_rectangle(length,width): for steps in range(2): t.fd(width) t.left(90) t.fd(length) t....
false
0a78a10b44750efbf098df50ab885e38eb12058e
remon/pythonCodes
/Functions/python_exmple_fibonacci_en.py
641
4.375
4
#this file print out the fibonacci of the function input #importing numpy for execute math with lists import numpy as np #define the function that takes one input def fibonacci_cube(num): #define a list that contains 0 and 1 , because the fibonacci always starts with 0 and 1 lis = [0,1] #this for loop take...
true
6c568207157997c04d5aacba36d8dfdb911dd03b
remon/pythonCodes
/Lists/List_Methods/reverse_ar.py
1,918
4.90625
5
#added by @Azharoo #Python 3 """ The reverse() يعكس عناصر قائمة محددة. The reverse() لا تأخذ أي عوامل. The reverse() لا يعيد أي قيمة. يقوم فقط عكس العناصر وتحديث القائمة. """ #مثال 1 : Reverse a List # Operating System List os = ['Windows', 'macOS', 'Linux'] print('Original List:', os) # List Reverse os.reverse() ...
false
591ce87b8211499434dc4f19086d6a8eb042f843
remon/pythonCodes
/Functions/strip_en.py
618
4.25
4
#strip() returns a copy of the string #in which all chars have been stripped #from the beginning and the end of the string #lstrip() removes leading characters (Left-strip) #rstrip() removes trailing characters (Right-strip) #Syntax #str.strip([chars]); #Example 1 #print Python a high level str = "Python a high...
true
57e7fdb1ff3591f58ec76cf85638980d3f5a6171
remon/pythonCodes
/Lists/comprehensions_en.py
1,012
4.5625
5
# Added by @ammarasmro # Comprehensions are very convenient one-liners that allow a user to from a # whole list or a dictionary easily # One of the biggest benefits for comprehensions is that they are faster than # a for-loop. As they allocate the necessary memory instead of appending an # element with each cycle an...
true
aa3f18d2d26c103253f0df89c11c30c5bd9a754e
vdn-projects/omnilytics-challenge
/read_print_data.py
998
4.125
4
import os def is_float(obj): """ Check if object is float datatype or not Args: obj: input object in string Returns: True if it is float, else False """ try: float(obj) except ValueError: return False return True if __name__=="__main__": b...
true
0858e00dbefe600268bf106ce92459396828b6f8
laineyr19/MAGIC
/Week 3/text_based_adventure_game-2/game_02.py
317
4.15625
4
def main(): '''Getting your name''' play_name=(raw_input("What's your name? > ")) play_age=(raw_input("enter your age? >")) print ("hi"+" "+play_name) result="my name is {name} and my age is {age}".format (name=play_name, age=play_age) print(result) if __name__ == '__main__': main()
true
7264c06c4327d762d4f072a4c903cc6fd79cf3c4
krishnachouhan/calculator
/calculator/sum.py
1,200
4.25
4
# Sum Module def sum(a, b, verbose=0): ''' Writing this Sample doc. This is useful as when you type __doc(sum)__, this text is printed. hence its a good practice to use this. Here, - parameters are to be explained. - return values are to be explained. - finally, dependencies ar...
true
60a15f880a910137d6c267daf14baad13a638fc3
abramova-alex/first
/Fourth.py
546
4.28125
4
#Write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit and print out the converted temperature. celsius = raw_input('Print temperature in Celsius: ') celsius = float(celsius) fahrenheit = celsius * 9 / 5 + 32 print 'In Celsius', celsius, ' converting to', fahrenheit...
false
ee26f9872314401c7e376ac3018ef80dd5f23e58
agandhasiri/Python-OOP
/program 4 Contest problems/everywhere.py
996
4.15625
4
Tests = int(input()) # no of test cases len_list=[] # for length of each test case list with distinct names for v in range(Tests): # a loop for every test case n = int(input()) # no of work trips for each test case list = [] ...
true
218275d05a30d062ce99d9dd2f4cb2dea08523ca
xhemilefr/ventureup-python
/exercis5.1.py
314
4.21875
4
def reverse_string(string): reversed_string = "" for x in string: reversed_string = x + reversed_string return reversed_string def check_palindrome(string): temp = string.lower() if temp == reverse_string(temp): return True return False print(check_palindrome("Pasddsap"))
true
0b8a3bfb2f1514d77b83bf94c59fefb20f1b5bd8
mabbott2011/PythonCrash
/conditionals.py
536
4.125
4
# Conditionals x = 4 #basic if if x < 6: print('This is true') #basic If Else y = 1 if y > 6: print("This is true") else: print("This is false") # Elif color = 'red' #color = 'blue' #color = 'purple' if color == 'red': print('Color is red') elif color == 'blue': print('Color is blue') else: ...
true
63b4bdc7b80b17cd676b6c404c15a9ccb27f6d7e
ADcadia/py-calc
/coin-toss-calculator.py
474
4.125
4
# Enter the number of times you will toss the coin. import random def tossCoin(): num = random.randint(0, 1) if num == 0: return "Heads" else: return "Tails" timesToToss = int(input("How many times will you toss the coin? \n")) headsCounter = 0 tailsCounter = 0 for i in range(timesToToss): if tossC...
true
8c396abb6742f4e88cd68d47c057420fb5f3f253
stoneboyindc/udacity
/P1/problem_2.py
1,862
4.4375
4
import os def find_files(suffix, path): """ Find all files beneath path with file name suffix. Note that a path may contain further subdirectories and those subdirectories may also contain further subdirectories. There are no limit to the depth of the subdirectories can be. Args: ...
true
b1562cd790de07deaec97f593a6a48ec057e6214
Rohitthapliyal/Python
/Decision statements/12.py
328
4.125
4
week=int(input("enter week number:\n")) if week==1: print("sunday") elif week==2: print("monday") elif week==3: print("tuesday") elif week==4: print("wednesday") elif week==5: print("thursday") elif week==6: print("friday") elif week==7: print("saturday") else: print("inv...
false
b9d3484d14d0a0148a32d94715c1a30009ce3b3f
Rohitthapliyal/Python
/Python_basics/14.py
280
4.15625
4
import math class Power: x=int(input("enter any number:\n")) y=int(input("enter base:\n")) def show(ob): ob.power=math.pow(ob.x*ob.y) def output(ob): print("power of the number is=",ob.power) obj=Power() obj.show() obj.output()
true
fb3d6821b831097d592a05993c5f6d9d24c98706
mepujan/IWAcademyAssignment_3_python
/algorithms_and_dataStructure/insertion_sort.py
315
4.1875
4
def insertion_sort(data): for i in range(1,len(data)): key= data[i] j=i-1 while j >=0 and key < data[j]: data[j+1] = data[j] j -= 1 data[j+1] = key data =[5,3,2,6,4,1,3,7] print("Before Sorting = ",data) insertion_sort(data) print("After Sorting= ",data)
false
c2c4f82acaa1cfa7cc082ddcdf5819a21d64f3fd
BadrChoujai/hacker-rank-solutions
/Python/13_Regex and Parsing/Re.findall() & Re.finditer().py
1,211
4.125
4
# Problem Link: https://www.hackerrank.com/challenges/re-findall-re-finditer/problem # ---------------------------------------------------------------------------------- import re m = re.findall(r'(?i)(?<=[^aeiou])[aeiou]{2,}(?=[^aeiou])', input()) if len(m) > 0: print(*m, sep = '\n') else: print('-1') ...
true
2ecded57167e4ff843aea14dcc97e141de899a38
Sunil-Archive-Projects/Python-Experiments
/Python_Basics/classes.py
370
4.1875
4
#defining classes class myClass(): def firstMethod(self): #self refers to itself print("First Method") def secondMethod(self,str): #self refers to itself print "Second Method",str #defining subclasses # subClass inherits superClass myClass class subClass(myClass): x=0 def main(): obj=subClass() obj....
true
063d16a81a5348f33bc809d857d7ad71d16ee58c
elmasria/mini-flow
/src/linear.py
689
4.25
4
from neuron import Neuron class Linear(Neuron): def __init__(self, inputs, weights, bias): Neuron.__init__(self, inputs) # NOTE: The weights and bias properties here are not # numbers, but rather references to other neurons. # The weight and bias values are stored within the ...
true
bac53da6089ab51d4d094411fdcbc2a9741a50c4
schnitzlMan/ProjectEuler
/Problem19/Problem19.py
1,400
4.125
4
# strategy - #count all the days - approximately 100 * 365.25 - not too large. #keep track of the month to add correctly #devide the day by %7 - if no rest, sunday if you counted correctly #count the numbers of sundays #months = {"jan": 31, "feb": 28, "mar":31, "apr":30, "may":31, "jun":30, # "jul": 31, "aug...
true
62f40aec64258193e15abedd7a346425bbc877b3
pranakum/Python-Basics
/week 2/course_1_assessment_6/q8.py
426
4.34375
4
''' Write code to create a list of word lengths for the words in original_str using the accumulation pattern and assign the answer to a variable num_words_list. (You should use the len function). ''' original_str = "The quick brown rhino jumped over the extremely lazy fox" #code str = original_str.split() print (str)...
true
7e31942b56635ec1122e4ee36ae7127759ff1d29
H-B-P/WISHK
/Resources/PYTHON/repeater.py
593
4.28125
4
import sys #Imports sys, the library containing the argv function the_string=str(sys.argv[1]) #The string to repeat is the first argument given. target_number_of_repeats=int(sys.argv[2]) #The number of repeats is the second argument given. number_of_repeats=0 #Set this variable to zero, as there are no repeats at the s...
true
56a6965014a8d529400257f90556692bb619861d
platinum2015/python2015
/cas/python_module/v07_nested_functions_2.py
440
4.1875
4
def derivative(my_function): '''Returns a function that computes the numerical derivative of the given function my_function''' def df(x, h=0.0001): return ((my_function(x+h) - my_function(x-h)) / (2*h)) return df def f(x): '''The mathematical function f(x) = x^3''' return x*...
true
0b7360bdf8002a8b0c5542ea2cfa08784855be7b
platinum2015/python2015
/cas/python_module/Day1_SampleSolutions/p02_braking_distance_SOLUTION.py
1,095
4.375
4
# Compute the distance it takes to stop a car # # A car driver, driving at velocity v0, suddenly puts on the brake. What # braking distance d is needed to stop the car? One can derive, from basic # physics, that # d=0.5*v_0^2 / mu * g # # Develop a program for computing d using the above formula when the ini...
true