blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
03be2c4df4c404636dd5599ca939e5692cba538d
mecomontes/Python
/Desde0/listConprehension.py
2,545
4.40625
4
"""Qué son las list comprehensions Básicamente son una forma de crear listas de una manera elegante simplificando el código al máximo. Como lo oyes, Python define una estructura que permite crear listas de un modo un tanto especial. Te lo mostraré con un ejemplo:""" numeros = [1, 2, 34, 86, 4, 5, 99, 890, 45] pare...
false
5b1d73fe53c06e6973112db0962a48fa454a40a1
mecomontes/Python
/Fundamentos Python/Fun_Seleccion1.py
1,638
4.21875
4
#!/usr/bin/env python #-*- coding: utf-8 -*- def Fun_Crea_Lista(): import random # Crea una lista a partir de numeros aleatorios # Generar un numero aleatorio(7-10) # Generar una lista de números aleatorios de acuerdo al número generado en el punto anterior # Mostrar: # El nume...
false
e68f7daf7a588470c36b131e13606b458298906d
sunnyyants/crackingPython
/Recursion_and_DP/P9_5.py
1,169
4.21875
4
__author__ = 'SunnyYan' # Write a method to compute all the permutation of a string def permutation(string): if string == None: return None permutations = [] if(len(string) == 0): permutations.append("") return permutations firstcharacter = string[0] remainder = string[1:...
true
70269b4f1997e6509e7323da0d8a7592355e0ef5
sunnyyants/crackingPython
/Trees_and_Graph/P4_4.py
850
4.1875
4
__author__ = 'SunnyYan' # Given a binary tree, design an algorithm which creates a linked list # of all the nodes at each depth(e.g., if you have a tree with depth D, # you'll have D linked lists from Tree import BinarySearchTree from P4_3 import miniHeightBST def createLevelLinkedList(root, lists, level): if...
true
2db3135898b0a57ef68bc4005a12874954b4809f
sunnyyants/crackingPython
/strings_and_array/P1_7.py
893
4.40625
4
__author__ = 'SunnyYan' # # Write an algorithm such that if an element in an M*N matrix is 0, # set the entire row and column to 0 # def setMatrixtoZero(matrix): rowlen = len(matrix) columnlen = len(matrix[0]) row = [0]*rowlen column = [0]*columnlen for i in range(0, rowlen): for j in range...
true
cf53a1b7300099ea8ecbe596ac2cb6574642e05f
sainath-murugan/small-python-projects-and-exercise
/stone, paper, scissor game.py
1,231
4.21875
4
from random import randint choice = ["stone","paper","scissor"] computer_selection = choice[randint(0,2)] c = True while c == True: player = input("what is your choice stone,paper or scissor:") if player == computer_selection: print("tie") elif player == ("stone"): if computer_selection =...
true
0bea4a359a651daeb78f174fe3fb539e118c39ad
asperaa/programming_problems
/linked_list/cll_create.py
1,345
4.34375
4
# class for Circular linked list node class Node: # function to initiate a new_node def __init__(self, data): self.data = data self.next = None # class for circular linked list class CircularLinkedList: # function to initialise the new_node def __init__(self): self.head = None...
true
316c16a74400b553599f007f61997e65a5ed0069
asperaa/programming_problems
/linked_list/rev_group_ll.py
1,889
4.25
4
""" Reverse a group of linked list """ class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: # initialise the head of the linked list def __init__(self): self.head = None # add a new node to the end of linked list def add_node(self, ...
true
f7fa6a108c3a05c476fa48b679ec81b9dab0edd7
asperaa/programming_problems
/linked_list/rev_ll.py
1,383
4.25
4
# Node class class Node: def __init__(self, data): self.data = data self.next = None # LinkedList class class LinkedList: def __init__(self): self.head = None def push(self, data): new_node = Node(data) new_node.next = self.head self.head = new_no...
true
e05982cee993abbc9163123021f57d352d644225
asperaa/programming_problems
/stack/queue_using_stack.py
834
4.34375
4
"""Implement queue using stack i.e only use stack operations""" class Queue: def __init__(self): self.s1 = [] self.s2 = [] def empty(self): return len(self.s1) == 0 def push(self, val): self.s1.append(val) def pop(self): while len(self.s1) != 0: ...
false
956495f4026844ed336b34512c87aceec11c0ef8
asperaa/programming_problems
/linked_list/reverse_first_k.py
2,093
4.375
4
"""Reverse the first k elements of the linked list""" # Node class for each node of the linked list class Node: # initialise the node with the data and next pointer def __init__(self, data): self.data = data self.next = None # Linked list class class LinkedList: # initialise the head of the...
true
b1507117769677b028c86f588a88e91e67ef410f
asperaa/programming_problems
/binary_search/sqrt(x).py
385
4.1875
4
"""sqrt of a number using binary search""" def sqrtt(x): if x < 2: return x l = 2 r = x//2 while l <= r: pivot = l + (r-l)//2 num = pivot*pivot if num > x: r = pivot - 1 elif num < x: l = pivot + 1 else: return pivot ...
false
9bd1ec0e8941bae713a60098d73bc0d7f996bf9c
eldimko/coffee-machine
/stage3.py
1,047
4.34375
4
water_per_cup = 200 milk_per_cup = 50 beans_per_cup = 15 water_stock = int(input("Write how many ml of water the coffee machine has:")) milk_stock = int(input("Write how many ml of milk the coffee machine has:")) beans_stock = int(input("Write how many grams of coffee beans the coffee machine has:")) cups = int(inpu...
true
69a1845303537328dfd0db3c2379b2d094643633
satya497/Python
/Python/storytelling.py
1,340
4.15625
4
storyFormat = """ Once upon a time, deep in an ancient jungle, there lived a {animal}. This {animal} liked to eat {food}, but the jungle had very little {food} to offer. One day, an explorer found the {animal} and discovered it liked {food}. The explorer took the {animal...
true
0f4005420c98c407a9d02e6f601c2fccbf536114
satya497/Python
/Python/classes and objects.py
775
4.46875
4
# this program about objects and classes # a class is like a object constructor #The __init__() function is called automatically every time the class is being used to create a new object. class classroom: def __init__(self, name, age): # methods self.name=name self.age=age def myfunc1(s...
true
5b7f40cc69402346f9a029c07246da2286022c7f
Vk686/week4
/hello.py
212
4.28125
4
tempName = "Hello <<UserName>>, How are you?" username = input("Enter User Name: ") if len(username) < 5: print("User Name must have 5 characters.") else: print(tempName.replace("<<UserName>>",username))
true
1596d1d1e7ef22f858dad005741768c7887a5a0e
wardragon2096/Week-2
/Ch.3 Project1.1.py
296
4.28125
4
side1=input("Enter the first side of the triangle: ") side2=input("Enter the second side of the triangle: ") side3=input("Enter the thrid side of the triangle: ") if side1==side2==side3: print("This is an equilateral triangle.") else: print("This is not an equilateral triangle.")
true
63bcca7240f1f8464135732d795e80b3e95ddd1f
RichardLitt/euler
/007.py
565
4.125
4
# What is the 10001st prime? # Import library to read from terminal import sys # Find if a number is prime def is_prime(num): if (num == 2): return True for x in range(2, num/2+1): if (num % x == 0): return False else: return True # List all primes in order def list_pri...
true
2c91f734d48c6d0ab620b6b5a9715dc4f5e4ddb7
smoke-hux/pyhton-codes
/2Dlistmatrixes.py
1,044
4.46875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 28 05:54:12 2020 @author: root """ matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] print(matrix[1]) matrix[0][1] = 20 print(matrix[0][1]) #we can use nested loops to iterate over every item in the list...
true
4d1f17b48ad9d60432702e4f440b5b42e8182796
ViniciusLoures/BCC701
/[P-04]/p04q04.py
1,223
4.125
4
# Vinicius Alves Loures França 20.1.1039 years = int(input('Anos de experiência: ')) language = int(input('Linguagens de programação: ')) projects = int(input('Projetos: ')) diff_years = 3 - years diff_language = 3 - language diff_projects = 5 - projects diff_years_senior = 10 - years diff_language_senior = 5 - languag...
false
7f44a3ce1ebc5dc682fb9a71a62413640101ed46
mdev-qn95/python-code40
/challenge-counter-app.py
642
4.15625
4
# Basic Data Types Challenge 1: Letter Counter App print("Welcome to the Letter Counter App") # Get user input name = input("\nWhat's your name: ").title().strip() print("Hello, " + name + "!") print("I'll count the number of times that a specific letter occurs in a message.") message = input("\nPlease enter a messa...
true
e5162cfd848d2079cd0a2783413cdce62c365e39
rajkamalthanikachalam/PythonLearningMaterial
/com/dev/pythonSessions/07Functions.py
2,940
4.5625
5
# Function: a piece of code to execute a repeated functions # Recursion: A function calling itself # Arguments : *arg is used to pass a single arguments # Key words : **args is used to pass a multiple arguments in key & value format # Lambda functions : Anonymous functions or function without name # Function def fun...
true
3c83bcb69b992b68845482fbe0cf930bb0faaf22
Japan199/PYTHON-PRACTICAL
/practical2_1.py
257
4.21875
4
number=int(input("enter the number:")) if(number%2==0): if(number%4==0): print("number is a multiple of 2 and 4") else: print("number is multiple of only 2") else: print("number is odd")
true
98d91f20f106a8787e87e6e18bfb0388bb96a24e
Douglass-Jeffrey/Assignment-0-2B-Python
/Triangle_calculator.py
499
4.25
4
#!/usr/bin/env python3 # Created by: Douglass Jeffrey # Created on: Oct 2019 # This program calculates area of triangles def main(): # this function calculates the area of the triangles # input num1 = int(input("Input the base length of the triangle: ")) num2 = int(input("Input the height of the tri...
true
73b8058f76913080f172dd81ab7b76b1889faa11
ibrahimuslu/udacity-p2
/problem_2.py
2,115
4.15625
4
import math def rotated_array_search(input_list, number): """ Find the index by searching in a rotated sorted array Args: input_list(array), number(int): Input array to search and the target Returns: int: Index or -1 """ def findPivot(input_list,start,end): if start == end...
true
894bc08ece7968512d1214ea6853199951b49de5
ffismine/leetcode_github
/普通分类/tag分类_链表/2_两数相加.py
1,657
4.125
4
""" 2. 两数相加 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 示例: 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4) 输出:7 -> 0 -> 8 原因:342 + 465 = 807 """ # 思考: # 需要注意几个点:1,位数不相等 2,进位 3,最后还要进位 # Definition for singly-linked list. # class ListNode: # ...
false
b2b27d69caeab17bc3150e1afe9c1e1de3ac5d9e
aniketchanana/python-exercise-files
/programmes/listMethods.py
922
4.46875
4
# methods are particular to a given class # append insert & extend first_list = [1,2,3,4,5] # first_list.append([1,2,3]) # print(first_list) # [1, 2, 3, 4, 5, [1, 2, 3]] simply pushes it inside the list # no matter what is that <<append takes in only one arguement>> # first_list.extend([1,2,3,4]) # print(first_l...
true
5fbbfd843c662a09a20b1e5bad1861a2a82f53fa
aniketchanana/python-exercise-files
/programmes/bouncer.py
270
4.125
4
age = input("How old are you") if age : age = int(age) if age >= 18 and age < 21 : print("Need a wrist band") elif age>=21 : print("you can enter and drink") else : print("too little to enter") else : print("Input is empty")
true
3b582f75705736982841af1acc369baa26287f05
ethomas1541/Treehouse-Python-Techdegree-Project-1
/guessing_game.py
2,919
4.15625
4
""" Treehouse Python Techdegree Project 1 - Number Guessing Game Elijah Thomas /2020 """ """ Tried to make my code a bit fancy. I have a bit of knowledge beyond what's been taught to me thus far in the techdegree, and I plan to use it to streamline the program as much as I can. """ #Also, fair warning, I ...
true
7e8e5cd20755bc9967dc6800b3614fdc9c8cc8d3
Sheax045/SWDV660
/Week1/week-1-review-Sheax045/temp_converter.py
371
4.375
4
# Please modify the following program to now convert from input Fahrenheit # to Celsius def doConversion(): tempInFAsString = input('Enter the temperature in Fahrenheit: ') tempInF = float( tempInFAsString ) tempInC = ( tempInF - 32 ) / 1.8 print('The temperature in Celsius is', tempInC, 'degrees') fo...
true
72e99be26206ee4fefa8154ca8ee53403f01ae6d
JavierEsteban/TodoPython
/Ejercicios/DesdeCero/1.- Variables y Tipos de Datos/3.- Ejercicios.py
1,580
4.28125
4
## Hallar el promedio de notas con los pesos enviados def main(): nota_1 = 10 nota_2 = 7 nota_3 = 4 notafinal = 10*0.15 + 7*0.35 + 4*0.5 print(notafinal) # Completa el ejercicio aquí if __name__ =='__main__': main() #Ejercicio que cada ultimo registro de la matriz sume los 3 primeros. def ...
false
9e62ba08fa01e6a2d0e3c9aecf93e43c0600992e
hemiaoio/learn-python
/lesson-01/currency_converter_v4.0.py
573
4.25
4
def convert_currency(in_money,exchange_rate): out_money = in_money * exchange_rate return out_money USD_VS_RMB = 6.77 currency_str_value = input("请输入带单位的货币:") # 获取货币单位 unit = currency_str_value[-3:] if unit == 'CNY': exchange_rate = 1/USD_VS_RMB elif unit == 'USD': exchange_rate = USD_VS_RMB else:...
false
7f5a62963e620a00f8e30baf529d82007c1d9076
hemiaoio/learn-python
/lesson-01/currency_converter_v2.0.py
522
4.1875
4
USD_VS_RMB = 6.77 currency_str_value = input("请输入带单位的货币:") # 获取货币单位 unit = currency_str_value[-3:] if unit == 'CNY': rmb_str_value = currency_str_value[:-3] rmb_value = eval(rmb_str_value) usd_value = rmb_value / USD_VS_RMB print('CNY to USD :', usd_value) elif unit == 'USD': usd_str_value = curr...
false
f1c33d5a000f7f70691e10da2bad54de62fc9a8d
sugia/leetcode
/Integer Break.py
648
4.125
4
''' Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. Example 1: Input: 2 Output: 1 Explanation: 2 = 1 + 1, 1 × 1 = 1. Example 2: Input: 10 Output: 36 Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36. Not...
true
a3fc906021f03ed53ad43fbc133d253f74e56daa
sugia/leetcode
/Valid Palindrome.py
697
4.15625
4
''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Output: false ''' class...
true
396253f9798266c4b6b291f272aa7b79c6fa0a0a
sugia/leetcode
/Power of Two.py
498
4.125
4
''' Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Example 2: Input: 16 Output: true Example 3: Input: 218 Output: false ''' class Solution(object): def isPowerOfTwo(self, n): """ :type n: int :rtype: bool """ ...
true
1c59ace51e212ef319a09a5703d88b878ca494e8
sugia/leetcode
/Group Shifted Strings.py
1,102
4.15625
4
''' Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence: "abc" -> "bcd" -> ... -> "xyz" Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence. Exa...
true
cd46ca9292716451523c2fb59813627274928af3
sugia/leetcode
/Strobogrammatic Number II.py
1,197
4.15625
4
''' A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Find all strobogrammatic numbers that are of length = n. Example: Input: n = 2 Output: ["11","69","88","96"] ''' class Solution(object): def findStrobogrammatic(self, n): """ :type n...
true
e0e326f07a8f166d9e424ddd646e563b5e817da9
sugia/leetcode
/Solve the Equation.py
2,867
4.3125
4
''' Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable x and its coefficient. If there is no solution for the equation, return "No solution". If there are infinite solutions for the equation, return "Infinite solutions". If t...
true
8c3ae2289cd214e6288ede5de4a2e296f5d3983b
sugia/leetcode
/Largest Triangle Area.py
1,047
4.15625
4
''' You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points. Example: Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]] Output: 2 Explanation: The five points are show in the figure below. The red triangle is the largest. Notes: 3 <= points.length <=...
true
55926ff3a2bebfaad166335cff41c9edc9aba9a6
joseph-palermo/ICS3U-Assignment-02B-Python
/assignment_two.py
527
4.34375
4
#!/usr/bin/env python3 # Created by: Joseph Palermo # Created on: October 2019 # This program calculates the area of a sector of a circle import math def main(): # This function calculates the area of a sector of a circle # input radius = int(input("Enter the radius: ")) angle_θ = int(input("Enter ...
true
89a55032338f6872b581bbabdfa13670f9520666
Derin-Wilson/Numerical-Methods
/bisection_.py
998
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Feb 4 19:12:56 2020 @author: esha """ # Python program for implementation # of Bisection Method for # solving equations # An example function whose # solution is determined using # Bisection Method. # The function is x^3 - x^2 + 2 def f...
true
b04dee090d6f39bb7ad5a6f31f8a1ad99ada9234
clhking/lpthw
/ex4.py
1,277
4.28125
4
# Set a variable for the number of cars cars = 100 # Set a variable (using a float) for space in each car space_in_a_car = 4 # Set a variable with number of drivers drivers = 30 # Set a variable with number of passengers passengers = 90 # Set up the variable for cars not driven being # of cars minus number of drivers c...
true
3d7c45fb38fd221bca8a9cb22f7509d0106fca65
EricksonSiqueira/curso-em-video-python-3
/Mundo 3 estruturas de dados/Aula 16 (tuplas)/Desafio 074(maior e menor).py
808
4.1875
4
# Crie um programa que vai gerar cinco números aleatório # e colocar em uma tupla. Depois disso, mostre a listagem de números # gerados e também indique o menor e o maior valor que estão na tupla. from random import randint numeros = (randint(0, 20), randint(0, 20), randint(0, 20), randint(0, 20), randint(0, 20)) menor...
false
8a55c35f58b0e598cb6e544df24dcdb02048824c
EricksonSiqueira/curso-em-video-python-3
/Mundo 2 estruturas condicionais e de repeticoes/Aula 15 (do while)/Desafio 071 (Caixa eletronico).py
1,134
4.21875
4
# Crie um programa que simule o funcionamento de um caixa eletrônico. # No início, pergunte ao usuário qual será o valor a ser sacado (número inteiro) e # o programa vai informar quantas cédulas de cada valor serão entregues. # OBS: considere que o caixa possui cédulas de R$50, R$20, R$10 e R$1. print("{:=^34}".form...
false
906d4238eda704289808ee8c99a5388d10f4c948
EricksonSiqueira/curso-em-video-python-3
/Mundo 2 estruturas condicionais e de repeticoes/Aula 14 (while)/Desafio 065 (Maior e Menor).py
762
4.15625
4
# Crie um programa que leia vários números inteiros pelo teclado. No final da # execução, mostre a média entre todos os valores e qual foi o maior e o menor valores lidos. # O programa deve perguntar ao usuário se ele quer ou não continuar a digitar valores. r = 's' s = 0 media = 0 maior = 0 menor = 0 c = 0 while r !=...
false
5a693ea54065d8ee521cddb8be003f7f357813bb
joelhrobinson/Python_Code
/object types.py
668
4.25
4
########################## # this is a list mylist = [1, "joel", 2, 'henry', 3, 'Robinson', 4, "Brenda"] print ('mylist=',mylist) mydict = {"mykey":"value", "Name":"Frankie"} print ('mydictionary=',mydict) mytuple = tuple(mylist) print ('mytuple=',mytuple) print (type(mytuple)) ###############################...
false
c7796becfd43fdc5339bf2b707390c090a2ed8c9
SergioOrtegaMartin/Programacion-Python
/3er Trimestre/Ej 11/Ej 11.py
2,537
4.15625
4
'''a)Hacer un ejercicio donde se crea una agenda en formato csv Para ello el usuario introduce 3 valores (nombre, tel, email) hasta que el nombre sea una cadena vacia Esta función debe ser un archivo csv que guardaremos como ‘agenda.csv’''' '''b)crear otra funcion (carga)que le paso el nombre de la agenda y me l...
false
e82a0d351645c38a97eb004714aae9ab377e13f4
vaelentine/CoolClubProjects
/mags/codewars/get_middle_char.py
1,231
4.3125
4
""" Get the middle character From codewars https://www.codewars.com/kata/56747fd5cb988479af000028/train/python You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 cha...
true
51b06ab89a0b7a96d973ad14a2a75703697e5d2c
JMBarberio/Penn-Labs-Server-Challenge
/user.py
2,532
4.15625
4
class User(): """ The user class that contains user information. Attributes: ----------- name : str The name of the user. clubs : list The list of the clubs that the user is in fav_list : list The bool list of whether or not a club has been favorite...
true
817d35dd6ee95282807850ca348a78528516beed
jhill57/Module-4-Lab-Activity-
/grading corrected.py
1,553
4.4375
4
# Calculating Grades (ok, let me think about this one) # Write a program that will average 3 numeric exam grades, return an average test score, a corresponding letter grade, and a message stating whether the student is passing. # Average Grade # 90+ A # 80-89 B # 70-79 C # 60-69 D # 0-59 F # Exams: 89, 90, 90 # Aver...
true
1b48abeed7454fea2a67ed5afc2755932e093d32
CTEC-121-Spring-2020/mod-6-programming-assignment-tylerjjohnson64
/Prob-3/Prob-3.py
521
4.125
4
# Module 7 # Programming Assignment 10 # Prob-3.py # <Tyler Johnson> def main(): number = -1 while number <0.0: x = float(input("Enter a positive number to begin program: ")) if x >= 0.0: break sum = 0.0 while True: x = float(input("Enter a pos...
true
c9804338656ff356407de642e3241b44cc91d085
leon0241/adv-higher-python
/Term 1/Book-1_task-6-1_2.py
659
4.28125
4
#What would be the linked list for.. #'brown', 'dog.', 'fox', 'jumps', 'lazy', 'over', 'quick', 'red', 'The', 'the' #... to create the sentence... #'The quick brown fox jumps over the lazy dog' linkedList = [ ["brown", 2], #0 ["dog.", -1], #1 ["fox", 3], #2 ["jumps", 5], #3 ["lazy", 7], #4 ["ov...
true
907c008de30d2238a729f5245af0623721d5f96e
leon0241/adv-higher-python
/Project Euler/Resources/prime_algorithms.py
1,225
4.21875
4
import math def find_primes(n): #Finds primes below n primeList = [2] for i in range(3, n, 2): primeList.append(i) #Makes array of odd number to number n(even numbers are not prime) for i in range(3, (int(math.sqrt(n)) + 1), 2): #cycle for i = 3 for j in primeList: if j...
false
b56a066a3e11ed1e8e3de30a9ed73c35975e8c2e
leon0241/adv-higher-python
/Pre-Summer/nat 5 tasks/task 6/task_6a.py
218
4.1875
4
name = input("what's your name? ") age = int(input("what's your age? ")) if age >= 4 and age <= 11: print("you should be in primary school") elif age >= 12 and age <= 17: print("you should be in high school")
true
f827f2a2a2f34903b2b9dfc738b603573f69aac4
gitHirsi/PythonNotes
/001基础/018面向对象/07搬家具.py
1,154
4.15625
4
""" @Author:Hirsi @Time:2020/6/11 22:32 """ # 定义家具类 两个属性:名字和占地面积 class Furniture(): def __init__(self, name, area): self.name = name self.area = area # 定义房屋类 4个属性:地理位置,房屋面积,剩余面积,家具列表 class House(): def __init__(self, address, area): self.address = address self.area = area ...
false
76c2bacefc0f6f33dfaf37682b8be84303754cdb
gitHirsi/PythonNotes
/001基础/019面向对象_继承/08私有属性和方法.py
1,609
4.1875
4
""" @Author:Hirsi @Time:2020/6/12 22:10 """ """ 1.定义私有属性和方法 2.获取和修改私有属性值 """ # 师傅类 class Master(object): def __init__(self): self.kongfu = '《师傅煎饼果子大法》' def make_cake(self): print(f'运用{self.kongfu}制作煎饼果子') # 学校类 class School(object): def __init__(self): self.kongfu = '《学校煎饼果子大法》' ...
false
1eaba137311948a4042e1c25a0238d79db17f27b
SouriCat/pygame
/7_Intermédiaire __ La portee des variables et utilisation dans les fonctions.py
1,500
4.25
4
## Fonctionnement normal d'une fonction et des variables ##--> la variable locale est Dispo dans tous le documents, mais les fonctions doivent l'avoir en parametre pour l'utiliser var1 = "parametre1" var2 = "parametre2" def fonction(parametre1, parametre2): print (parametre1, "a bien été passé dans la fonc...
false
a32adf43016c39fa5c413703b48ff5628cc6f0cf
SouriCat/pygame
/8_Intermédiaire __ Manipulation de chaines de caractères.py
1,726
4.3125
4
##### Manipulation des chaines de caractères str1 = 'Bonjour' # unicode str2 = "Bonjour" # utf8 ##---> L'echappement permet d'afficher des signes utilisés pour coder #\' \" ##---> Retour chariot, a mettre a la fin de la ligne #\n\ ## retour chariot facile : # str3 = """ texte sur # plusieurs ligne...
false
67ef1b27449b3dd39629b8cc675e519ac462663e
RitaJain/Python-Programs
/greater2.py
226
4.25
4
# find greatest of two numbers using if else statment a=int(input("enter a ?")) b=int(input("enter b ?")) if (a>b): print("a is greater than b", a) else: print("b is greater than a",b)
true
1c1b6f7379b46515bab0e2bcddf0ed78bf527cc4
vipulm124/Python-Basics
/LearningPython/LearningPython/StringLists.py
355
4.40625
4
string = input("Enter a string ") #Method 1 reverse = '' for i in range(len(string)): reverse += string[len(string)-1-i] if reverse==string: print("String is a pallindrome. ") else: print("Not a pallindrome. ") #Method 2 rvs = string[::-1] if rvs == string: print("String is a pallindrome. ") else...
true
bd17263b5e1af3fc2ec8ea1929959c1844ffecbc
arias365/juego-python
/3ra.py
2,731
4.1875
4
nombre = input("digite su nombre: ") print("hola ", nombre, " bienvenido") #tema de la clases 7 n1 = int(input('introduce n1: ')) n2 = int(input('introduce n2: ')) print(type(n1)) print('la suma de los numeros es: ', n1 + n2) print('la suma de los numeros es: {}'.format(n1+n2)) print('la suma de ', n1, ' y ', n2, 'es',...
false
5c40d587eb5bea2adab8c6a6ae27c461ec45ed74
bhattaraiprabhat/Core_CS_Concepts_Using_Python
/hash_maps/day_to_daynum_hash_map.py
995
4.40625
4
""" Built in python dictionary is used for hash_map problems """ def map_day_to_daynum(): """ In this problem each day is mapped with a day number. Sunday is considered as a first day. """ day_dayNum = {"Sunday":1, "Monday":2, "Tuesday":3, "Wednesday":4, "Thursday":5, "Friday":...
true
3dc10b40ad44521c1b628324e38b976f88cca26d
bhattaraiprabhat/Core_CS_Concepts_Using_Python
/recursion/fibonacci_series.py
580
4.25
4
""" This module calculates Fibonacce series for a given number input: an integer return : Fibonacce series """ def main(): number = input("Enter an integer : ") for i in range (int(number)): print ( fibonacci(i), end= ", " ) print () def fibonacci(n): """ Calculates the...
false
1e6eb33a7057383f2ae698c219830b5408ba7ab5
lilamcodes/creditcardvalidator
/ClassMaterials/parking lot/review.py
1,563
4.34375
4
# 1. Dictionary has copy(). What is it? # DEEP dict1 = {"apple": 4} dict2 = dict1.copy() dict1["apple"] = 3 # print("dict1", dict1) # print("dict2", dict2) # SHALLOW dict1 = {"apple": [1,2,3]} dict2 = dict1.copy() copy = dict1 dict1["apple"].append(5) # print("dict1", dict1) # print("dict2", dict2) # print("...
true
f9ca56364b52e6da5cb52c00396872294c04e5eb
lilamcodes/creditcardvalidator
/ClassMaterials/day7/beginner_exercises.py
1,701
4.59375
5
# Beginner Exercises # ### 1. Create these classes with the following attributes # #### Dog # - Two attributes: # - name # - age # #### Person # - Three Attributes: # - name # - age # - birthday (as a datetime object) # ### 2. For the Dog object, create a method that prints to the terminal the name...
true
bd8cab740890c73454f7fc27c28c9ee41db707b5
YarDK/lesson2
/comparison.py
1,323
4.59375
5
''' Сравнение строк Написать функцию, которая принимает на вход две строки Проверить, является ли то, что передано функции, строками. Если нет - вернуть 0 Если строки одинаковые, вернуть 1 Если строки разные и первая длиннее, вернуть 2 Если строки разные и вторая строка 'learn', возвращает 3 Вызвать функцию несколько р...
false
1b82d057d603672ef90d083bbc59dd34de075736
saurabh-ironman/Python
/sorting/QuickSort/quicksort.py
1,419
4.15625
4
def partition(array, low, high): #[3, 2, 1] # [1, 2, 3] # choose the rightmost element as pivot pivot = array[high] # pointer for greater element i = low - 1 # traverse through all elements # compare each element with pivot for j in range(low, high): if array[j] <= pivot: ...
true
57cb8daab27142956246f0a849924a1a4103cd21
n9grigoriants/python
/removing.py
374
4.125
4
nums = [1, 2, 3, 4, 5, 6, 7, 8] print(nums) nums.remove(3) #используем , если заранее известно значение объекта для удаления print(nums) #nums.remove(5) возникнет ошибка nums.pop() print(nums) res = nums.pop(2) print(nums) print("Был удален элемент со значением " + str(res))
false
ffc17a58e989094e5a31092826b501a6b22f2652
JayWelborn/HackerRank-problems
/python/30_days_code/day24.py
417
4.125
4
def is_prime(x): if x <=1: return False elif x <= 3: return True elif x%2==0 or x%3==0: return False for i in range(5, round(x**(1/2)) + 1): if x%i==0: return False return True cases = int(input()) for _ in range(cases): case ...
true
27a8884bada5af0cb7fea5b1fcc5d6e255188150
jeetkhetan24/rep
/Assessment/q11.py
755
4.28125
4
""" Write a Python program to find whether it contains an additive sequence or not. The additive sequence is a sequence of numbers where the sum of the first two numbers is equal to the third one. Sample additive sequence: 6, 6, 12, 18, 30 In the above sequence 6 + 6 =12, 6 + 12 = 18, 12 + 18 = 30.... Also, you can spl...
true
4f73f3d4dee08f41dbcf97fba090d1a2cf605c01
chc1129/python_jisen
/04/strFstring.py
703
4.53125
5
# 文字列の変数置換 # f-string -- 式を埋め込める title = 'book' f'python practive {title}' # 変数の値で置換 print( f'python practive {title}' ) f'python practice {"note" + title}' # 式を利用 print( f'python practice {"note" + title}' ) def print_title(): print(f'python practice {title}') print_title() title = 'sketchbook' print_title() ...
false
6febde39059c62422f858e99718fa7471c7aa50b
Aternands/dev-challenge
/chapter2_exercises.py
1,538
4.25
4
# Exercises for chapter 2: # Name: Steve Gallagher # EXERCISE 2.1 # Python reads numbers whose first digit is 0 as base 8 numbers (with integers 0-7 allowed), # and then displays their base 10 equivalents. # EXERCISE 2.2 # 5---------------> displays the number 5 # x = 5-----------> assigns the value "5" t...
true
6362fb8b4b02d0ad66a13f68f59b233cdde2038b
jgarcia524/is210_lesson_06
/task_01.py
847
4.5625
5
#!usr/bin/env python # -*- coding: utf-8 -*- """Listing even and odd numbers""" import data from data import TASK_O1 def evens_and_odds(numbers, show_even=True): """Creates a list of even numbers and a list of odd numbers. Args: numbers (list): list of numbers show_even (bool): de...
true
e35d9de64d658fff3adf421be31b0caf23f3e2b1
pfreisleben/Blue
/Modulo1/Aula 14 - Exercicios Obrigatórios/Exercicio 2.py
493
4.125
4
# 02 - Utilizando estruturas de repetição com variável de controle, faça um programa que receba # uma string com uma frase informada pelo usuário e conte quantas vezes aparece as vogais # a,e,i,o,u e mostre na tela, depois mostre na tela essa mesma frase sem nenhuma vogal. frase = input("Digite a frase: ").lower() voga...
false
c77b54073b94153f22acc361fe864339194caf9f
pfreisleben/Blue
/Modulo1/Aula 10 - While/Exercicio 1.py
353
4.25
4
""" Exercício 1 - Escreva um programa que pede a senha ao usuário, e só sai do looping quando digitarem corretamente a senha. """ senha = "9856321" digitada = input("Digite sua senha: ") while digitada != senha: print("Senha incorreta, digite novamente!") digitada = input("Digite sua senha: ") print(f'Você d...
false
315cdba74cd51658d39a788a872a3e33c62eac6f
pfreisleben/Blue
/Modulo1/Aula 14 - Exercicios Obrigatórios/Exercicio 7.py
573
4.1875
4
# 07 - Crie um programa onde o usuário possa digitar sete valores numéricos e cadastre-os em uma # lista única que mantenha separados os valores pares e ímpares. No final, mostre os valores pares # e ímpares em ordem crescente. lista = [[], []] continua = 0 while continua < 7: numero = int(input("Digite um número...
false
6b17a68c013f999b3547abbedd93f12166061c72
pfreisleben/Blue
/Modulo1/Aula 12 - CodeLab Dicionário/Desafio.py
1,865
4.1875
4
""" DESAFIO: Crie um programa que leia nome, sexo e idade de várias pessoas, guardando os dados de cada pessoa em um dicionário e todos os dicionários em uma lista. No final, mostre: A) Quantas pessoas estão cadastradas. B) A média da idade. C) Uma lista com as mulheres. D) Uma lista com as idades que estão acima da mé...
false
d2e2b75a85e09aab40dca105c1cf1cabe404ea07
ScottPartacz/Python-projects
/Pick_3_Lotto.py
2,334
4.1875
4
# Scott Partacz 1/25/2018 ITMD 413 Lab 3 import time import random def check (picked,wining_numbers) : if(wining_numbers == picked) : win_or_lose = True elif(wining_numbers != picked) : win_or_lose = False return win_or_lose; def fireball_check(fireball,picked,wining_numbers) : count =...
true
8c13e0f0fe77d59c514d3b071f1488169a461755
Eduardo271087/python-udemy-activities
/section-9/multiple-exceptions.py
1,285
4.28125
4
variable = float(input("Introduce algo: ")) # Si se introduce una letra # File "/home/eduardo-fernandez/source/python-udemy-activities/section-9/multiple-exceptions.py", line 1, in <module> # variable = float(input("Introduce algo: ")) # ValueError: could not convert string to float: 'l' a = 2 print("Resultado...
false
92cd0001b602a0cdea7e03d6170ba6bd500aca0f
bauglir-dev/dojo-cpp
/behrouz/ch01/pr_13.py
227
4.46875
4
# Algorithm that converts a temperature value in Farenheit to a value in Celsius farenheit = float(input("Enter a temperature value in Farenheit: ")) celsius = (farenheit - 32) * (100/180) print(str(celsius) + ' Celsius.'))
true
d5dde1216cb6e77f8b92a47de57268447c4189c3
V4p1d/Assignment-1
/Exercise_4.py
406
4.40625
4
# Write a program that receives three inputs from the terminal (using input()). # These inputs needs to be integers. The program will print on the screen the sum of these three inputs. # However, if two of the three inputs are equal, the program will print the product of these three inputs. # Example 1: n = 1, m = 2, l...
true
2af76dc77f4cebd7d13f517141f6ef633c073700
prakhar-nitian/HackerRank----Python---Prakhar
/Sets/Set_.intersection()_Operation.py
2,053
4.3125
4
# Set .intersection() Operation # .intersection() # The .intersection() operator returns the intersection of a set and the set of elements in an iterable. # Sometimes, the & operator is used in place of the .intersection() operator, but it only operates on the set of elements in set. # The set is immutable to the .int...
true
843ddcb5a7fd997179c284d6c18074282a70ab0a
KULDEEPMALIKM41/Practices
/Python/Python Basics/67.bug.py
295
4.5625
5
print('before loop') for i in range(10,0,-1): # -1 is write perameter for reverse loop. print(i) print('after loop') print('before loop') for i in range(10,0): # if we are not give iteration in range function. it is by default work print(i) # on positive direction. print('after loop')
true
ad929f0d120653cf303cf7d59018eccdedae04c6
KULDEEPMALIKM41/Practices
/Python/Python Basics/114.multiple.py
2,399
4.3125
4
# 4. multiple inheritance => # (base for C)CLASS A CLASS B(base for C) # | | # | | # ______________________________________ # | # | # CLASS C(derived for A and B) # Drawback of other technology => # 1.if base class wi...
true
722f02a018763d5c18297e2977130e8be8c2093c
KULDEEPMALIKM41/Practices
/Python/Python Basics/36.control.py
536
4.1875
4
#Control Structure -> # 1.Conditional Statement 2.Control Statement 3.Jumping Procedure # a) if-statement a) while loop a) break # b) if-else statement b) for loop b) continue # c) if-elif-else(ladder if-else c) pass #Conditional Statement -> it is use to implement decision makin...
false
534146d46f8c71c9edec393105942add3bc01f5a
KULDEEPMALIKM41/Practices
/Python/Single Py Programms/statistics_module.py
1,459
4.15625
4
from statistics import * a = [1,10,3.5,4,6,7.3,4] b = [2,2,3,8,9] print("mean(a) - ",mean(a)) # The mean() method calculates the arithmetic mean of the numbers in a list. print("mean(b) - ",mean(b)) print("median(a) - ",median(a)) # The median() method returns the middle value of numeric data in a list. print("medi...
true
302d09455ea91820c27d2529516bbd55efcf6348
KULDEEPMALIKM41/Practices
/Python/Python Basics/40.if-else.py
263
4.125
4
#program for find divisiable number from 5 and10. #jo 10 se divisiable hogi vo 5 se almost divide hogi. n=int(input('Enter any number')) if n%10==0: print('divisible') else: #we will give different indentation in if and else part. print('not divisible')
false
0702ece64a2e2eaffc7fa970ddf974ec2f244dbf
minhnhoang/hoangngocminh-fundamental-c4e23
/session3/password_validation.py
424
4.28125
4
pw = input("Enter password: ") while True: if len(pw) <= 8: print("Password length must be greater than 8") elif pw.isalpha(): print("Password must contain number") elif pw.isupper() or pw.islower(): print("Password must contain both lower and upper case") elif pw.isdigit(): ...
true
c298d41657f00d72a8718da8741c9d0cf24acc3a
oreolu17/python-proFiles
/list game.py
1,284
4.1875
4
flag = True list = [ 10,20,30,40,50] def menu(): print("Enter 1: to insert \n Enter 2: to remove \n Enter 3: to sort \n Enter 4: to extend \n Enter 5 to reverse \n Enter 6: to transverse") def insertlist(item): list.append(item) def remove(item): list.remove(item) def sort(item): list.sort() def extend...
true
cf0ffad1f8470707cf05177287c5a085b8db0098
shubham3207/pythonlab
/main.py
284
4.34375
4
#write a program that takes three numbers and print their sum. every number is given on a separate line num1=int(input("enter the first num")) num2=int(input("enter the second num")) num3=int(input("enter the third num")) sum=num1+num2+num3 print("the sum of given number is",sum)
true
d3a882a461e6f5b853ea7202592418618539c5e1
llmaze3/RollDice.py
/RollDice.py
679
4.375
4
import random import time #Bool variable roll_again = "yes" #roll dice until user doesn't want to play while roll_again == "yes" or roll_again == "y" or roll_again == "Yes" or roll_again == "Y" or roll_again == "YES": print("\nRolling the dice...") #pause the code so that it feels like dice is being rolled #sleep ...
true
246d6138de3857dd8bf9a4488ebcce3d9f1c7144
StevenLOL/kaggleScape
/data/script87.py
1,355
4.34375
4
# coding: utf-8 # Read in our data, pick a variable and plot a histogram of it. # In[4]: # Import our libraries import matplotlib.pyplot as plt import pandas as pd # read in our data nutrition = pd.read_csv("../input/starbucks_drinkMenu_expanded.csv") # look at only the numeric columns nutrition.describe() # Thi...
true
2c8305b951b42695790cc95fef57b5f3751db447
GowthamSiddarth/PythonPractice
/CapitalizeSentence.py
305
4.1875
4
''' Write a program that accepts line as input and prints the lines after making all words in the sentence capitalized. ''' def capitalizeSentence(sentence): return ' '.join([word.capitalize() for word in sentence.split()]) sentence = input().strip() res = capitalizeSentence(sentence) print(res)
true
b78fea29f88fee4293581bbbfae5da0fa60065b9
GowthamSiddarth/PythonPractice
/RobotDist.py
1,030
4.4375
4
''' A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following: UP 5 DOWN 3 LEFT 3 RIGHT 2 The numbers after the direction are steps. Please write a program to compute the distance from cur...
true
c1a94cfefd636be989ea3c0df1a2f40ecefd6390
GowthamSiddarth/PythonPractice
/PasswordValidity.py
1,368
4.3125
4
''' A website requires the users to input username and password to register. Write a program to check the validity of password input by users. Following are the criteria for checking the password: 1. At least 1 letter between [a-z] 2. At least 1 number between [0-9] 1. At least 1 letter between [A-Z] 3. At least 1 char...
true
2b78532e935cc48136266b96a4a8d5070d14852b
GowthamSiddarth/PythonPractice
/EvenValuesFromTuple.py
268
4.1875
4
''' Write a program to generate and print another tuple whose values are even numbers ''' def getEvenNumsFromTuple(nums): return tuple(x for x in nums if x % 2 == 0) nums = list(map(int, input().strip().split(','))) res = getEvenNumsFromTuple(nums) print(res)
true
7e576a799df097e9afe67872e3313acab43be54b
wxl789/python
/day12/11-单继承.py
1,784
4.40625
4
#定义一个父类 class Cat(object): def __init__(self,name,color="白色"): self.name = name self.color = color def run(self): print("%s-----在跑"%self.name) #定义一个子类,继承Cat父类 """ 继承的格式: class 子类名(父类名) 子类在继承的时候,在定义类时,小括号中为父的名字 父类的属性和方法,会继承给子类(公有) """ class Bosi(Cat): def setNewName(sel...
false
5cc975cd608316355f65da33885eb43ebac6db92
wxl789/python
/Day16/2-代码/面向对象/10- __str__.py
631
4.3125
4
# __str__函数:__str__():当打印实例对象的时自动调用。 # 注:该方法必须有一个str类型的返回值 # __str__是给用户用来描述实例对象的方法 # 优点:当我们需要打印实例对象的多个属性时,可以使用__str__, # 这种方式会简化我们的代码量。 class Person(): def __init__(self, name, age, sex): self.name = name self.age = age self.sex = sex # 在类中重写__str__方法 def __str__(self): ...
false
cbf356727ec572000df535ab177a4bd2c056ff9f
wxl789/python
/Day07/2-代码/函数/7-不定长参数(元组).py
1,209
4.25
4
# 不定长参数 # 概念:能够在函数内部处理比形参个数多的实参 def sum1(a,b): print(a + b) def sum2(a,b,c): print(a + b + c) # 加了 (*) 的变量,可以存放多个实参。 # 加了 * 的形参,数据类型为元组类型,如果调用时未传入传入参数,默认 # 为一个空元组,如果传入了实参,将传入的实参按传入顺序依次放到元组中。 def fun1(*args): print(args) fun1() fun1(1) fun1(1,2,3) print("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&...
false