blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
f38d4534d6a5fdb6565f9124eefc8e7cf00e04e5
satyamachani/python-experiments
/guess game.py
896
4.21875
4
import random print("you are going to play guess game with computer") print("rules are as follows") print("computer guess and you too") print("if ur guess equals computer guess") print("you wins") print("maximum guess allowed are 3") print("we are strating game......") print("ready to play with satya's computer...
true
503eb1fb3f378307e6ff0d9a9ccbd191e592d9b3
hugolribeiro/Python3_curso_em_video
/World3/exercise081.py
811
4.21875
4
# Exercise 081: Extracting data from a lista # Make a program that reads several numbers and put them into a list. After that, show: # A) How many numbers were inputted # B) The numbers list, in descending order # C) If the value 5 is in the list numbers_list = [] want_continue = 'Y' while want_continue != 'N': nu...
true
edaa06ad2bdc494c8011777a3aacf69f5ba2764a
hugolribeiro/Python3_curso_em_video
/World3/exercise096.py
467
4.40625
4
# Objective: Make a program that have a function called Area(). # Receive the dimensions of a rectangular land (width and length) and show its area. # Programmer: Hugo Leça Ribeiro def area(width, length): amount_area = width * length print(f'The area of this land is equal than: {amount_area}m²') width = fl...
true
1f25f848fb152d60b5af77405534750d4c83694c
hugolribeiro/Python3_curso_em_video
/World2/exercise060.py
408
4.3125
4
# Exercise 060: Factorial calculation # Make a program that read any number and show its factorial # Example: 5! = 5 X 4 X 3 X 2 X 1 = 120 number = int(input('Input here a number: ')) factorial = 1 print(f'{number}! = ', end='') for multiply in range(number, 0, -1): factorial = multiply * factorial print(f'{mu...
true
45a18da87d6d6a4b6d6dc201dbce51a6b44dab87
hugolribeiro/Python3_curso_em_video
/World2/exercise071.py
857
4.21875
4
# Exercise 071: ATM simulator # Make a program that simulates the operation of an ATM. # At the begin, ask to the user what value will be withdraw (an integer number) # and the program will informs how many banknotes of each value will be give. # Observation: Consider that the banking box has these banknotes: R$ 50, R$...
true
63f0901cc32517c7090232184e6179db607d1f87
hugolribeiro/Python3_curso_em_video
/World1/exercise013.py
265
4.125
4
# Exercise 013: Income readjustment # Build an algorithm that read the employee's income and show his new income, with 15% increase. income = float(input(f"Input here the employee's income: ")) new_income = income * 1.15 print(f'The new income is: {new_income}')
true
3127270d8291d1794b18cc66b47a0d547ba9b353
hugolribeiro/Python3_curso_em_video
/World2/exercise052.py
572
4.125
4
# Exercise 052: Prime numbers # Make a program that read an integer number and tell if it is or not a prime number. def verify_prime(num): if num < 2 or (num % 2 == 0 and num != 2): return False else: square_root = int(num ** 0.5) for divisor in range(square_root, 2, -1): if...
true
8fb71045715791f1d73d8394de33b5af4400a102
hugolribeiro/Python3_curso_em_video
/World2/exercise043.py
740
4.625
5
# Exercise 043: body mass index (BMI) # Make a program that read the weight and the height of a person. # Calculate his BMI and show your status, according with the table below: # - Up to 18.5 (not include): Under weight # - Between 18.5 and 25: Ideal weight # - Between 25 and 30: Overweight # - Between 30 and 40: Obes...
true
c99de9678d8cc3cd067ab93f3480a5c75f850bee
hugolribeiro/Python3_curso_em_video
/World3/exercise086.py
510
4.4375
4
# Exercise 086: Matrix in Python # Make a program that create a 3x3 matrix and fill it with inputted values. # At the end, show the matrix with the correct format matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] for line in range(0, 3): for column in range(0, 3): matrix[line][column] = int(i...
true
5cad30469285efa036089dd993eaa595bb0ecdf4
as3379/Python_programming
/String_manipulation/reverse_alternate_words.py
629
4.3125
4
def reverseWordSentence(Sentence): # Splitting the Sentence into list of words. words = Sentence.split(" ") # Reversing each word and creating # a new list of words # List Comprehension Technique n = len(words) for i in range (0, n): if i%2 !=0: words[i] = words[i][::...
true
8e37ac3431bffcc74f9c66f16938409ef2277561
as3379/Python_programming
/String_manipulation/middle_char.py
377
4.25
4
"""Print middle character of a string. If middle value has even then print 2 characters Eg: Amazon -->print az """ def middle_char(S): S = S.replace(" ", "") # mid = "" n = len(S) if n%2 ==0: mid = S[n//2 -1]+ S[n//2] else: mid = S[n//2 -1] print(mid) middle_char("Amazon"...
true
0d8d1c23ee883c8ecb465b1ea25b9b2bf60bf01f
blueicy/Python-achieve
/00 pylec/01 StartPython/hw_5_2.py
358
4.1875
4
numscore = -1 score = input("Score:") try: numscore = float(score) except : "Input is not a number" if numscore > 1.0 : print("Score is out of range") elif numscore >= 0.9: print("A") elif numscore >= 0.8: print("B") elif numscore >= 0.7: print("C") elif numscore >= 0.6: print("D") elif numscore >= 0.0: pr...
true
8954c50cc3a94b3966da8d67efb3359ad57683cc
RomanLopatin/Python
/HW_5/5_1.py
542
4.25
4
"""" Создать программно файл в текстовом формате, записать в него построчно данные, вводимые пользователем. Об окончании ввода данных свидетельствует пустая строка. """ with open("my_file_.txt", "w") as my_file_obj: while True: new_str = input("Введите новую строку: ") if new_str != "": ...
false
cc8429fb4b812f7af16b4afd4be2a072be9957d5
RomanLopatin/Python
/HW_3/HW_3.6.py
1,571
4.25
4
""" 6. Реализовать функцию int_func(), принимающую слово из маленьких латинских букв и возвращающую его же, но с прописной первой буквой. Например, print(int_func(‘text’)) -> Text. Продолжить работу над заданием. В программу должна попадать строка из слов, разделенных пробелом. Каждое слово состоит из латинских букв в ...
false
489259c1f202adff5817dbedde48efeff65f2258
scienceiscool/Permutations
/permutation.py
2,248
4.15625
4
# CS223P - Python Programming # Author Name: Kathy Saad # Project Title: Assignment 6 - Generators and Iterators - Permutations # Project Status: Working # External Resources: # Class notes # https://www.python.org/ class PermutationIterator: def __init__(self, L): self.counter = 0 self.length_for_co...
true
420505fb8d7e2230e8554772d8e60c2efbb83017
kunalprompt/numpy
/numpyArray.py
735
4.4375
4
''' Hello World! http://kunalprompt.github.io Introduction to NumPy Objects ''' print __doc__ from numpy import * lst = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] print "This a Python List of Lists - \n", lst print "Converting this to NumPy Object..." # creating a numpy object (ie. a multidimensional array) num_obj = array...
true
37c1c60959104197272a204209bcf432165f2474
mumudexiaomuwu/Python24
/00Python/day11/basic03.py
2,313
4.15625
4
""" Python中的一场处理try-except 1- 多个异常python可以写在同一行,括号包括多个异常,逗号隔开 2- 获取异常的信息描述通过 as e的方式 3- 发生异常执行except,不发生异常执行else,两者对立 """ try: file = open("Test.txt", "r") except (FileNotFoundError, NameError) as e: print("捕获到了异常,异常信息%s, 准备补救工作..." % e) # file = open("Test.txt", "w") except Exception as e: ...
false
10c4c93bfb93b007d3399f4ab25a6911c9a36d71
mumudexiaomuwu/Python24
/00Python/day09/basic04.py
1,825
4.46875
4
""" python中的类和对象, 所有的类的祖先都是object和java是一样的 1- 前两种叫做经典类存在python 2.x中, 最后一种叫做新式类 2- python 2中类并没有父类,自己就是父类 3- 而python3中得class Person(object)存在父类,可以使用根类的方法 """ class Person: pass class Person(): pass class Person(object): pass """ 1- 实例方法的第一个形参是self自身,表示调用该方法的对象,谁调用谁就是self 2- 给一个**对象...
false
1edd03dbe49721b23b8b90bc4e8eb66d4970c666
mumudexiaomuwu/Python24
/00Python/day11/basic01.py
2,716
4.5
4
""" 如果在类的外面取值和修改私有属性的值,需要自己定义get/set方法 """ class Person(object): def __init__(self): self.name = "老王" self.__age = 20 def get_age(self): return self.__age def set_age(self, age): self.__age = age p = Person() print(p.name) p.name = "王五" print(p.name) print(p.get_ag...
false
251547ce931257c34f2f185c503ff3bf6e4a8c2f
mumudexiaomuwu/Python24
/00Python/day04/basic03.py
1,236
4.375
4
""" help(str) """ help(str) # 查看str数据类的所有方法和说明 help(str.count) # 查看str数据类的某个具体方法,方法说明文档 """ list列表**有序**数据结构,python中的list可以装任何类型的元素在同一个list中 如果遍历list的时候想要获取index,好像只能使用while小于len的方法 """ a_list = [1, 3.14, "hello world", True, [1,2,3] ] b_list = [] c_list = list() print(len(c_list)) # 返回0表示这个list是一个空的l...
false
49694169a4ab556bcd9072ff168c8dd894008455
ffnbh777/Udacity-Adventure-Game
/udacity_game.py
2,680
4.125
4
import time import random import sys def print_pause(message_to_print): print(message_to_print) time.sleep(2) def intro(): print_pause("You find yourself in a dark dungeon.") print_pause("In front of you are two passageways.") print_pause("Which way do you want to go right or left?") def pla...
true
30d5b462c8dda72993475a485a3583f4c45fac5f
tkj5008/Luminar_Python_Programs
/Object_Oriented_Programming/Demo5.py
929
4.15625
4
#instance variable- relatedtomethods using self #Static variable related to class # class Student: # def setvalue(self,name,rollno,age,standard): # self.name=name # self.rollno=rollno # self.age=age # self.standard=standard # def printvalue(self): # print("Name",self.name...
false
fc25cd3651f146956a075bc5c258b6181adbcee8
judebattista/CS355_Homework
/hw02/reverseComplement.py
1,980
4.4375
4
# function to find the reverse complement of a DNA strand # pattern: A string representation of DNA consisting of the chars 'A', 'C, 'G', and 'T' # complements: a dictionary translating a nucleotide to its complement # revComp: The pattern's complement, complete with 5' to 3' reversal # We may need to store complement ...
true
b78d2fe914cdf429651d076b7627d2daad9269f7
Timeverse/stanCode-Projects
/SC101_Assignment5/largest_digit.py
1,176
4.59375
5
""" File: largest_digit.py Name: ---------------------------------- This file recursively prints the biggest digit in 5 different integers, 12345, 281, 6, -111, -9453 If your implementation is correct, you should see 5, 8, 6, 1, 9 on Console. """ def main(): print(find_largest_digit(12345)) # 5 print(find_larg...
true
4294c826dfd8f6d9bf071505312717642616f2c6
WorkRock/python_lab
/lab5_10~11.py
2,513
4.3125
4
""" 주제 : 좌표 클래스 정의 작성일 : 17. 10. 30. 작성자 : 201632023 이지훈 """ class Coordinate: """ 좌표를 표현하는 클래스 정의 """ def __init__(self, a, b): """ 좌표를 초기화 :param a: x좌표의 값 :param b: y좌표의 값 """ self.x = a self.y = b def prnt(self): """ 출력하는 ...
false
7efcb0b3f5aa5622e90423c07dd92952fc3f5c07
TryHarder01/SantaBot
/code/draft_bot_chatting.py
2,639
4.15625
4
""" The conversation logic to get the information from users """ username = 'NAME_GOES_HERE' introduction = "Hello {}, before we start let me check if we've done this before...".format(username) new= """Ok let's do this. I'm going to ask you for three things you like and three things you don't like. Once everyone has...
true
c8518987eda51e8866d77f42c7913e2f64bb9d37
tarakaramaraogottapu/CSD-Excercise01
/01_prefix_words.py
1,029
4.34375
4
import unittest question_01 = """ Given a query string s and a list of all possible words, return all words that have s as a prefix. Example 1: Input: s = “de” words = [“dog”, “deal”, “deer”] Output: [“deal”, “deer”] Explanation: Only deal and deer begin with de. Example 2: Input: s = “b” words = [“banana”, “bin...
true
fd071f09d7fb9dfb95e9ce399eadc08dedc05f72
pankajanand18/python-tests
/trees/sachin.py
532
4.1875
4
# Question 1: Given a string of words return all words which have their reverse present in the string as ( (word1 , reverseword1 ) , (word2 ,reverseword2) ) # eg . # Input - # Sachin tendulkar is the best tseb eth nihcaS input='Sachin tendulkar is the best tseb eth nihcaS' hash={} word='' for char in ...
false
1dcba14f0fb6b1e4ec92993a0ad8980fb1588bdf
Puneeth1996/programiz.com
/Python Introduction/Additon with single statement.py
639
4.34375
4
""" # This program adds two numbers num1 = 1.5 num2 = 6.3 # Add two numbers sum = float(num1) + float(num2) # Display the sum print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) # Store input numbers num1 = input('Enter first number: ') num2 = input('Enter second number: ') # Add two numbers sum = f...
true
332aaf6ab6405d2fdeef7ba789b4736437531b8c
mateo42/Project-Euler
/problem005.py
587
4.15625
4
# smallest positive number that is evenly divisible by all of the numbers from 1 to 20 def multiplesOf20(): '''Yield increasing multiples of 20''' i = 20 while True: yield i i += 20 def divisibleByAll( number ): ''' Checks that arguments is divisible by 3 - 19 ''' # Skip 1, 2, 20 for i in range(3,20): if ...
true
50d9761e41347ae4992d85276f54ba0a00662c08
Jazaltron10/Python
/Time_Till_Deadline/Time_Till_Deadline.py
556
4.28125
4
from datetime import datetime user_input = input("enter your goal with a deadline separated by colon\n") input_list = user_input.split(":") goal = input_list[0] deadline = input_list[1] deadline_date = datetime.strptime(deadline,"%d/%m/%Y") # calculate how many days from now till deadline today_date = datetime.toda...
true
ff235c77c3e02717f0aab5ed57005cb826a076a6
GilmendezCR/Python_Fundamentals
/Procesar Cadena de caracters/Ejercicio_2.py
953
4.21875
4
#Ingresar una oración que pueden tener letras tanto en mayúsculas como minúsculas. #Contar la cantidad de vocales. #Crear un segundo string con toda la oración en minúsculas para que sea más fácil disponer la condición que verifica que es una vocal. contadorVocales = 0 oracion = input("Ingrese una oración: ") oracion....
false
a894c5576be8236857d3c6040c9187fbbe16fa80
GilmendezCR/Python_Fundamentals
/Funciones/Ejercicio_1.py
617
4.15625
4
#Desarrollar un programa que solicite la carga de tres valores y muestre el menor. #Desde el bloque principal del programa llamar 2 veces a dicha función (sin utilizar una estructura repetitiva) def ingresar_valor(): valor1 = int(input("Ingrese un valor: ")) valor2 = int(input("Ingrese un valor: ")) valor3...
false
ddee8e59a44e8f76b83f63ebcc1054c8e6e1d128
EdgarUstian/CSE116-Python
/src/tests/UnitTesting.py
721
4.1875
4
import unittest from lecture import FirstObject class UnitTesting(unittest.TestCase): def test_shipping_cost(self): small_weights = [15.0, 10.0, 20.0, 25.0, 10.0] large_weights = [45.0, 30.1, 30.0, 55.0] def compute_shipping_cost(weight): if weight < 30: return 5.0 else: return 5.0 + (weigh...
true
d311cb7a2bd31e9cd658714257c7db218e429a59
code-rejoice/Learn-With-Examples-Python
/Examples/4_functions.py
1,294
4.375
4
#tutorials 4: functions print( "-->examples to define functions\n" ) x = str(input("enter an alphabet: \n")) print ("entered alphabet is ",x) def vowelTest(alphabet): vow=['a','e','i','o','u'] if any(alphabet in s for s in vow) : print("TEST PASS: the given alphabet is a vowel") else: print("TEST FAILED: th...
false
0768f554f6d4780360f4cf27f7fdc3f4734a1f4b
rishav-karanjit/Udemy-Python-Basic
/6. Project 1 - Basic Calculator/1. Getting the data.py
465
4.4375
4
# input() -> Takes user input in the form of string a = int(input("Enter a integer:")) #We have changed string to integer because operations like addition cannot be performed in string b = int(input("Enter a integer:")) sign = input("Enter \n + for addition \n - for substraction \n * for multiplication \n / for divis...
true
e128fc066b44c825fd4ad8e0c38afacc931b385d
massadraza/Python-Learning
/defualt_Values_for_arguements.py
282
4.1875
4
def get_age(age = "Unknown"): if age is "13<": age = 'kid' elif age is "13>": age = 'teen' elif age is '18>': age = 'adult' print (age) get_age('13<') get_age('13>') get_age('18>') get_age() # Learning about defualt Values for arguements
false
504e771762dc1227fab5e0d4572629c1e7a5cbcd
MattSokol79/Python_Control_Flow
/loops.py
824
4.375
4
# Loops for loop and while loop # for loop is used to iterate through the data 1 by 1 for example # Syntax for variable name in name_of_data collection_variable shopping_list = ['eggs', 'milk', 'supermalt'] print(shopping_list) for item in shopping_list: if item == 'milk': print(item) sparta_user_details...
true
db08593250bf45ccc385036980ef67711cb3bf87
wonkim0512/BDP
/week2/palindrome.py
249
4.3125
4
# palindrome checker def palindrome(): string = raw_input("Enter the sentence what you want to chech palindrome:") if string == string[-1::-1]: print "It is palindrome!" else: print "It is not palindrome" palindrome()
false
2365ccf635085dfa2e38e28d80aa7a1811eb0279
Ch-sriram/python-advanced-concepts
/functional-programming/exercise_2.py
405
4.1875
4
# Small exercises on lambda expressions # Square each element in the list using lambda expression my_list = [5, 4, 3] print(list(map(lambda item: item ** 2, my_list))) # Sort the following list on the basis of the 2nd element in the tuple my_list = [(0, 2), (4, 3), (9, 9), (10, -1)] print(sorted(my_list, key=lambda t...
true
0dda899681dd50663c3aa5a81c3ef00a1df6f090
Ch-sriram/python-advanced-concepts
/functional-programming/reduce.py
1,061
4.125
4
''' The reduce() function isn't provided by python directly. reduce() function is present inside the functools package, from which we import the reduce() function. In the functools library, we have functional tools that we can use to work with functions and callable objects. ''' from functools import reduce # synta...
true
795e15a99a91d2857fbdfab497ecaccd1789c0e8
ilarysz/python_course_projects
/data_structures/3_stack/linkedstack.py
920
4.28125
4
from linkedlist import LinkedList class LinkedStack: """ This class is a stack wrapper around a LinkedList. """ def __init__(self): self.__linked_list = LinkedList() def push(self, node): """ Add a node to the start of the linked list property. :param node: The No...
true
91f4b5659ced240b326e011c4228713a8fd378c4
github-hewei/Python3_study
/2/5.面向对象.py
787
4.21875
4
# 面向过程 # 创建一个苹果 apple = {} apple['name'] = '苹果' apple['color'] = '红色' apple['price'] = 10 print('我吃了一个%s'%apple['name']) # 创建一个香蕉 banana = {} banana['name'] = '香蕉' banana['color'] = '黄色' banana['price'] = 20 print('我吃了一个%s'%banana['name']) # 面向对象 class food: name = '' color = '' price = 0 def __init...
false
60ce10d064bf776b47d4e35da055b4a88d2a88aa
likhi-23/DSA-Algorithms
/Data Structures/linked_queue.py
1,828
4.1875
4
#Linked Queue class Node: def __init__(self, data): self.data = data self.next = None class Queue: def __init__(self): self.head = None self.tail=None def enqueue(self, data): if self.tail is None: self.head =Node(data) self.tail =self.head else: self.tail.next = No...
true
91c9488189f2895212594e1834cb54f5de713b8e
lpjacob/RPN-Calculator
/operand_queue.py
1,025
4.15625
4
""" Program to perform demonstrate a static queue in Python by ljacob1@canterbury.kent.sch.uk Purpose: to demonstrate queue operation, Limitations: WIP - not currently fully tested """ """global variables""" queue = [] maxSize = 5 #constant to set max queue size tailPointer = 0 def queueSize(): global queue ...
true
8cfc47ff3793abb4c6cac760607941d198c3064d
ayushi710/basic-python-program
/pattern1.py
253
4.125
4
# using for loop for i in range(6): for j in range(i): print("*",end=" ") print("\r") print("\n") # using while loop i = 1 while i <= 6: j = 1 while j <= i: print("* ",end="") j = j+1 i = i+1 print("\r")
false
91bf3c7be3b61637fa8b66c891a5c3d26fb713f8
zhangqunshi/common-utils
/python/file/remove_duplicate_line.py
607
4.1875
4
# coding: utf8 # # Remove the duplicate line of a file # import sys def remove_duplicate_line(filename): exist_lines = list() with open(filename) as f: for line in f.readlines(): line = line.strip() if not line: continue if line not in exist_lines:...
true
64b82c06f17926340b3f49e8fe8ccc27f716f367
robeertgr/Geek_University_Python_Secao_5
/estruturas_logicas_and_or_not_is.py
686
4.15625
4
""" Estruturas lógicas: and (e), or (ou), not (não) e is (é). Operadores unários: - not Operadores binários: - and, or, is # Regras de funcionamento # Para o 'and', ambos os valores precisam ser True # Para o 'or', um ou outro valor precisa ser True # Para o 'not', o valor do booleano é invertido """ ativo =...
false
78123433f18d7959d1f7f264e85c4afd964cb878
coala/workshops
/2016_07_03_doctesting_in_python_lasse/sum.py
320
4.3125
4
def sum(*args): """ Sums up all the arguments: >>> sum(1, 2.5, 3) 6.5 If you don’t provide any arguments, it’ll return 0: >>> sum() 0 :param args: Any numbers to sum up. :return: The sum of all the given """ return args[0] + sum(*args[1:]) if len(args) > 0 else 0
true
15b5608a5d690e4fbc40285ea65c94a81195f624
dhruvilthakkar/Dhruv_Algorithm_and_Games
/check_prime.py
267
4.15625
4
#!/usr/bin/env python from __future__ import print_function def check_prime(num): for i in range(2,num): if num % i == 0: print('Number is not prime') break print('Number is prime') num = input('Enter number to check for: ') check_prime(num)
true
29b21b246bd6eadf38f3e71b23d61a5f4590c05f
Alireza-Helali/Design-Patterns
/ProtoType_p2.py
1,500
4.125
4
from copy import deepcopy """ ProtoType: prototype is creational design pattern that lets you copy existing objects without making your code dependant on your classes """ class Address: def __init__(self, street, building, city): self.street = street self.building = buildi...
true
5acdaf70d6cb94d97a315d255ca6a1db1e027c44
Alireza-Helali/Design-Patterns
/Interface_Segregation_principle.py
2,207
4.3125
4
# Interface Segregation Principle """ The idea of interface segregation principle is that you dont really want to stick too many elements or too many methods in to an interface. """ from abc import ABC, abstractmethod class Machine(ABC): @abstractmethod def printer(self, document): pass @abstr...
true
e49b2f20b098d8119943430968da3d841376642c
sarwar1227/Stone-Paper-Scissors-E-Game
/stone_paper_scissors E-Game.py
2,659
4.15625
4
'''Stone Paper Scissors E-Game by SARWAR ALI(github.com/sarwar1227) using Python Technologies Required To Run this Code : Pyhton(32/64 bit) version 2/3+ INSTRUCTIONS TO PLAY THIS GAME : 1.Computer Randomly chose between ston/paper/scissors 2.You are asked to chose your option 3.Based on some camparisons...
true
c5bf8c4f132f30281414a6ea88f67ff977c14131
MarianaMedeiros/python-basics
/part14_args_kwargs.py
1,956
4.75
5
""" args e kwargs """ """ Digamos que queremos criar uma função de ordem alta que tem como entrada uma função f e retorna uma função nova que retorna duas vezes o valor de f para qualquer entrada: """ def doubler(f): def g(x): return 2 * f(x) return g """ isto funciona em alguns casos: """ def f1(x...
false
d23a81e251ccfb2000f3de8ac0e93db194e08bee
shasha9/30-days-of-code-hackerrank
/Day_04_ClassVSInstance.py
1,345
4.21875
4
#Task # Write a person class with an instance variable age and a constructor that takes an integer initialAge as a parameter. #The constructor must assign initialAge to age after confirming the argument past as initialAge is not negative; #if a negative argument is passed past as initilAge, the constructor should set ...
true
7373b562b5e59201e6ffdcdde140e33dba3ce468
thiteixeira/Python
/Sum_Avg_Variance_StdDeviation.py
898
4.21875
4
#!/usr/bin/env python ''' Compute the Sum, Average, Variance, Std Deviation of a list ''' grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def grades_sum(grades): total = 0 for grade in grades: total += grade return total def grades_average(grades): sum_of_grades = grades...
true
caeb99fe34437b5d5adc1c31cad03bbc30e31e35
ASHOK6266/fita-python
/w3resource/python3/List/exercise.py
1,614
4.34375
4
''' 1. Write a Python program to sum all the items in a list. list_values = [2,4,5,6] index = 0 while index < len(list_values): print(list_values[index]) index += 1 ---------------------------------------------------------------------------------------------------------------------------------------------...
true
7b8cbe2a5228cc3153d40bfeaf976cd1f8857f42
PatrickPitts/Brainworms
/lab2/SeasonsAndDays.py
1,526
4.40625
4
# Author : John Patrick Pitts # Date : June 21, 2021 # File : SeasonsAndDays.py # imports essential libraries import sys # gets data input from the user day_num = eval(input("Enter a number between 1 and 7: ")) season = input("Enter a season: ") day = "" month = "" # lists to check against for type of season spr...
true
fac443035144eb723c6df6a82fa4405079c49b10
Ewa-Gruba/Building_AI
/Scripts/C3E15_Nearest_Neighbor.py
947
4.15625
4
import math import random import numpy as np import io from io import StringIO import numpy as np x_train = np.random.rand(10, 3) # generate 10 random vectors of dimension 3 x_test = np.random.rand(3) # generate one more random vector of the same dimension def dist(a, b): sum = 0 for ai...
true
7bf4d9a3ac26769a211fe336c56d5cef6c0e0522
willamesalmeida/Maratona-Datascience
/Semana 1 - O poderoso Python/fase 2 - Exercicios/Estruruda de Decisão/Exercicio 2.py
285
4.28125
4
# 2 - Faça um Programa que peça um valor e mostre na tela se o valor é positivo ou negativo. valor = float(input("Forneça um valor e direi se é positivo ou negativo: ")) if valor < 0: print("O valor fornecido é negativo! ") else: print("O valor fornecido é positivo! ")
false
8044c59728a243d5ba9e974e0a8c62c3dd9cf750
ingehol/RomanNumerals
/main.py
2,205
4.21875
4
# Function for turning integers into roman numerals. # Creating lists with integers and the corresponding roman numerals. integers = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000] romans = ["I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"] def int_to_roman(val): i = 12 roman_from_nu...
true
10cc4bf9eb93419251371f45e589c194f7cdd2f4
SeanIvy/Learning-Python
/ex6 (2).py
2,000
4.25
4
# --------------------------------- # Header # --------------------------------- # LPTHW - Exercise 6 # Sean Ivy - 050912 # Exercise 6 - Strings and Text # --------------------------------- # Start Code # --------------------------------- # Setting up Variables # --------------------------------- x = "There are %d ...
true
abb45bb26b7448d89575f90cc770b5e34fdc1135
NoeNeira/practicaPython
/Guia_1/Ejercicio10.py
562
4.28125
4
"""Escribir un programa que almacene todas las letras del abecedario y luego elimine las vocales y nos devuelva una lista sin las vocales, sin modificar la original """ abecedario = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "ñ", "o", "p", "q", "r", "s", "t", "u", "v", "w", "...
false
6b6b490f63b1be54482cd36444e3c88e5bb461a9
NoeNeira/practicaPython
/Guia_2/Ejercicio1.py
662
4.40625
4
""" Pedir al usuario que ingrese un mensaje cualquiera, si el mensaje tiene más de 100 caracteres imprimirlo por pantalla, si tiene entre 50 y 100 caracteres imprimirlo al revés, si no se cumple ninguna de las opciones anteriores, por pantalla devolver un mensaje que diga "su mensaje es demasiado corto" """ texto =...
false
770edf3dc3dbde450b0c82e276193f413a633732
aidenyan12/LPTHW
/EX36/ex36.py
2,848
4.15625
4
from sys import exit def cave(): print "You're in a cave, a dragon is living inside to safeguard the magic sword" print "You need to take the sword as a weapon to kill the evil king to safe the country" print "You can choose 'sing' to make the dragon fall alseep or 'fight' with the dragon" action = raw_input("> "...
true
eff4b958a0918618ab71b8d275fe0b2b10792fb4
Sayan725/Sayan725
/say.py
261
4.21875
4
num1 = int(input('Enter first number: ')) num2 = int(input('Enter second number: ')) op = input('Enter Operator') if op == '+': print(num1+num2) if op == '-': print(num1-num2) if op == '*': print(num1*num2) if op == '/': print(num1/num2)
false
07265f21311c4a90056ddf0f4c7458cfdae4e880
DokiStar/my-lpthw-lib
/ex11.py
719
4.21875
4
print("How old are you?", end=' ') # input默认返回字符串类型 age = input() print("How tall are you?", end=' ') height = input() print("How much do you weight?", end=' ') weight = input() print(f"So, you're {age} old, {height} tall and {weight} heavy.") # 更多输入 str = input("Input some text here: ") str2 = input("more things her...
true
7032001cac6b18552bb161bb3c07f55961cc8230
greenfox-zerda-lasers/matheb
/week-03/day-2/36.py
243
4.25
4
numbers = [3, 4, 5, 6, 7] # write a function that reverses a list def rev(numbers): newlist = [] for i in range(len(numbers)-1, -1, -1): print(numbers[i]) newlist.append(numbers[i]) print(newlist) rev(numbers)
true
cf934c557b66a540408af48e1c5ebb3dcc0ea7e1
andyyu/coding-problems
/maximum_product_of_three.py
1,811
4.125
4
# Andy Yu ''' Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output: 6 Example 2: Input: [1,2,3,4] Output: 24 Note: The length of the given array will be in range [3,104] and all elements are in the range [-1000, 1000]. Multiplication of an...
true
c47c78d8b585483eac06ee47a9c55b02b22bb741
andyyu/coding-problems
/is_palindrome.py
686
4.21875
4
# Andy Yu ''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome. Note: Have you consider that the string might be empty? This is a good question to ask during an ...
true
99cbb8dac0fe03bad60919a4ebfcf3be8e5e434a
andyyu/coding-problems
/string_permutation.py
315
4.15625
4
# Andy Yu ''' Print all permutations of a string. Difficulty: Easy Solution notes: O(n*n!) time O(1) space ''' def permutate(string, prefix = ''): if (len(string) == 0): print prefix else: for char in string: permutate(string[:string.index(char)] + string[string.index(char)+1:], prefix + char)
true
b648720e20cae1330c7a094599027bcf991b58ed
andyyu/coding-problems
/is_anagram.py
701
4.125
4
# Andy Yu ''' Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s = "rat", t = "car", return false. Note: You may assume the string contains only lowercase alphabets. Follow up: What if the inputs contain unicode characters? How ...
true
830c75cf9be01d0b3dbdf8ccf275d5f5aab9a000
andyyu/coding-problems
/invert_binary_tree.py
1,293
4.21875
4
# Andy Yu ''' Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None Difficul...
true
b79af958a03cd31deaf3d794f18fb4eea8f8dafa
andyyu/coding-problems
/last_word_length.py
1,001
4.15625
4
# Andy Yu ''' Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is defined as a character sequence consists of non-space characters only. For example, Given s = "Hello World",...
true
9fc1ffb05b7a6892d43c8909a37a26e99abed9fc
errorport/makker_python
/makker_python_00.py
2,164
4.28125
4
# Fibonacci számok generálása pythonnal # Az alábbi példakód segítségével egy N elemű fibonacci számsort generálhaunk. # 01 Az első példában csak egy for ciklus használatával tesszük ezt. print("Példa 01.") N=10 n_1 = n_2 = 1 for i in range(N): actual_number = n_1 + n_2 n_1 = n_2 n_2 = actual_number print(actual_n...
false
9bef8335c8629608d0982148e814acfed3bab9f0
BelfastTechTraining/python
/examples/mymodule.py
865
4.15625
4
def sum_numeric_list(nums): """ Accepts a list of numeric values. Returns the sum of the elements. """ sum = 0 for item in nums: sum += item return sum def prune_dict(dict, keys_to_remove): """ Accepts a dict to priune and a list of keys to remove. Matching keys are del...
true
b36f2f7a5bc5cc1dd1bc500bfe4c45d1f34f547f
pdaplyn/adventOfCode2018
/solutions/day1.py
1,326
4.1875
4
""" >>> test = ["+1", "+1", "+1"] >>> calc_frequency(test) [0, 1, 2, 3] >>> test = ["+1", "+1", "-2"] >>> calc_frequency(test) [0, 1, 2, 0] >>> test = ["-1", "-2", "-3"] >>> calc_frequency(test) [0, -1, -3, -6] >>> test = ["+1", "-2", "+3", "+1"] >>> calc_frequency(test) [0, 1, -1, 2, 3] >>> find_first_repeated( test )...
true
7b81131365a385f8ec425940868509c4729ad1dc
danielbrock4/election_analysis_tom
/practice_examples_files/test.py
1,313
4.34375
4
# F STRINGS my_votes = () my_votes = int(input("How many votes did you get in the election")) total_votes =int(input('What is the total number of votes')) print(f"I recieved {my_votes / total_votes * 100} % of the total votes") counties = {} counties_dict = {"Arapahoe": 369237, "Denver":413229, "Jefferson": 390222} fo...
false
b9ce5e24adecc9b4795c536dc833a0cfd8699d1a
BaggyKimono/pythonfoundationswow
/02 Printpractice.py
956
4.5625
5
""" title: Printpractice author: Ally date: 11/26/18 10:36 AM """ print("hello world") #new line print("hello world\nhell is other people") #end a print statement with a thingy print("newline", end = "-") #tabbed characters print("Testing, testing\t1\t2\t3...") print("Testing, testing\n\t1\n\t\t2\n\t\t\t3...")...
true
2a5b009c76623d935619a982b43a244fff186646
marri88/python-base
/FILES/prob3.py
721
4.3125
4
# Создайте программу, которая считает из файла текст, # и если в тексте содержится буква “w”, # то выведет на экран “Да, в тексте есть w”, # иначе - “Нет, в тексте нет w”. # Подсказка: используйте ключевое слово in. h = open('/home/aimira/python/python3/week2files/text.txt', 'r') if 'w' in h.read() : print('Да,...
false
9a9809371f87dc2cff66822fb73be8650bf2a972
marri88/python-base
/FILES/prob7.py
900
4.125
4
# Напишите программу которая спрашивает от пользователя 2 вещи: # 1.Путь до картинки которую нужно изменить. # 2.Путь до картинки НА которую нужно изменить. # Если оба пути существуют перепишите первую картинку на вторую, если нет скажите пользователю какой картинке не существует. q = input('Путь до картинки которую...
false
3802ff2190f66bfe3cb233429ade648bb7ecbffb
marri88/python-base
/FUNCTION1/prob3.py
1,299
4.34375
4
# Создайте функцию сложения, затем функцию вычитания двух чисел... # Создайте 3-ю функцию которая вызывает первые 2 внутри себя. # def plus(a,b): # print(a + b) # def minus(a,b): # print(a - b) # def umnojenie(a,b): # print(a * b) # def delenie(a,b): # print(a / b) # def otvet(a,b): # plus(a,b...
false
fb77c633d7e76d980de7db18abd7251447286de3
marri88/python-base
/IF_ELIF_ELSE/prob11.py
309
4.125
4
a=10 b=5 if a>0 and b>0: print("положительный") '''У вас есть переменные a=10 и b=5 Напишите условие которое проверяет, являются ли ваши переменные положительными числами(только один if)'''
false
b2b874aabe434bbc8001adca9ad7c70407f290e0
TarasovaYuliya/Python
/lectures/lecture02/While2.py
454
4.53125
5
# Задача: поиск натуральных чисел, результат возведения двойки в которые меньше ста x = 1 y = 2 ** x while y < 100: # проверка, не превышает ли степень 100 print(y) # вывод текущей степени двойки x += 1 # увеличение показателя y = 2 ** x # расчет следующей степени 2
false
4ba9bb1961d7dfd94f6019cda03c0fa31c0a0a96
ysr20/comp110-fa20-lab02
/draw_polygon.py
601
4.6875
5
""" Module: draw_polygon Program to draw a regular polygon based on user's input. """ import turtle # create a turtle and set the pen color duzzy = turtle.Turtle() duzzy.pencolor("red") # asks user for the length of the pentagon go_forward=int(input("Enter a length for the pentagon: ")) #asks user for number of side...
true
0d6fbc8b255a676dbc6b6da8608eee3367615187
Portfolio-Projects42/UsefulResourceRepo2.0
/GIT-USERS/TOM2/WEBEU3-PY1/guessing.py
1,080
4.3125
4
## guessing game where user thinks of a number between 1 and 100 ## and the program tries to guess it ## print the rules of the game print("Think of a number between 1 and 100, and I will guess it.") print("You have to tell me if my guess is less than, greater than or equal to your number.") # set a sentinal value t...
true
da2734b97e7b3b1449ed1688e1406e4c62e2e726
Portfolio-Projects42/UsefulResourceRepo2.0
/GIT-USERS/TOM2/WEBEU3-PY1/day1.py
1,819
4.15625
4
# This is a comment # lets print a string print("Hello, World!") # variables name = "Tom" age = 40 print("Hello, " + name) # f strings name = "Bob" print(f"Hello, {name}") # collections # create an empty list? lst1 = [] # lst1 = list() # create a list with numbers 1, 2, 3, 4, 5 lst2 = [1, 2, 3, 4, 5] # add an ...
true
665e20a76c940043340a84f48abec890420458e0
App-Dev-League/intro-python-course-jul-2020
/Session7/NestedLoops/main.py
279
4.1875
4
#Nested Loops for i in range(5): for j in range(5): print(f"The value of i is {i} and the value of j is {j}") #Nested lists and loops table = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] print(table) for row in table: print(row) for col in row: print(col)
true
30238131f2827d86fe4f530b1c7b39600c2dbdc4
App-Dev-League/intro-python-course-jul-2020
/Session2/DataTypes/strings.py
473
4.1875
4
#Strings name = "Krish" print(name) print(type(name)) #Indexing and Slicing print(name[0]) print(name[4]) print(name[2:4]) #get characters from 2 to 4 (not included) print(name[-1]) #gets last index print(name[-2]) #gets second to last index print(name[:]) #gets whole string #Length print(len(name)) #Common String...
true
7aa74118c759dff5f3ac767deaf623dfcae7b411
Yesidh/holbertonschool-web_back_end
/0x00-python_variable_annotations/5-sum_list.py
516
4.28125
4
#!/usr/bin/env python3 """ =============================================================================== a type-annotated function sum_list which takes a list input_list of floats as argument and returns their sum as a float. =============================================================================== """ from t...
true
6b04ab4f3a44d03cf78390e3f85deeb8af7c0cc6
DikranHachikyan/CPYT210409-PLDA
/ex55.5.py
669
4.15625
4
# 1. дефиниция на клас class Point: # Конструктор на класа def __init__(self): print('Point Ctor') # данни класа self.x = 20 self.y = 30 # Методи на класа def draw(self): print(f'draw point at: ({self.x},{self.y})') if __name__ == '__main__': # 2. декл...
false
6e74663f896df96e049596bcd6c2962c7a5b3767
hombreamarillo/aprendo_python
/01-FuncionesBasicos.py
942
4.28125
4
# Repaso de el tema de Funciones """ este block de trabajo es para aprender todo sobre lso metodos en python ya que estory aprendiedo a usar este en programación orientada a objetos """ print("Comensamos con el uso de Funciones") divisas = {"PEN": 3.256, "MXN": 20, "PESO": 3745.41} def definir_tipo_cambio(tipo_mone...
false
d0c5db82d901898df3259ef51bcfc03de773eeee
PatrickJCorbett/MSDS-Bootcamp-Module-5
/module5_python.py
2,777
4.34375
4
#first just a test, print "hello world" print("hello world") ##Exercise 1: print the time #import the datetime function from the datetime package from datetime import datetime #put the current time into a variable now = datetime.now() #print the current time print(now) ##Exercise 2: simple stopwatch #Create the sto...
true
da4610110e6e7e580e52700b9fbe42c6f6fa0a19
Nirvighan/Python-C100-Project-
/ATM.py
1,231
4.125
4
# CREATE THE CLASS class ATM(object): #CREATE __INIT__ FUNCTION #IT IS SAME LIKE CONSTRUCTO IN JAVA def __init__(self,name,age,cardNumber,PIN,TotalAmount): #USE SELF #IT IS SAME LIKE THIS IN JAVA self.name = name self.age = age self.cardNumber = cardNumber ...
true
057ed18abae64e416e94891e2c1bdb530ff20db9
jigsaw2212/Understanding-Regular-Expressions
/RedEx_findall.py
971
4.6875
5
#findall() function for regular expressions finds all the matches of the desrired pattern in a string, and returns them as a list of strings #findall automatically does the iteration import re #Suppose we have a list with many email addresses str = 'purple alice-b@google.com, blah monkey bob@abc.com blah dishwasher' ...
true
893b3c73e03bb2d07fd0d2b6fa1da8cf1b8dd6ef
vanigupta20024/Programming-Challenges
/CaesarCipher.py
1,468
4.40625
4
''' Caesar cipher: Encryption technique also called the shift cipher. Each letter is shifted with respect to a key value entered. ''' print("Enter 0 for encryption and 1 for decryption:") n = int(input()) enc_text = "" print("Enter the input string: ", end = "") text = input() print("Enter key: ", end = "") key = int(i...
true
05bed03f2a6c548af9c820ec4872c7ec36c168e8
vanigupta20024/Programming-Challenges
/FindHighestAltitude.py
684
4.125
4
''' There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0. You are given an integer array gain of length n where gain[i] is the net gain in altitude between points i and i + 1 for all (0 <= i < n). Return the hig...
true
de4d4235835ca1b871af439494367b2119c909d9
vanigupta20024/Programming-Challenges
/ReshapeTheMatrix.py
1,279
4.34375
4
''' You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the wanted reshaped matrix, respectively. The reshaped matrix need to be filled with all the elements of the original matrix in the same row-traversing order as they wer...
true
a64ffa6636d8f087557f9acb8ebe9c08c98226d6
vanigupta20024/Programming-Challenges
/RevVowelsOfString.py
625
4.15625
4
''' Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases. Example 1: Input: s = "hello" Output: "holle" ''' class Solution: def reverseVowels(self, s: str) -> str: vowels = ['a', 'e', 'i', 'o', 'u', 'A', '...
true
98054d8c3947eca001b99d37f491cc0205878bf9
corvolino/estudo-de-python
/Atividades-Estrutura-Sequencial/atividade11.py
738
4.28125
4
''' Faça um Programa que peça 2 números inteiros e um número real. Calcule e mostre: o produto do dobro do primeiro com metade do segundo . a soma do triplo do primeiro com o terceiro. o terceiro elevado ao cubo. ''' numero1 = int(input("\nInforme o primeiro número: ")) numero2 = int(input("Informe o segu...
false