blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
47dbe1afe497cd782da601861888775c94cb3e7c
brandonmorren/python
/C3 iteratie/oefIteratie/oefening 5.py
619
4.25
4
number = int(input("enter a number: ")) if number != 0: smallest_number = number highest_number = number difference = 0 while number != 0: if number < smallest_number: smallest_number = number else: if number > highest_number: highest_number = numb...
true
8ae7e1a9e691f66b965f09644bf849f4938d5506
brandonmorren/python
/C10 set/OefeningenSet/oef 5.py
479
4.4375
4
months_days = {"January": 31, "February": 28, "March": 31, "April": 30, "May": 31, "June": 30, "July": 31, "August": 31, "September": 30, "October": 31, "November": 30, "December": 31} input_month = input("Month (press enter for an overview of all months): ") if input_month...
true
12a0e490f5025bca17f7957ae7cf6a7677bfd7fe
naldridge/algorithm_exercises
/algorithm_exercise.py
1,468
4.25
4
# Algos ## 1. Bubble Sort Write a program to sort a list of numbers in ascending order, comparing and swapping two numbers at a time. ```python [3,1,4,2] [1,3,4,2] [1,3,2,4] [1,2,3,4] ``` ## 2. Candies Given the list `candies` and the integer `extra_candies`, where `candies[i]` represents the number of candie...
true
6d4c8d2e2843896ebe132366a5a5e3b35064a0c7
ydj515/python-cleancode
/Chapter6/not_use_descriptor.py
1,013
4.1875
4
#-*- coding: utf-8 -*- """ 속성을 가진 이란적인 클래스인데 속성의 값이 달라질 때마다 추적 속성의 setter 메소드에서 값이 변경될 때 검사하여 리스트와 같은 내부 변수에 값을 저장 """ class Travller: def __init__(self, name, current_city): self.name = name self._current_city = current_city self._cities_visited = [current_city] @property def...
false
a1c49869e7026c54009ebac29d8b485fcc570072
WesleyPereiraValoes/Python
/Curso em Python Mundo 3/ex113.py
672
4.21875
4
while True: try: num = int(input('Digite um número inteiro: ')) except KeyboardInterrupt: num = 0 print('Usuario desistiu de inserir um valor!') break except: print(f'ERROR: Digite um número inteiro válido!') else: print(f'O número digitado foi {num}.') ...
false
440aad874dfa186c0419813799507b6f4a31debb
midathanapallivamshi/Saloodo
/Question one challange( return reverse of string)/reversestring.py
988
4.28125
4
#!/usr/bin/env python3 import random # Json module import only if we are reading json input reading and currently we are not reading json input and hence commenting out # import json def reverse_string(str_input): """ This method is used to reverse a string """ reverse_string = str_input[1:] ...
true
4187ba4726a9bd9feda1d72edf9a0a7215f9bdbf
saipavandarsi/Python-Learnings
/FileSamples/ReverseFileContent.py
344
4.3125
4
#File content Reversing #Using read() file = open('myfile.txt', 'r') content = file.read() print content print content[::-1] # Using ReadLines file = open('myfile.txt', 'r') content_lines = file.readlines() #content_lines[::-1] is to reverse lines for line in content_lines[::-1]: #print characters in reverse ...
true
f387d5872cd714e4f672fa9cd08e788072c4cd99
jldroid25/DevOps
/Python_scripting/Review_Python/Foundation/1-BasicPython/integers_floats.py
683
4.125
4
''' ------ Working with Integers and Floats in Python ----- There are two Python data types that could be used for numeric values: - int - for integer values - float - for decimal or floating point values You can create a value that follows the data type by using the following syntax: ''' x = int(4.7) # x is no...
true
d32d3cfd34306257a27952348fa9c647a504ecb1
jldroid25/DevOps
/Python_scripting/Review_Python/Foundation/2-DataStructures/dictionaries.py
1,178
4.125
4
# Dictionary : ''' A Data Type for mutable object that store pairs or mappings of unique keys to values. ''' elements = {'hydrogen': 1, 'helium': 2, 'carbon': 6 } elements['lithium']= 3 print("\n\n") print(elements) print("\n\n") # We can also use " in" in dictionaries to check if an element is present. print("...
true
dbdc1a6706be097b1727dcfa8d72c3511011dbbd
jldroid25/DevOps
/Python_scripting/Review_Python/Foundation/6-iterator-generator/iterator-generator.py
2,954
4.78125
5
import numpy as np ''' --Iterators And Generators - Iterables: are objects that can return one of their elements at a time, such as a list. Many of the built-in functions we’ve used so far, like 'enumerate,' return an iterator. - An iterator: is an object that represents a "stream of data". This is different from ...
true
8b03d7b5c1edd3313ff972108fa7fc3173cc2a01
jldroid25/DevOps
/Python_scripting/Review_Python/Foundation/5-Scripting/ScriptingRawInput.py
571
4.3125
4
# -------------Scripting Raw Input ------------------# #using the input() function name = input("Enter a name: ") #print("Welcome come in ", name.title()) # When using the the input() with numbers # you must include the data type "int()" or "float()" funtion # else python will throw an error print('\n') num = int(...
true
8e77e139517c1ed083f00c390ed2bcc29d29654d
jldroid25/DevOps
/Python_scripting/Review_Python/Foundation/2-DataStructures/CompoundDataStruct.py
1,279
4.1875
4
# Compound DataStructure is a combination of dictionary inside another # to have elements names to another dictionary that stores that collection data. # Essentially it's a nested dictionary print("\n\n") elements = { 'hydrogen': {'number': 1, 'weight': 1.000794, 'Symbol' : 'H'} , 'helium': {'number': 2, 'w...
false
fe263deeeb9e60830db38532633f728b325271c6
Zachary3352/reading-journal-Zachary3352
/shapes.py
2,162
4.375
4
import turtle #------------------------------------------------------------------------------ # Make some shapes # Work through exercises 1-4 in Chapter 4.3. #------------------------------------------------------------------------------ # Square # NOTE: for part 2 of 4.3, you will add another parameter to this fun...
false
95657382a090f8341cfe2aebfad9cb5dadb3e75f
antonio00/blue-vscode
/MODULO 01/AULA 10/EX01.PY
328
4.15625
4
# Escreva um programa que pede a senha ao usuário, # e só sai do looping quando digitarem corretamente a senha senha = '5467' tentativa=input("Digite a senha:") while senha != tentativa: print("Senha Incorreta! Tente novamente!") tentativa=input("Digite a senha:") print("Senha correta. Acesso liberado...")
false
4445febfb60cfa94adc57d490b02afe4d66c2397
GaborBakos/codes
/CCI/Arrays_and_Strings_CHP1/1_string_compression.py
1,037
4.375
4
''' Implement a method to perform basic string compression using the counts of repeated characters. EXAMPLE: Input: aabcccccaaa Output: a2b1c5a3 If the "compressed" string would not become smaller than the original return the original. You can assume the string has only uppercase and lowercase...
true
08871a22ab49d1750f9d5ccdda7d90686b751e42
Nao801/opp
/kadai.py
1,626
4.46875
4
''' 課題1:円オブジェクト 次のコードが正しく動作するようなCircleクラスを実装すること areaは面積、perimeterは周囲長という意味 #半径1の円 Circle1 = Circle(radius=1) print(circle1.area()) #3.14 print(circle1.perimeter()) #6.28 #半径3の円 Circle3 = Circle(radius=3) print(circle3.area()) #28.27 print(circle3.perimeter()) #18.85 ''' import math class Circle: def __init__(s...
false
5b6c99aa27f6d2c4c7466dff79492c41882f8fda
BeahMarques/Workspace-Python
/Seção 3/exercicio26/app.py
310
4.21875
4
Categoria = int(input("Qual sua categoria: ")) if Categoria == 1: print("Voce escolheu a categoria BOLSA!") elif Categoria == 2: print("Voce escolheu a categoria TENIS!") elif Categoria == 3: print("Voce escolheu a categoria MOCHILA!") else: print("Essa categoria não foi encontrada")
false
aff2467f53cb555016ebfd476cec773bbb316f7f
Spandan-Dutta/Snake_Water_Gun_Game
/SNAKE_WATER_GUN_GAME.PY
2,988
4.21875
4
""" So the game is all about that: 1) If you choose Snake and computer choose Gun, you loose as computer shots the snake with a gun. 2) If you choose Gun and computer choose water, you loose as gun is thrown in the water. 3) If you choose Snake and computer choose Water, you wins as Snake drinks the water. """ i...
true
04fd2d654936f8cc705f5a362a4326f175995ddc
standrewscollege2018/2020-year-11-classwork-Bmc9529
/For loop example.py
366
4.1875
4
""" for loop example, for loops run up to but not the final number""" i = 1 #in for loops we set a start, enging and increment valu for i in range(1,1001): if i % 3 == 0 and i % 5 == 0: print("fizzbuzz") elif i % 3 == 0 and not i % 5 == 0: print("fizz") elif i % 5 == 0 and not i % 3 == 0: ...
false
464c3b7fcfd0409dc72f9a238227af789aed4aa0
Asmithasharon/Python-Programming
/square_root.py
409
4.375
4
''' To find the square root of a number using newton's method. ''' def sq_root(number, precision): sqroot = number while abs(number - (sqroot * sqroot)) > precision : #'''abs() is to get the absolute value''' sqroot = (sqroot + number / sqroot) / 2 return sqroot number = int(inp...
true
0425427f405ff360a9b61b66dd26ecfd25f1ba28
pawnwithn0name/Python-30.03-RaKe
/py_07_04_second/decision_making/if-demo.py
386
4.1875
4
num = float(input("Enter a floating-point: ")) var = int(input("Enter an integer: ")) if num > 100: print("Numbers entered: {}, {} is greater than 100.".format(num, var)) print("Numbers entered: {1}, {0} is greater than 100.".format(num, var)) print(f"Numbers entered: {num}, {var} is greater than 100.") ...
true
faa9cc5542f7bb23f5c8e60b779a089381ae319d
BitanuCS/Python
/College-SemV/07. occurrence of each letter.py
270
4.125
4
#Count the occurrence of each letter in "Maharaja Manindra Chandra College". str = 'Maharaja Manindra Chandra College' freq = {} for i in str: if i in freq: freq[i] += 1 else: freq[i] = 1 print("Frequencies of {} is:\n {}".format(str,freq))
false
6829fda3257b5e28f7d54f699bfedabb1ef6da06
BitanuCS/Python
/College-SemV/10. vehicle class with max_speed and mileage attributes.py
437
4.25
4
# creat a vehicle class with max_speed and mileage attributes. class Vehicle: def __init__(self,max_speed, mileage): self.max_speed = max_speed self.mileage = mileage print("Max. Speed of your car is: {}\nMileage is: {}".format(max_speed,mileage)) max_speed = float(input("What is the max...
true
56354c5fcf9292ceaae13f4455af5ec3437d7c5e
pksingh786/BETTER-CALCULATOR
/BETTER CALCULATOR.py
601
4.25
4
#this is a better calculatorin comparison of previous one first_num=float(input("enter first number:")) second_num=float(input("enter second number:")) print("press + for addition") print("press - for subtraction") print("press * for Multiplication") print("press / for division") input=input("enter the symbol fo...
true
2b53d5961c27ba0e1144b4eb74065e29bf6e7471
mochapup/LPTHW
/ex20_SD5.py
1,078
4.28125
4
# Functions and files # import argv from sys import argv # Scripr and argument input script, input_file = argv # defining function that prints all of file def print_all(f): print(f.read()) # defining a function to rewind to character 0 of file def rewind(f): f.seek(0) # defining a function to print each line s...
true
e40e0d6fb683e2da5b75fbe9ad8f3385b7ad7617
alfrash/git_1
/Pandas/Pandas_1.py
763
4.28125
4
import pandas as pd groceries = pd.Series(data=[30,6,'yes','no'],index=['eggs', 'apples', 'milk', 'bread']) print(groceries) print(groceries.shape) print(groceries.ndim) print(groceries.size) print(groceries.values) print(groceries.index) print('banana' in groceries) # lesson 5 - Accessing and Deleting Elements in P...
true
413300290ba3ef27daa57ef52f45af5189bef2a6
IvanyukStas/different_lessons
/reverse_every_acdeting.py
1,099
4.125
4
def reverse_ascending(items): # your code here temp_items = [] new_items = [] for i in range(len(items)): if i == len(items)-1: temp_items.append(items[i]) temp_items.reverse() for j in temp_items: new_items.append(j) continue ...
false
9fa1c6ab1f961cce3d2464b1e8079a2bd407c631
chetangargnitd/Python-Guide-for-Beginners
/Factorial/iterativeFactorial.py
442
4.40625
4
# Python program to find the factorial of a given number # input the number to find its factorial num = int(input("Enter a number: ")) factorial = 1 if num < 0: #factorial doesn't exist for a negative number print("Please enter a valid number!") elif num == 0: #factorial of 0 is 1 print("The factorial of 0...
true
63a8f0dfb92e74e4fa574f3048f810823893b820
gabrielavirna/python_data_structures_and_algorithms
/my_work/ch3_stacks_and_queues/bracket_matching_app.py
1,856
4.15625
4
""" Bracket-matching application ---------------------------- - using our stack implementation, verify whether a statement containing brackets --(, [, or {-- is balanced: whether the number of closing brackets matches the number of opening brackets - It will also ensure that one pair of brackets really is contained...
true
b14bab37f60ba19116cf36475643ac4e7e4a1cd6
gabrielavirna/python_data_structures_and_algorithms
/my_work/ch2_lists_and_pointer_structures/lists_and_pointers.py
2,302
4.34375
4
""" Pointers -------- Ex: a house that you want to sell; a few Python functions that work with images, so you pass high-resolution image data between your functions. Those large image files remain in one single place in memory. What you do is create variables that hold the locations of those images in memory. The...
true
28920f935d378841ec8750148075236777dfe2b1
gabrielavirna/python_data_structures_and_algorithms
/my_work/ch2_lists_and_pointer_structures/circular_lists.py
2,502
4.15625
4
""" Circular lists --------------- - a special case of a linked list - It is a list where the endpoints are connected: the last node in the list points back to the first node - Circular lists can be based on both singly and doubly linked lists - In the case of a doubly linked circular list, the first node also needs to...
true
0ffa31e363ce141ddc7d5a7f5526aadd74046f7d
gabrielavirna/python_data_structures_and_algorithms
/my_work/ch10_design_techniques_&_strategies/coin_counting_greedy.py
2,416
4.46875
4
""" Greedy algorithms - make decisions that yield the largest benefit in the interim. - Aim: that by making these high yielding benefit choices, the total path will lead to an overall good solution or end. Coin-counting problem --------------------- In some arbitrary country, we have the denominations 1 GHC, 5 GHC, an...
true
da4dd699a4259d0df6e34bb1f2edc256b504b1da
aadyajha12/Covid19-SmartAlarm
/CA3/time_conversion.py
965
4.21875
4
from datetime import datetime def minutes_to_seconds(minutes) -> int: """Converts minutes to seconds""" return int(minutes) * 60 def hours_to_minutes(hours) -> int: """Converts hours to minutes""" return int(hours) * 60 def hhmm_to_seconds(hhmm: str): if len(hhmm.split(':')) != 2: prin...
false
912d8a64e49846144609746390f49caba462873c
zhangler1/leetcodepractice
/树与图/Trie Tree/Implement Trie (Prefix Tree)208.py
1,552
4.125
4
class TrieNode: def __init__(self): """ Initialize your Node data structure here. """ self.children=[None]*26 self.endcount=0 class Trie: def __init__(self): """ Initialize your data structure here. """ self.head=TrieNode() def inser...
true
55d07ac39edf980053d80525264424d8eaf416fc
mokrunka/Classes-and-Objects
/countcapitalconsonants.py
992
4.375
4
#Write a function called count_capital_consonants. This #function should take as input a string, and return as output #a single integer. The number the function returns should be #the count of characters from the string that were capital #consonants. For this problem, consider Y a consonant. # #For example: # # count_c...
true
de8d4a940fb3c2098f2e4b6ff689f5a1a69e749f
mushamajay/PythonAssignments
/question8.py
345
4.21875
4
def maximum(numOne, numTwo): if numOne>numTwo: return numOne; else: return numTwo; numOne = float(input("Enter your first number: ")) numTwo = float(input("Enter your second number: ")) print("You entered: {} {} " .format(numOne,numTwo)) print("The larger of the two numbers is: {} " .format(...
true
50384a3fafcc828dcd563081d8c458c4965d523b
IgorToro/mi_primer_proyecto
/comer_helado.py
1,587
4.21875
4
apetece_helado_input = input("¿Te apetece un helado? (Si / No):").upper() if apetece_helado_input == "SI": apetece_helado = True elif apetece_helado_input == "NO": apetece_helado = False else: print("Te he dicho que digas Si o No, no se que me has dicho, cuento como que no quieres un helado") apetece_h...
false
aa27be886488997a3f89d12ca493d0b1162360fa
mary-tano/python-programming
/python_for_kids/book/Projects/fenster8.py
945
4.21875
4
# Разметка окна from tkinter import * class Window() : # Инициализация def __init__(self, Titel) : self.Window = Tk() self.Window.title(Titel) self.Window.config(width=260, height=120) self.Display = Label(self.Window, text="Как это сделать?") self.Display.place(x=50, y=20, width=160, height...
false
18a6899c57c124e3763853d806b282f1dacfab8c
Elena-Yasch/GB_Python_Homework
/task1.py
465
4.125
4
#1. Поработайте с переменными, создайте несколько, выведите на экран, запросите у пользователя несколько чисел # и строк и сохраните в переменные, выведите на экран. name = input('Enter your first name:\n') print(name) last_name = input('Enter your last name:\n') print(last_name) age = int(input('Enter your age:\n'))...
false
7924ab943291d81d40280a3e46e35b0fbcaffda3
anayatzirojas/lesson6python
/lesson6/problem3/problem3.py
483
4.15625
4
name = input ('What is your name?') print ('Hi' + name + ','' ' 'my name is Girlfriend Bot!''<3') mood = input ('How was your day, Lover?') print ('Hmm I am looking up the meaning of' + mood +' ' 'just one minute.') press= input ('I have a surprise for you. Click the screen and type okay.') print ('HACKED! VIRUSES IS I...
true
e98f404d2cdb6b1a7cbc0f6172da400fdb305ca2
renankemiya/exercicios
/2.Estrutura_De_Decisão_wiki.Python/estrutura_de_decisão_5.py
913
4.21875
4
# Faça um programa para a leitura de duas notas parciais de um aluno. # O programa deve calcular a média alcançada por aluno e apresentar: # A mensagem "Aprovado", se a média alcançada for maior ou igual a sete; # A mensagem "Reprovado", se a média for menor do que sete; # A mensagem "Aprovado com Distinção", se a mé...
false
67f0a9da8deef35de2945f9810b7faf7dbd50018
renankemiya/exercicios
/2.Estrutura_De_Decisão_wiki.Python/estrutura_de_decisão_15.py
1,774
4.28125
4
# Faça um Programa que peça os 3 lados de um triângulo. O programa deverá informar se os valores # podem ser um triângulo. Indique, caso os lados formem um triângulo, se o mesmo é: equilátero, isósceles ou escaleno. # Dicas: # Três lados formam um triângulo quando a soma de quaisquer dois lados for maior que o tercei...
false
f364eb5a8a75807803b802aecfb0b17ee9e94724
renankemiya/exercicios
/3.Estrutura_De_Repetição_wiki.Python/estrutura_de_repetição_1.py
405
4.21875
4
# Faça um programa que peça uma nota, entre zero e dez. Mostre uma mensagem caso o valor seja inválido e continue # pedindo até que o usuário informe um valor válido. nota = float(input('Insira um nota entre 0 a 10: ')) while nota < 0 or nota > 10: print('Nota Inválida') nota = float(input('Insira um nota e...
false
ef1ab96d6b4dd0eb988a31bf3e15b13528e9678b
lohib/Programming--language
/hack3.py
243
4.15625
4
def is_leap(year): leap=False if year%4==0: if year%100==0 and not year%400==0: leap=False else: leap=True return leap year=2004 print(is_leap(year)) year=1990 print(is_leap(year)) year=1996 print(is_leap(year))
false
32ff4110bcd5bc8c2d1bb1455216581a0e68bc1b
oshrishaul/lesson1
/Lesson2/Assignment_Class2/Extra2.py
700
4.21875
4
# # Create a nested for loop to create X shape (width is 7, length is 7): # i=0 # j=4 # for row in range(5): # for col in range(5): # if row==i and col==j: # print("*",end="") # i=i+1 # j=j-1 # elif row==col: # print("*",end="") # else: # ...
true
69e4baa9758d9808ac6f72cfe90059b76b874da8
standrewscollege2018/2020-year-12-python-code-JustineLeeNZ
/credit_manager.py
2,896
4.40625
4
""" Manage student info about L1 NCEA credits - Ms Lee. """ def display_all_students(): """ Display all students in a list. """ print("\nLIST OF STUDENTS") for index in range(0, len(students)): print("{}. {} Credits: {}".format(index+1, students[index][0], students[index][1] )) # stores init...
true
88627a52218cf3c4fff7d39f34f565f9f39990ee
AssafR/sandbox
/generators.py
2,172
4.375
4
def with_index(itr): """This is the same as builtin function enumerate. Don't use this except as an exercise. I changed the name, because I don't like overriding builtin names. Produces an iterable which returns pairs (i,x) where x is the value of the original, and i is its index i...
true
18f595f69bafa2de6f12e3e22e85efc24ab91d82
knowledgeforall/Big_Data
/Big Data/arrays.py
935
4.125
4
#create empty array A = [] print("Array A: ", A) #create a "populated" array B = [12, 23, 56, 17, 23] print("Array B: ", B) #Add an element to an array print("Before adding to A: ", A) A.append(90) print("After adding to A: ", A) #access the 2nd element in array B print("The second element in Array B is: ", B[1]...
true
ae879397835b9f1a95459a6bdc70d12252a3754a
baraluga/programming_sandbox
/python/miscellaneous/binary_tree_optimizer.py
2,117
4.34375
4
''' Recall that a full binary tree is one in which each node is either a leaf node, or has two children. Given a binary tree, convert it to a full one by removing nodes with only one child. For example, given the following tree: 0 / \ 1 2 / \ 3 4 \ / ...
true
bce7773067afd0c81466166e792751c5be04d7ec
chenlifeng283/learning_python
/7-handling conditions/code_challenge_and_solution.py
529
4.40625
4
# Fix the mistakes in this code and test based on the description below # if I enter 2.00 I should see the message "The tax rate is: 0.07" # if I enter 1.00 I should see the message "The tax rate is :0.07" # if I enter 0.5 I should see the message "The tax rate is: 0" price = input('How much did you pay?') price = flo...
true
0e123b02dca275d099869084f1ed52a9a18d571c
chenlifeng283/learning_python
/1-print/ask_for_input.py
244
4.28125
4
#The input function allows you to prompy the user for a value #You need to declare a variable to hold the value entered by the user name=input("What's your name?") #if string has single quotes,it must be enclosed in double quotes. print(name)
true
84594d387e3c44e7e3cd50cf6e33b210e27a865a
BenDataAnalyst/Practice-Coding-Questions
/leetcode/67-Easy-Add-Binary/answer.py
618
4.21875
4
#!/usr/bin/env python #------------------------------------------------------------------------------- # Cheaty Python way :) # Other way would be to add each digit bit by bit, and having a carry bit when > 1 class Solution: def addBinary(self, a, b): """ :type a: str :type b: str :...
true
615668717c061bcdcfcc4c3f7dbe4130aeb6401b
JHHXYZ/DSCS2020
/Assignments/Assignment 2/part3.py
2,574
4.5625
5
# building a ml model with sklearn import numpy as np import pandas as pd """ 1. Load your data from part 2 Create two lists. One should contain the name of the features (i.e. the input variables) you want to use to train your model, the other should contain the column name of the labels """ # your code """ 2. Div...
true
0bb19fcdb98d6c46c174347921246fe25cf69777
BillyRockz/Magic-8-Ball
/main.py
1,215
4.125
4
'''This is a game of 8-Ball where you can ask Yes/No Questions and get answers''' alpha = True while alpha == True: name = input("What is your name?: ") if name.isalpha() and name.strip(): alpha = False beta = True while beta == True: question = input("Ask a (Yes/No) question: ") beta = False else: pr...
true
6a8130d24de307de61d263b0bdc358a602cfd985
khelryst/Learning-Python
/gradechecker.py
444
4.21875
4
grade = input('Enter your grade: ') try: grade = float(grade) except: grade = input('Enter a number from 0.0 - 1.0: ') if float(grade) >= 0.9: grade = 'A' elif float(grade) >=0.8: grade = 'B' elif float(grade) >= 0.7: grade = 'C' elif float(grade) >= 0.6: grade = 'D' elif float(grade) < 0.6: ...
false
0e89f43161009efc79d682584518c8cce89196d6
ngovanuc/UDA_NMLT_Python_chapter06
/page_203_project_03.py
925
4.3125
4
""" author : Ngô Văn Úc date: 30/08/2021 program: 3. Elena complains that the recursive newton function in Project 2 includes an extra argument for the estimate. The function’s users should not have to provide this value, which is always the same, when they call this function. Modify the definition of the functio...
true
0c99a8c25c99644fbaddb94b22a7146aad09b854
ngovanuc/UDA_NMLT_Python_chapter06
/page_199_exercise_03.py
477
4.3125
4
""" author : Ngô Văn Úc date: 30/08/2021 program: 2. Write the code for a filtering that generates a list of the positive numbers in a list named numbers. You should use a lambda to create the auxiliary function. solution: - sử dụng bộ loc filter """ word = ["a", "hello", "Uc", "handsome", "b", "c", "d"] ...
true
cb9ad2b4f192f67206af6f565a7cb50a36b13f40
jjena560/Data-Structures
/strings/strings.py
656
4.15625
4
def createStack(): stack = [] return stack def push(stack, item): stack.append(item) def pop(stack): return stack.pop() def reverse(string): n = len(string) try: stack = createStack() for i in range(n): push(stack, string[i]) string = "" ...
true
61813e43dbfb6c4be84104f9e042207ef3beeb2e
sohitmiglani/Applications-in-Python
/Max Heaps.py
931
4.125
4
# This is the algorithm for building and working with heaps, which is a tree-based data structure. # It allows us to build a heap from a given list, extract certain element, add and remove them. def max_heapify(A, i): left = 2 * i + 1 right = 2 * i + 2 largest = i if left < len(A) and A[left] > A[la...
true
a1e1308263ba36420c3b7095ae682addf3898b33
sohitmiglani/Applications-in-Python
/Hash Tables.py
1,391
4.40625
4
# This is an algorithm to produce hash tables and implement hashing functions for efficient data storage and retrieval. # It also has 4 examples of hashing functions that can be used to store strings. import random import string def randomword(length): return ''.join(random.choice(string.lowercase) for i in ra...
true
fab8ea8638fbb524c1b423a6aac64cca4e692cbd
nzrfrz/praxis-academy
/novice/01-02/list_comprehension.py
1,529
4.28125
4
from math import pi print("using math lib to calculate pi: ") print( [str(round(pi, i)) for i in range(1, 6)] ) print("") # Create a list of squares squares = [] for x in range(10): squares.append(x ** 2) # Creates or overwrite 'x' after loop squares = list(map(lambda x: x ** 2, range(10))) # Simple version ...
true
c41456a23f31788093696b4433813bc63d57b5d4
Devanshiq/Python-Programs
/rectangle.py
1,460
4.1875
4
# class rectangle(): # pass # # # r1=rectangle() # r2=rectangle() # # # r1.height=40 # r1.width=60 # # r2.height=60 # r2.width=30 # # print(r1.height*r1.width) # print(r2.height*r2.width) # class rectangle(): # def __init__(self,height,width): # print(height*width) # self....
false
23083506114f10882ec02b046f74a4fe502d042f
Devanshiq/Python-Programs
/car.py
2,450
4.125
4
# class car: # pass # # ford=car() # honda=car() # audi=car() # ford.speed=200 # honda.speed=400 # audi.speed=100 # ford.color='black' # honda.color='blue' # audi.colour='maroon' # print(ford.speed) # print(audi.colour) # print(honda.color) # class car(): # def __init__(self,speed,color): #...
true
f093c70bedeaf48c1a139c49a2252224b515d27c
ziGFriedman/My_programs
/Single_double_positive_negative_digit.py
658
4.28125
4
'''Какое число: однозначное или двухзначное, положительное или отрицательное?''' def digit(n): if n == 0: print('Ноль - однозначное число') else: if n > 0: print('Положительное', end=' ') else: print('Отрицательное', end=' ') if abs(n) < 10: pr...
false
52258bb913b812c121a1eb90466fd018ac6fb643
ziGFriedman/My_programs
/Area_and_perimeter_of_a_right_triangle.py
1,267
4.71875
5
'''Найти площадь и периметр прямоугольного треугольника''' # Найти площадь и периметр прямоугольного треугольника по двум заданным катетам. # Площадь прямоугольного треугольника равна половине площади прямоугольника, стороны которого равны # длинам катетов. # Периметр находится путем сложения длин всех сторон треугольн...
false
35a77aa042a95f8f956fc013e68efc9d3f1da89c
656021898/python_project
/homework/homework_1018/User.py
1,009
4.375
4
# 1:创建一个名为 User 的类: # 1)其中包含属性 first_name 和 last_name,还有用户简介通常会存储的其他几个属性,均是自定义, 请放在初始化函数里面。 # 2)在类 User 中定义一个名为 describe_user()的方法,它打印用户信息摘要; # 3)再定义一个名为 greet_user()的方法,它向用户发出个性化的问候。: # 请创建多个表示不同用户的实例,并对每个实例都调用上述两个方法。 class User: def __init__(self,first_name,last_name,sex="男",age=25): self.first_name = f...
false
06413d33de4cb40afd3c7109cf3baf084693b74a
korn13r/RTR105
/dgr_20181015.py
1,222
4.28125
4
# Conditional steps x = 5 if x < 10: print('Smaller') if x > 20: print('Bigger') print ('Finish') # Comparison operators x = 5 if x == 5: print('Equals 5') if x > 4: print('Greater than or Equals 5') if x < 6: print('Less than or Equals 5') if x != 6: print('Not Equals 6') # one way decision...
false
75df350c68c6ff04cf879d80be5d97f2a75f48f0
byn3/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
575
4.21875
4
#!/usr/bin/python3 """ this is my add_integer module """ def add_integer(a, b=98): """Function that returns the addition of a + b Args: a: should be an int. if not throw error b: second int. if not throw error. default val is 98. Returns: The addition of a + b or a raised TypeErr...
true
0e6ca5815e21b5a3d5225dc2934d1ba0f390708e
ag-ds-bubble/projEuler
/solutions/solution6.py
821
4.125
4
""" Author : Achintya Gupta Date Created : 22-09-2020 """ """ Problem Statement ------------------------------------------------ Q) The sum of the squares of the first ten natural numbers is, 385 The square of the sum of the first ten natural numbers is, 3025 Hence the difference between the sum of the square...
true
e81ed59d35f3094800cf2c92ad860dfa50fd3dbd
ag-ds-bubble/projEuler
/solutions/solution4.py
924
4.1875
4
""" Author : Achintya Gupta Date Created : 22-09-2020 """ """ Problem Statement ------------------------------------------------ Q) A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the produc...
true
99a4a4fd4f46f677d72f1a41c11fa89d404f9497
arkaris/gb_python_basic
/lesson1/task1.py
368
4.1875
4
user_input = input('Введите 3-значное число: ') numbers = map(int, user_input) numbers_sum = 0; for number in numbers: numbers_sum += number print("Сумма цифр:", numbers_sum) numbers_mul = 1; for number in numbers: numbers_mul *= number print("Произведение цифр:", numbers_mul) input('Работа завершена.')
true
29ede9877a7ecd003c6320b86aa65c0a5a19dfd9
BillyCussen/CodingPractice
/Python/Data Structures & Algorithms Module - Python/Revision/SearchAndSortAlgorithms/BubbleSort1.py
296
4.125
4
""" BubbleSort1.py Billy Cussen 09/02/2021 """ def bubbleSort(list): for i in range(len(list)): for j in range(len(list)-1): if list[j] > list[j+1]: list[j], list[j+1] = list[j+1], list[j] myList = [10,8,4,2,6] bubbleSort(myList) for i in myList: print(i)
false
5d8b1ceb96d3447722a3bafccb880d1809b8be49
BillyCussen/CodingPractice
/Python/Data Structures & Algorithms Module - Python/Revision/SearchAndSortAlgorithms/BubbleSort.py
310
4.125
4
""" BubbleSort.py Billy Cussen 09/02/2021 """ def bubbleSortArray(arr): for i in range (len(arr)): for j in range (len(arr)-1): if(arr[j]>arr[j+1]): arr[j], arr[j+1] = arr[j+1], arr[j] arr1 = [5,4,2,3,1] bubbleSortArray(arr1) for i in range(len(arr1)): print(arr1[i])
false
6f2b7477d373945c06ebb7adccb9ff8b5489e841
BillyCussen/CodingPractice
/Python/Data Structures & Algorithms Module - Python/Week7/Factorial.py
358
4.125
4
""" Factorial.py Billy Cussen 17/11/2020 """ def factorial(num): res = num while num != 1: num-=1 res*=num return res def factorialRecursion(num): if num == 1 or num == 0: return num return num * factorialRecursion(num-1) print("Factorial: "+str(factorial(5))) print("Factor...
false
acc7a33673cb8edc553e7ab7337c425259c187a5
mmayes3/Projects
/Tree-Node/Tree-node.py
1,289
4.25
4
class TreeNode(object): def __init__(self, value): self.value = value self.left = None self.middle = None self.right = None def insert_node(self, new_value): if new_value < self.value: if self.left == None: self.left = TreeNode(new_value) ...
false
d607dcb8b0da5dcbf7e7cded267b4c58ff70cb7e
coder562/python
/83-exercise 18.py
271
4.1875
4
# define a function that takes a number(n) # return a dictionary containing cube of numbers from 1 to n # example # cube_finder(3) # {1:1,2:8,3:27} def cube_finder(n): cubes={} for i in range(1,n+1): cubes[i]=i**3 return cubes print(cube_finder(10))
true
fef7dce0af13470cf2e11f12163e5d14624a5f1a
coder562/python
/74-more about tuples.py
827
4.5
4
#looping in tuple # tuple with one element # tuple without parenthesis # tuple unpacking # list inside tuple # some functions that you can use with tuples mixed=(1,2,3,4.5) # for loop and tuple # for i in mixed: # print(i) #we can use while loop too # tuple with one element nums=(1,) #, is important as python de...
true
b61f899f7e22db47f9793d4f8e4d2f4750f6e729
coder562/python
/65-more about lists.py
547
4.21875
4
#generate lists with range function # something more about pop method # index method # pass list to a function # numbers = list(range(1,10)) numbers=[1,2,3,4,5,6,7,8,9,10,1] # print(numbers) # print(numbers.pop()) #pop returns the value popped # print(numbers) # print(numbers.index(1)) #by defalut search from 0th p...
true
d75bc9a6e32a78551ff8eae7e4bb75adb2226659
coder562/python
/88-list comprehenstion.py
734
4.21875
4
#list compreshension # with the help of list comprehension we can create of list in one line #create a list of squares from 1 to 10 # squares=[] # for i in range(1,11): # squares.append(i**2) # print(squares) #by using list comprehension # square2=[i**2 for i in range(1,11)] # print(square2) # cretate list of n...
true
42e3bb8b71a449580d8b7699b45b76965e89dc41
coder562/python
/52-variable scope.py
390
4.125
4
x=5 #global variable which is defined outside the function def func(): global x #to change the value of global variable we use term global x=7 #the variable defined inside the function are called local variables return x #x has only scope upto func() not in func2() x cant be used outside func() function pri...
true
ed20bbc58702b64ae4b1724646dd431d41f2fcaa
coder562/python
/68-exercise 14.py
343
4.5625
5
# define a function that take list of words as argument and # return list with reverse of every element in that list # example # ['abc','tuv','xyz']--->['cba','vut','zyx'] def reverse_elements(l): elements = [] for i in l: elements.append(i[::-1]) return elements words=['abc','tuv','xyz'] print(re...
true
b6dbcf61531c5ec98deaac7f4c4a5b405316acc3
coder562/python
/46-function practice.py
951
4.125
4
# def last_char(name): # return name[-1] # print(last_char("vaishali")) # last_char(9) #error # define function and check number is even or odd # def odd_even(num): # if num%2==0: #% is used to check reminder # return "even" # else: # return "odd" # print(odd_even(10)) #another method # d...
true
774e4fb24567730de3c894550630a51245ed94d0
Ernestoc14/Python
/pila.py
795
4.3125
4
# Implementacion de Pilas en Python Basico y Sencillo para ERDD con LIFO pila = [1,2,3] #Creacion de PILA con tres elementos print('La pila es:') #Impresion de PILA print(pila) #Agregamos elementos por el final print ('Agregamos los numeros 4 y 5 a la Pila') pila.append(4) #Agregamos el elemento 4 a la PILA pila.appe...
false
45c4c66ff2ccb6042a070256a5056ba573708575
nkhanhng/namkhanh-fundamental-c4e15
/session4/homework/turtle_excersise/ex2.py
344
4.15625
4
from turtle import * def draw_rectangle(m,n): for i in range(2): forward(m) left(90) forward(n) left(90) shape("turtle") speed(1) colors = ['red', 'blue', 'brown', 'yellow', 'grey'] for j in colors: color(str(j)) begin_fill() draw_rectangle(50,100) forward(50) ...
true
bd8b9b509d2fe919f97a8685cc8145d1c75b883f
nkhanhng/namkhanh-fundamental-c4e15
/session6/calc.py
640
4.21875
4
def eval(x,y,op): result = 0 if op == "+": result = x + y elif op == "-": result = x - y elif op == "*": result = x * y elif op == "/": result = x // y return result # x = int(input("x = ")) # oper = input("Operation(+,-,*,/): ") # y = int(input("y = ")) # eval...
false
7c207be73a0defe569ec799b188b5b3544bec62b
RavinderSinghPB/data-structure-and-algorithm
/array/Find the number of sub-arrays having even sum.py
1,132
4.15625
4
def countEvenSum(arr, n): # A temporary array of size 2. temp[0] is # going to store count of even subarrays # and temp[1] count of odd. # temp[0] is initialized as 1 because there # a single even element is also counted as # a subarray temp = [1, 0] # Initialize count. sum is sum of el...
true
a822bde45c53e20f84c19e17ef0abb4b8923cc27
RavinderSinghPB/data-structure-and-algorithm
/puzzle/range of comp no.py
442
4.125
4
def factorial(n): a = 1 for i in range(2, n + 1): a *= i return a # to print range of length n # having all composite integers def Range(n): a = factorial(n + 2) + 2 b = a + n - 1 if n==(b-a+1): return 1 else: return 0 #print("[" + str(a) + ", " + str(b) + "]"...
false
7c54a34f8b6476b7ebef606d1416b911b525a135
devodev/cracking_the_coding_interview_practice
/8.recursion/8.4.py
957
4.3125
4
def get_subsets(s): if not s: return None return _get_subsets(s, 0) def _get_subsets(s, n): all_subsets = None if len(s) == n: all_subsets = [] all_subsets.append(set()) else: all_subsets = _get_subsets(s, n+1) item = s[n] more_subsets = [] ...
true
2b1a3141594ad6c66dfa4ce3491b62f7551dccb6
Adem54/Python-Tutorials
/Günün Soruları/3.soru.py
787
4.28125
4
""" Kullanicidan bir kelime alan, ve bu kelimedeki sesli harflerin toplam sayisini ve sesli harflerin kelimenin kacinci harfleri oldugunu ekrana yazdiran python programini yaziniz. Kullanicinin sadece kucuk harfleri kullanidigini varsayabilirsiniz. Ornek Program Outputu: ==================================== lutfen bir ...
false
c8143a9de01ab254cd4cd68b21dbc4962be490ef
Adem54/Python-Tutorials
/Günün Soruları/slice_methdou.py
1,553
4.25
4
a = [10, 12, 13, 17, 19, 21, 24, 27, 31, 34] print(a[:2]) # add 1 number # a[:0] = [30] # add two numbers # a[:0] = [40, 50] # print(a) b = a[:] # Bir listenin kopyasını almak içi kullanırız print(b) # Normalde parmetre olarak 3 eleman alır a[star,stop,step] şekllindedir ve star başlangıç indisi stop duracağı # indis...
false
efeb5601c4525d64eab0adf492fafe131ed921a1
Adem54/Python-Tutorials
/3.Week/python9.py
1,219
4.3125
4
# Kullanıcıya while döngüsü 3 kere doğru pin girme şansı verin.Hatalı girişler için ekrana "Hatalı Giriş. # Tekrar PIN girin" yazdırın # 3 girişten birinde doğru pin girilirse "PIN Kabul Edildi. Hesabınıza Erişebilirsiniz." yazdırın. # 3 girişte de yanlış girilirse "3'den Fazla Giriş Hakkınız Yok. Hesabınız Kilitlendi!...
false
e765fb185b8d55cb1c1a37595e229a1e047ea78c
Adem54/Python-Tutorials
/sinav/9.py
521
4.21875
4
""" Verilen iki liste arasındaki farklı elemanları bulan ve bunlardan yeni bir liste oluşturan program yazınız. Örnek: list1 = [1, 2, 3, 4] list2 = [3, 4, 5, 6] Çıktı: [1, 2, 5, 6] """ def farkli_elemanlari_bul(liste1, liste2): liste = [] for eleman1 in liste1: if eleman1 not in liste2: ...
false
7228c8f644f982b022646dff0c24af3ba0b031c1
Suka91/RS
/CodeArena/CodeArena/Resources/Leap_Year/version3/Leap_Year.py
440
4.34375
4
def leap_year(year): if(...)==0: if(...)== 0: if(...) == 0: print("{0} is a leap year".format(year)) return 1 else: print("{0} is not a leap year".format(year)) return -1 else: print("{0} is a leap y...
true
1c3ed6a743b865524ff8f21fd85105f92996407f
AntonioRafaelGarcia/LPtheHW
/ex20/ex20.py
1,581
4.375
4
# makes argv available in this script from sys import argv # uses argv to assign user input when calling script script, input_file = argv # defines function to read and print input variable file def print_all(f): print(f.read()) # defines function to go to very first line of inputted variable file def rewind(f):...
true
63dbc6ca29923a63a42477c45d138a7c29d7c26e
AntonioRafaelGarcia/LPtheHW
/ex12.py
312
4.28125
4
# string prompts and directly assigns to three separate variables age = input("How old are you? ") height = input("How tall are you? ") weight = input("How much do you weigh? ") # f prints a string statement seeded with those prompted variables print(f"So, you're {age} old, {height} tall and {weight} heavy.")
true
b56b81731cb6a6cacbbdaf7d45d645ea040a10ef
mkwak73/probability
/chapter 1/exercises/exercise1.py
1,183
4.4375
4
# Chapter 1 - Exercise 1 # Author: Michael Kwak # Date: December 26 2016 ####################################################### # # random () - return the next random floating point number in the range [0.0, 1.0) # import random # # get input for number of tosses for this simulation # n = int(input("Enter the val...
true
a7a9e67983effa2597e33420b34085c55e0ed2b7
mkwak73/probability
/chapter 1/exercises/exercise9.py
2,743
4.125
4
# Chapter 1 - Exercise 9 - Labouchere system # Author: Michael Kwak # Date: January 4 2016 ####################################################################################### # # random () - return the next random floating point # number in the range [0.0, 1.0) # import random from math import floor # # defin...
true
6b39f64cd03f762d6f7a8bfb79842a845fac5107
Kowenjko/Python_Homework_13_Kowenjko
/test_2.py
2,973
4.15625
4
""" Examples: triangle = Triangle([3, 3, 3]) Use classes TriangleNotValidArgumentException and TriangleNotExistException Create class TriangleTest with parametrized unittest for class Triangle test data: """ import unittest import math class Triangle: def __init__(self, t): self.t = t def input_valu...
false
ea6b1b325303699febde9050a58e031f18651475
NaregAmirianMegan/Hailstone-Problem
/hailstone_interactive.py
558
4.125
4
def isEven(num): if(num%2 == 0): return True else: return False def applyOdd(num): return 3*num + 1 def applyEven(num): return num/2 def analyze(num, count): if(isEven(num)): num = applyEven(num) else: num = applyOdd(num) if(num == 1): print("Value:...
true
391c94dc9513855243ea8658926ff404ac1510b2
yangwenbinGit/python_programe
/python_04/do_slice.py
2,282
4.1875
4
# 切片 # 取一个list或tuple的部分元素是非常常见的操作。比如,一个list如下: L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack'] # 取前3个元素,应该怎么做?笨办法就是: print(L[0],L[1],L[2]) # 也可以用循环的方式 方式一 i=0 for x in L: if(i<3): print(L[i]) i=i+1 # 方式二 range(5)生成的序列是从0开始小于5的整数 list(range(5)) 会将生成的数转换为list r=[] n=3 for i in list(range(n)): r.app...
false