blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
3a6d4b45c0dc2a0e77274788d52aac17fc3c987e
deepakrkris/py-algorithms
/dcp/dcp-8.py
2,014
4.28125
4
# A unival tree (which stands for "universal value") is a tree where all nodes under it have the same value. # # Given the root to a binary tree, count the number of unival subtrees. # # For example, the following tree has 5 unival subtrees: # # 0 # / \ # 1 0 # / \ # 1 0 # / \ # 1 1 class Node: ...
true
b026172df9da07b51d08f93cb970c1053f1f7901
VSVR19/DAA_Python
/StacksQueuesDeques/QueueUsingTwoStacks.py
1,489
4.15625
4
# Inspiration- https://stackoverflow.com/questions/69192/how-to-implement-a-queue-using-two-stacks class Queue2Stacks(object): def __init__(self): # Two Stacks self.stack1 = [] self.stack2 = [] def enqueue(self, element): # Add elements to Stack 1 having element as the range. ...
true
5dfc5b0e7de1e49ecd4155d698ca05c5cd2692ef
VSVR19/DAA_Python
/LinkedLists/DoublyLinkedListImplementation.py
915
4.375
4
# This class implements a Singly Doubly List. class Node: # This constructor assigns values to nodes and # temporarily makes the nextnode and previousnode as 'None'. def __init__(self, value): self.value = value self.nextnode = None self.previousnode = None # Setting up nodes and t...
true
719e956d0b6b79da3f485580157c0cf8cc51c05b
remsanjiv/Machine_Learning
/Machine Learning A-Z New/Part 2 - Regression/Section 9 - Random Forest Regression/random_forest_regression.py
2,239
4.21875
4
# Random Forest Regression # Lecture 77 https://www.udemy.com/machinelearning/learn/lecture/5855120 # basic idea of random forest is you use multiple Decisions Trees make up # a forest. This is also called Ensemble. Each decision tree provides a prediction # of the dependent variables.The prediction is the average of...
true
5268874f85dcf7dbcc8dacda9de2813ad88f9e69
sadika22/py4e
/ch11/ch11ex01.py
759
4.15625
4
# Exercise 1: Write a simple program to simulate the operation of the grep com- # mand on Unix. Ask the user to enter a regular expression and count the number # of lines that matched the regular expression: # $ python grep.py # Enter a regular expression: ^Author # mbox.txt had 1798 lines that matched ^Author # $ pyth...
true
1c911d0c01de5812365e98378108071a47d7c44e
PruthviP7/Programming-Hands-on
/pp/Problems on numbers/11DisplayPower.py
557
4.1875
4
'''Accept number from user and calculate its power. Input : 2 4 Output : 2*2*2*2 = 16 Input : 4 3 Output : 4*4*4 = 64 iNo1 5 iNo2 4 5 * 5 * 5 * 5 1 * 5 = 5 5 * 5 = 25 ''' def CalculatePower(ino1,ino2): iMul = 1 for i in range(ino2): iMul = iMul * ino1 return iMul def main...
false
0d466471f22138a6b079a50f06bc76c3b4e400a5
srikarporeddy/project
/udemy/lcm.py
337
4.125
4
def lcm(x,y): """ this functions takes two integers and return L>C>M""" if x>y: greater = x else: greater = y while(True): if((greater %x==0) and (greater %y==0)): lcm = greater break greater += 1 return lcm num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) print...
true
709eb2afb2fe89532b6f95c35a4d3b416ff088f6
KartikShrikantHegde/Core-Algorithms-Implementation
/Selection_Sort.py
1,126
4.125
4
''' Selection_Sort Implementation Let the first element in the array be the least. Scan through rest of the array and if a value less than least is found, make it the new least And swap with old least Selection_Sort running time needs N-1 + N-2 + ..... Comparisons and N exchanges which is a quadratic time. Thus the ...
true
98f4d8b4a54003c0f0591c6b68cb8bd3c769f3c8
jtrieudang/Python-Udemy
/Day1.0.py
1,142
4.46875
4
# Write your code below this line 👇 print("hello world!") print('Day 1 - Python Print Function') print('The function is declared like this:') print("print('what to print')") # Return to the front print("Hello world!\nHello World!\n Hello Dude!") # concatenate, taking seperate strings print("Hello" + "Jimmy") ...
true
faa46dec270c2a7b3cf438fa338ad65027f8ee64
Aunik97/variables
/practice exercise 3.py
352
4.21875
4
#Aunik Hussain #15-09-2014 #Practice Exercise 3 print("this programme will divide two numbers and show the remainder") number1 = int(input("please enter the first number")) number2 = int(input("please enter the second number")) answer = number1 / number2 print("The answer of this calculation is {0} / {1} is ...
true
8a739a09405d195143c7b92c8a611abd6a6b073c
AnantPatkal/Python_Handson
/AA_BTA_course/Cinema_stimulator.py
1,465
4.125
4
Films = { "Malang":[15,5], #Here 1 element is age ,second is seats available "Bhoot":[16,4], "Street Dancer":[12,6], "Love Aaj Kal":[14,5] } print("Please select movie from the list of movies :") print(" 1-Malang \n 2-Bhoot \n 3-Street Dancer \n 4-Love Aaj Kal ") while True: choice...
false
d5d120d1d5cf585b27ced7859623ce562a1a85a8
StRobertCHSCS/fabroa-Andawu100
/Practice/2_8_1.py
233
4.25
4
#Find the value of number number = int(input("Enter a number: ")) #initialize the total total = 0 #compute the total from 1 to number for i in range(1,number+1): #print(i) total = total + i #total output print(total)
true
dbe390db8a59f54378cdeeec195e3fc81cef6c56
PatrickChow0803/Sorting
/src/recursive_sorting/recursive_sorting.py
1,700
4.21875
4
# TO-DO: complete the helpe function below to merge 2 sorted arrays def merge( arrA, arrB ): elements = len( arrA ) + len( arrB ) merged_arr = [0] * elements # [] are used to create array literals. This gives me multiple [0] to work with. # TO-DO i = 0 # Cursor for left array j = 0 # Cursor for rig...
true
12d26fbb29fbe19013f91cd792a36e1a9a27a299
ChengChenUIUC/Data-Structure-Design-and-Implementation
/GetRandom.py
1,526
4.15625
4
class RandomizedSet(object): def __init__(self): """ Initialize your data structure here. """ self.d = dict() self.arr = [] self.n = 0 def insert(self, val): """ Inserts a value to the set. Returns true if the set did not al...
true
39cfb4386edcd838bcba5f9ce3e7358350f91cc3
pooja-pichad/ifelse
/nested.leap year.py
381
4.34375
4
# leap year # we have take one user input and show the year its leap year or not year=int(input("enter a year")) x=("%d",year) if year%4==0: if year%100==0: if year%400==0: print("it is a leap year",year) else: print(" no its not a leap year ") else: print(...
false
e882bc324fd047b06271860aef4251990788c3eb
pooja-pichad/ifelse
/averge.py
465
4.21875
4
a=10 b=20 c=30 avg=(a+b+c)/3 print("avg=",avg) if avg>a and avg>b and avg>c: print("avg is higher than a,b,c") elif avg>a and avg>b: print("avg is higher than a,b") elif avg>a and avg>c: print("avg is higher than a,c") elif avg>b and avg>c: print("avg is higher than b,c") elif avg>a: print("avg is j...
false
40783e2766d62c324b30d7b79386a4540a46b585
zexhan17/Problem-Solving
/python/a1.py
984
4.4375
4
""" There are two main tasks to complete. (a) Write a function with the exact name get_area which takes the radius of a circle as input and calculates the area. (You might want to import the value of pi from the math module for this calculation.) (b) Write another function named output_parameter . This should, again, t...
true
80961df9b6d1e81cfcc1166c724e2b0f13b464e6
klaudiakryskiewicz/Python-50-recruitment-tasks
/04.py
421
4.40625
4
"""Jakiej struktury danych użyłbyś do zamodelowania szafki, która ma 3 szuflady, a w każdej z nich znajdują się 3 przegródki? Stwórz taki model i umieść stringa "długopis" w środkowej przegródce środkowej szuflady""" szafka = [[[], [], []], [[], [], []], [[], [], []]] szafka[1][1].append("długopis") print(szafka) fo...
false
a803d1f3ebe89e03956323e1362a122f607c47e4
klaudiakryskiewicz/Python-50-recruitment-tasks
/33.py
341
4.28125
4
"""Do czego w Pythonie służy słowo kluczowe yield ? Napisz przykładowy kod wykorzystujący yield.""" def generator(n): for i in range(n): yield i for item in generator(5): print(item) gen = generator(5) print(gen) # <generator object generator_function at xxxxxxx> print(next(gen)) # 0 print(gen.__...
false
efcb902a302311e86683639e8dee8803eb8141d4
poliarus/Stepik_Python_course
/lesson1.py
229
4.125
4
A = int(input("A: ")) # minimum B = int(input("B: ")) # maximum H = int(input("H: ")) # current if A <= H <= B: print("Это нормально") elif A > H: print("Недосып") else: print("Пересып")
false
556ad2319af38b153209f918a202c793a646ed55
XBOOS/leetcode-solutions
/binary_tree_preorder_traversal.py
2,500
4.375
4
#!/usr/bin/env python # encoding: utf-8 """ Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive solution is trivial, could you do it iteratively?""" """ Method 1 using recursion. adding anothe...
true
f58f1448011d7be58f03493652af3da8451f8152
XBOOS/leetcode-solutions
/odd_even_linked_list.py
1,581
4.25
4
#!/usr/bin/env python # encoding: utf-8 # Method 1 # Must loop the walk with stepsize of 2 # could also make dummy starting node then start with head not head.next.next # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class S...
true
1bdf52e8770eb8dc1061e74a9c53672ddf0c2a48
XBOOS/leetcode-solutions
/first_bad_version.py
1,315
4.1875
4
#!/usr/bin/env python # encoding: utf-8 """ You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Supp...
true
3d0375292722763c19960095b2c270e3fe20620d
christianhv/python_exercises
/ex18.py
595
4.34375
4
#!/usr/bin/env python # This one is like the scripts with argv def print_two(*args): arg1, arg2 = args print "arg1 = %r, arg2 = %r" % (arg1, arg2) #Ok, that *args is actually pointless, we can do just this def print_two_again(arg1, arg2): print "arg1 = %r, arg2 = %r" % (arg1, arg2) #This just print on...
true
c448adeef80d1c158d1ed8ead495a9974b173e31
erik-vojtas/Algorithms-and-Data-Structure-I
/MergeSortAlgorithm.py
1,923
4.21875
4
# Merge Sort Algorithm # https://www.programiz.com/dsa/merge-sort # split an array into two halves and then again until we get lists which consist one item, merge and sort then two lists together, then again until we get full list which is ordered # https://www.studytonight.com/data-structures/merge-sort # Worst Case ...
true
f7c20d23f3329603dab4eb4c78067494fa33ec9e
chutianwen/LeetCodes
/LeetCodes/uber/640. Solve the Equation.py
1,868
4.28125
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
d5998dc7bfc0427f1e471b26732ed1a30d3da004
chutianwen/LeetCodes
/LeetCodes/Array/MergeSortedArray.py
1,192
4.1875
4
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. The number of elements initialized in nums1 and nums2 are m and n respectively. """ clas...
true
8fbbb5cc859758fb997b4f6bc0bc31190165ca15
chutianwen/LeetCodes
/LeetCodes/Consistency.py
706
4.3125
4
''' when set includes alphabet letter, then order won't be same every time running program, however, when set has all number the order seems to be same every time. Also difference between python2 and python3. Python2 will print same order all the time, python3 won't for letter cases. ''' a = set(range(5)) print("print ...
true
ea63e5c210cf599b45695ffc1d6b58459a844585
chutianwen/LeetCodes
/LeetCodes/summary/IteratorChange.py
260
4.1875
4
# list iterator can change a = [1,2,3,4] for x in a: print(a.pop()) print("*"*100) # we can append to the iterator like this. -x, "," is important for x in a: print(x) if x > 0: a += -x, # set iterator cannot change b = {1,2,3,4} for x in b: b.pop()
true
692b8995a37443f50512dfbcc5d7d799c8ff93e5
chutianwen/LeetCodes
/LeetCodes/stackexe/NestedListWeightSumII.py
2,916
4.28125
4
''' Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists. Different from the previous question where weight is increasing from root to leaf, now the weight is defined from...
true
6418042ad3eed02e18886ff8352cd892380e95cc
VladaOliynik/python_labs_km14_Oliynik
/p4_oliynik/p4_oliynik_1.py
597
4.25
4
#below we make variables for input name = input('Enter your name: ') surname = input('Enter your surname') number = input('Enter your phone number: ') street = input('Enter your street name:') building = input('Enter your building number') apartment = input('Enter your apartment number') city = input('Enter your city n...
true
6c003faa8da4af035c548cffcb76b8d67d6eb3a5
muon012/python3HardWay
/ex44.py
2,305
4.5625
5
# INHERITANCE vs COMPOSITION # =========================================== INHERITANCE =========================================== # Implicit Inheritance # The child class inherits and uses methods from the Parent class even though they're not defined in the Child class. class Parent(object): def implicit(self): p...
true
4384f3e5d9625e1f7205d66818781669fe7652d8
pyexer/pyBalaji
/asg6(08-09-19).py
311
4.21875
4
#python code to find distance between two points. import math x1=int(input("enter X1:")) y1=int(input("enter Y1:")) x2=int(input("enter X2:")) y2=int(input("enter Y2:")) distance=math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); print("distance ({0},{1}) and ({2},{3}) is {4}".format(x1,x2,y1,y2,distance))
false
4075b724406894a983abcc3c5c3618e06ea8912f
Ellina3008/PisarenkoER
/2 урок/8.py
352
4.125
4
# -*- coding: utf-8 -*- # 8 Задание a = int(input("Введите первое число: ")) b = int(input("Введите второе число: ")) c = int(input("Введите третье число: ")) if (a == b == c): print("3") elif (a == b or b == c or a == c): print("2") else: print("0") print("\n")
false
b04b7bba927f04b8932cb62895dece46929d7479
pablomdd/EPI
/Primitive/4_7_compute_power.py
602
4.46875
4
def power(x: float, y: int) -> float: result = 1.0 power = y # tweek for the algorithm work with negative power if y < 0: power, x = -power, 1.0 / x # if power < 0 evaluates False # that happens when bits shift down to 0 or less while power: # evaluates if power is odd ...
true
73c2e0ea222185ecb9e6a506373c09de646288c0
schatfield/classes-pizza-joint
/UrbanPlanner/building.py
1,479
4.34375
4
# In this exercise, you are going to define your own Building type and create several instances of it to design your own virtual city. Create a class named Building in the building.py file and define the following fields, properties, and methods. # Properties # designer - It will hold your name. # date_constructed - T...
true
2bd3c4fb23c738e2a77db06e92807ac3546758bd
HansMPrieto/CIS-211-Coursework
/Mini Projects/waldo-mini-master/dup.py
2,447
4.25
4
from typing import List def every_column_dups(m: List[List[int]]) -> bool: """Returns True iff every column has at least one duplicate element. Examples: every_column_dups([[0, 1, 2], [0, 2, 3], [4, 2, 3]]) == True every_column_dups([[0, 1, 2], ...
false
e7526399cda0a984b8fe03a425beab42c4782344
sourav2406/nutonAkash
/DataStructure/Stack/queueUsingStack.py
905
4.15625
4
#Implementing queue using stack from stack import Stack class Queue: def __init__(self): self.queueStack = Stack() def push(self,data): self.queueStack.push(data) def popInner(self): if self.queueStack.is_last(): return self.queueStack.pop() temp = self.queueS...
false
376ecda95125c6d26e8983d9971aaabea717ef9e
sourav2406/nutonAkash
/DataStructure/BinaryTree/reverseLevelOrder.py
1,037
4.4375
4
# A recursive python process to print reverse level order #Basic node for binary tree class Node: def __init__(self,data): self.data = data self.left = None self.right = None #compute the height of a binary tree def _height(node): if node is None: return 0 else: lhe...
true
959618ab34fb6f1f42843fb2c79c0af724c6746b
ramachandrajr/lpthw
/exercises/ex33.py
446
4.25
4
numbers = [] def loop_through(x, inc): for i in range(x): print "At the top i is %d" % i numbers.append(i) # We do not need this iterator anymore and # even if we use it the i value will be over # written by for loop. # i = i + inc print "Numbers now: ", num...
true
a388c5679b909776fbda190c98f6f57c49ff0193
1258488317/master
/python/example/continue.py
445
4.21875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # while True: # s =input('enter something:') # if s == 'quit': # break # if len(s) < 3: # print('too samall') # else: # print('input is of suffivient length') # print('done') while True: s = input('Enter something : ') if s == 'qu...
true
bbdc8374a9f16c165ef6252f6715b74457c92616
charlescheung3/Intro-HW
/Charles Cheung PS16a.py
263
4.25
4
#Name: Charles Cheung #Email: charles.cheung24@myhunter.cuny.edu #Date: February 11, 2020 #This program prompts the user for the number of kilograms and then print out the number of pounds. weight = input("Enter weight in kilos:") weight = float(weight) kg = weight*2.20462262185 print(kg,"lb")
true
db1af7f0d6e99aadd85081703ab55905fb3dd400
charlescheung3/Intro-HW
/Charles Cheung PS37.py
687
4.5
4
#Name: Charles Cheung #Email: charles.cheung24@myhunter.cuny.edu #Date: March 10, 2020 #This program asks the user for a string, then counts and prints the number of characters that are uppercase letters, lowercase letters, numbers and special characters. codeWord = input("Please enter a codeword:") number = 0 upper =...
true
a6eee61b1e72ae980b41dbf283c5b2c67cbb0eb2
charlescheung3/Intro-HW
/Charles Cheung PS18.py
435
4.21875
4
#Name: Charles Cheung #Email: charles.cheung24@myhunter.cuny.edu #Date: February 18, 2020 #This program will tell you how many coins your cents input will return centsinput = int(input("Enter number of cents as an integer")) quarters = centsinput // 25 print("Quarters:", quarters) rem = centsinput % 25 dimes = rem /...
true
7119908972cd42c33ca71cfb798b1d4716e13ca6
MandeepKaur92/c0800291_EmergingTechnology_assignment1
/main.py
1,646
4.65625
5
import datetime def reverse(fname, lname): print(f"First Name:{fname}\nLast Name:{lname}") print("---------------reverse------------------ ") #print name in reverse print(f"{lname}" + " " + f"{fname}") def circle_radius(radius): #calculate area of radius area=(22/7)*radius**2 print("-------...
true
9c6f3fdfdb384d75d1fd482f3009148fe0ebb06d
tthompson082/Sorting
/src/iterative_sorting/iterative_sorting.py
2,070
4.34375
4
# TO-DO: Complete the selection_sort() function below def selection_sort(arr): # loop through n-1 elements for i in range(0, len(arr) - 1): cur_index = i smallest_index = cur_index # TO-DO: find next smallest element # (hint, can do in 3 loc) # create a loop that starts a...
true
c50320c505da5dc6e6b4374e755234e068c77057
IagoAntunes/Python__learning
/Curso em Video[120Horas]/1º Mundo/Exercicio 004.py
342
4.28125
4
# Faça um programa que leia algo pela tela do seu computador e mostre na tela # o seu tipo primitivo e todas as informações possiveis sobre ela n1 = input("Digite um Numero: ") print(f"É uma Letra: {n1.isalpha()}") print(f"É um Numero: {n1.isnumeric()}") print(f"É um Decimal: {n1.isdecimal()}") print(f"É Minusculo: {...
false
0b6bfcf5b82f1c9d0e2098d692cc1c1c2c6a891a
IagoAntunes/Python__learning
/Curso em Video[120Horas]/1º Mundo/Exercicio 028.py
467
4.28125
4
# Escreva um programa que faça o computador “pensar” em um número inteiro entre 0 e 5 # e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador. # O programa deverá escrever na tela se o usuário venceu ou perdeu. from random import randint usuario = int(input("Adivinhe o Numero.(1 a 5)")) ...
false
45c822cf2d953081c2f3ee3435d23bad98a32a99
IagoAntunes/Python__learning
/Curso em Video[120Horas]/2º Mundo/Exercicio 064.py
419
4.125
4
#Crie um programa que leia vários números inteiros pelo teclado. # O programa só vai parar quando o usuário digitar o valor 999, # que é a condição de parada. No final, mostre quantos números foram digitados # e qual foi a soma entre eles soma = 0 qnt=0 num = 0 while(num != 999): num = int(input("Digite um Numero:...
false
b4c7b046b68acb11781f471bd72297bf8de53f80
aduo122/Data-Structures-and-Algorithms-Coursera-UCSD
/Graph/week5/connecting_points.py
1,072
4.125
4
#Uses python3 import sys import math import heapq def minimum_distance(x, y): result = 0. #write your code here #setup parameters queue = [[0,x[0],y[0],0]] heapq.heapify(queue) visited = [0 for _ in range(len(x))] v_length = 0 while v_length < len(visited): # select start heap...
true
b4bc51deb6a766cfc134ba59de57efa3a3729960
rampreetha2/python3
/natural.py
228
4.125
4
num = int(input("Enter the value of n:")) hold = num sum = 0 if sum<=0; print("Enter a whole positive number!") else: while num>0: sum sum + num num =num -1; print("Sum of first",hold, "natural numbers is":,sum)
true
f57c76a359ca492ab92052fb995011673bdd8b86
Jodabjuan/intro-python
/while_loop.py
511
4.28125
4
"""" Learn Conditional Repetition Two types of loops: for-loops and while-loops """ counter = 5 while counter !=0: print(counter) # Augmented Opperation counter -=1 counter = 5 while counter: print(counter) # Augmented Opperation counter -=1 # Run forever while True: print("Enter a numbe...
true
122b570d2b95df96d5c9c36db57cdc3cc4d7fc09
Jodabjuan/intro-python
/me_strings.py
1,357
4.40625
4
""" Learn more about strings """ def main(): """ Test function :return: """ s1 = "This is super cool" print("Size of s1: ", len(s1)) # concatenation "+" s2 = "Weber " + "State " + "University" print(s2) # join method to connect large strings instead of "+" teams = ["Real M...
true
0296546419117c17ca88673faf6861ca24a3a51c
toxine4610/codingpractice
/dcp65.py
1,810
4.34375
4
''' Given a N by M matrix of numbers, print out the matrix in a clockwise spiral. For example, given the following matrix: [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]] ''' def nextDirection(direction): if direction == "right": return "down" elif direction == "down": ...
true
f77236d54686a8ea79e1989c06329169cd453880
toxine4610/codingpractice
/dcp102.py
808
4.25
4
''' This problem was asked by Lyft. Given a list of integers and a number K, return which contiguous elements of the list sum to K. For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it should return [2, 3, 4]. ''' def get_contiguous_sum(A, k): sum_so_far = dict() # this stores the sums and the indices ...
true
8a7f93265ac05e8ddcb6c1d89bd830b1c450fa26
SergeiLSL/PYTHON-cribe
/Глава 2. Основы Python/Раздел 3. Условные выражения/Логические операции.py
2,541
4.21875
4
""" Логические операции """ """ Для создания составных условных выражений применяются логические операции. В Python имеются следующие логические операторы: """ # and (логическое умножение) """ Возвращает True, если оба выражения равны True """ age = 22 weight = 58 result = age > 21 and weight == 58 print(result) # ...
false
5f762a882d5976692ad36f4f3c4d8a070f168737
SergeiLSL/PYTHON-cribe
/Глава 2. Основы Python/Раздел 2. Операции с числами/Арифметические операции с присвоением.py
1,023
4.5625
5
""" Арифметические операции с присвоением """ """ Ряд специальных операций позволяют использовать присвоить результат операции первому операнду: += Присвоение результата сложения -= Присвоение результата вычитания *= Присвоение результата умножения /= Присвоение результата от деления //= Присвоение результат...
false
c9e304d2991fcaf640d5c2030d5e5538bda13afb
rizkarama/Ujian-Modul-1
/Hashtag.py
1,199
4.1875
4
# 1 # def Hashtag(string): #bikin fungsinya #menggunakan conditional expression untuk memisahkan jenis pertanyaan. # if len(string)>25: # menghitung panjang string, lalu membuat batasan yaitu len(string) lebih besar dari 25 # print(string.title()) # apabila panjang string lebih besar dari 25 maka string ...
false
259bf7ad003dc1216b8b5ee22231b910bdda8be1
Toras/gb_python_developer
/lesson03/task03.py
1,142
4.1875
4
""" 3. Создать два списка с различным количеством элементов. В первом должны быть записаны ключи, во втором — значения. Необходимо написать функцию, создающую из данных ключей и значений словарь. Если ключу не хватает значения, в словаре для него должно сохраняться значение None. Значения, которым не хватило ключей, не...
false
b69667d2cac84aa9a1dab4847b619425a02d2218
CanekSystemsHub/Python_Data_Structures
/3 Recursion/countdown_start.py
296
4.28125
4
# use recursion to implement a countdown counter global x x = int(input("Type the number you want to countdwon ")) def countdown(x): if x == 0: print("You're done!") return else: print(x, " ... the countdown stills running") countdown(x-1) countdown(x)
true
0674fd2e8bd686abf9b8e0be9b54388d720dcdba
ddp-danilo/ddp-pythonlearning1
/sm7ex1.py
251
4.1875
4
#desenho que usa '#' para fazer quadrados largura = int(input("digite a Largura: ")) altura = int(input("digite a altura: ")) while altura > 0: ll = largura while ll > 0: print("#", end='') ll -= 1 print() altura -= 1
false
b1d1901eb536968313a6e3d2e018261728b0a93e
MariaLegenda/various-tasks-education-
/1_1 - merge_sort.py
1,266
4.25
4
# 2. Отсортируйте по возрастанию методом слияния одномерный вещественный массив, # заданный случайными числами на промежутке [0; 50). # Выведите на экран исходный и отсортированный массивы. import random def merge_sort(array): if len(array) <= 1: return array middle = int(len(array)/2) left ...
false
0f4c8ffda99aeaeb8dc8f5dd901a24b8fd0161fb
atomicbombvendor/learnPythonTheHardWay
/SomeTests/ts_del/t40.py
1,143
4.25
4
things = ['a', 'b', 'c', 'd'] print things[1] things[1] = 'z' print things[1] print things stuff = {'name':'zed', 'age':36, 'height':6*12+2} print stuff['name'] print stuff['name'] print stuff['age'] print stuff['height'] stuff[1] = 'Wow' print stuff[1] stuff[2] = 'Neato' print stuff[2] stuff["t"] = 'T' print ...
false
db10b6b1bffd0450adc01ae4a8a7b1925a39f37d
htbit/Python-project
/5 день/project-2.py
361
4.21875
4
def vowel_count(str): count = 0 vowel = set("aeiouAEIOUёуеыаоэяиюЁУЕЫАОЭЯИЮ") for alphabet in str: if alphabet in vowel: count = count + 1 print("Всего было использовано гласных:", count) str = input('Введите слово или предложение: ') vowel_count(str)
false
e411395d691e88bd43c137eef6556c2d90d8fe07
PoornishaT/positive_num_in_range
/positive_num.py
344
4.25
4
input_list = input("Enter the elements of the list separated by space : ") mylist = input_list.split() print("The entered list is : \n", "List :", mylist) # convert into int for i in range(len(mylist)): mylist[i] = int(mylist[i]) print("The positive terms in list is :\n") for x in mylist: if x > 0: ...
true
567ecb1015e77b44c6e5840b1363887c00e94019
SushantBabu97/HackerRank_30Days_Python_Challenge-
/Day28.py
907
4.59375
5
# RegEx, Patterns, and Intro to Databases """ Task Consider a database table, Emails, which has the attributes First Name and Email ID. Given n rows of data simulating the Emails table, print an alphabetically-ordered list of people whose email address ends in @gmail.com. Sample Input::: 6 riya riya@gm...
true
92367542b27c2e121bd491fe2d9e3469caf3016d
lokitha0427/pythonproject
/day 7- Patterns/strong number.py
293
4.21875
4
n=int(input("enter the number")) sum=0 t=n while t>0: fact=1 digit=t%10 for i in range(1,digit+1): fact=fact*i sum=sum+fact t//=10 if(sum==n): print("the given number is a strong number") else: print("the given number is not a strong number")
true
de14dd2a4fbf0b572a89f648f02ba459b5ea42ce
lokitha0427/pythonproject
/day 3-conditional/monkey trouble.py
359
4.125
4
#monkey trouble a_smile=False b_smile=False if ((a_smile and b_smile) or (not a_smile and not b_smile)): print("true") else: print("false") ''' a_smile=bool(input("enter the a monkey")) b_smile=bool(input("enter the b monkey")) if True: print(((a_smile and b_smile) or (not a_smile and not b_sm...
false
0721265e0f7f1dfb6345120b4a79b72b978f1ec3
khanshoab/pythonProject1
/Function.py
1,776
4.375
4
# Function are subprograms which ar used to compute a value or perform a task. # Type of function # 1. built in function e.g print() , upper(), lower(). # 2. user-defined function # ** Advantage of Function ** # write once and use it as many time as you need. This provides code re-usability. # Function facilities cas...
true
93035b2efc77dab6e1d7cbb2aa8a398446f3ff36
khanshoab/pythonProject1
/mul+di+arr.py
262
4.15625
4
# Multi-dimensional Array means 2d ,3d ,4d etc. # It is also known as array of arrays. # create 2d array using array () function. from numpy import * a = array([[23,33,32,43], [54,23,35,23]]) print(a,dtype) print(a[1][3]) a[0][1] = 100 print(a[0][1])
true
e8613d9746bb6c1a99ea312d84132ffe00409f98
khanshoab/pythonProject1
/repetition+operator.py
224
4.125
4
# Repetition operator is used to repeat the string for several times. # It is denoted by * print("$" * 10) str1 = "MyMother " print(str1 * 10) # slicing string str2 = "my dream " print(str2[0:2] * 5) # To printing the 'my
true
e6f6c9b17fc7c8e400d26b16940c127b31504852
Maxud-R/FizzBuzz
/FizzBuzz.py
1,557
4.1875
4
#Algorithm that replaces every third word in the letter to Fizz, and every fifth letter in the word to Buzz. #Length of the input string: 7 ≤ |s| ≤ 100 class FizzBuzz: def replace(self, rawstr): if len(rawstr) < 7 or len(rawstr) > 100 or not (rawstr in rawstr.lower()) or rawstr.isdigit(): raise ...
true
644a34827d6c7fc97d7c5afb3c3a95bba6263c29
brandon98/variables
/string exercise 2.py
297
4.21875
4
#Brandon Dickson #String exercise 2 #8-10-2014 quote=input("Please enter quote:") replacement= input( "What word would you like to replace?") replacement2=input( "What word would you like to replace it with?") answer= quote.capitalize() output= quote.replace(replacement, replacement2) print(output)
true
1f2b406a39f0a5094c5206899dd2795f12d043ad
Hu-Wenchao/leetcode
/prob218_the_skyline_problem.py
2,271
4.3125
4
""" A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on a cityscape photo (Figure A), write a program to output the skyline formed by these buildings collect...
true
f1fa96f1a965889d29151b30eb26d039a7840bf7
MrShashankBisht/Python-basics-
/Class 11th complete/7) Continue_Breake_Statement/break.py
406
4.3125
4
# this is a programe to break your loop and make your programe to jump unconditionaly from loop # in this programe we take inpute from user and quit loop(uncondionaly break the middle term ) num = int(input('Enter the Ending limit of the loop ')) for i in range (num): print("you are in loop and this is looping num...
true
194f0af0d91d825b2e4542432d69ee6e54791d99
MrShashankBisht/Python-basics-
/Class 11th complete/7) Continue_Breake_Statement/Continue.py
377
4.125
4
# this is a programe to continue to loop and make your programe to jump unconditionaly from loop for i in range(0,3): a = int(input("enter first number")) b = int(input("enter second number ")) if(b == 0): #here we use conditional operater == print("b can't be zero ...
true
1ecac5332ee8f10bc949e07ef955d3d6e7880124
jf4rr3ll/IS211_Assignment6
/conversion.py
2,876
4.3125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """This module provides various temperature conversions""" ABSOLUTE_DIFFERENCE = 273.15 def fahrenheit_to_celsius(degrees): """Defines a function that converts Fahrenheit to Celsius. Args: degrees (float): Degrees in Fahrenheit. Returns: deci...
false
854e176dbc979a4b3b77d0f6b479fddcf3ec144c
renatodev95/Python
/aprendizado/curso_em_video/desafios/desafio100.py
804
4.125
4
# Faça um programa que tenha uma lista chamada números e duas funções chamadas # sorteia() e somaPar(). A primeira função vai sortear 5 números e vai colocá- # los dentro da lista e a segunda função vai mostrar a soma entre todos os # valores PARES sorteados pela função anterior. from random import randint from ti...
false
f0def89d7131bde3120c64444498b86686601291
renatodev95/Python
/aprendizado/codewars/find_the_unique_number.py
582
4.25
4
# There is an array with some numbers. All numbers are equal except for one. Try to find it! def find_uniq(arr): arr.sort() if arr[0] == arr[1]: return arr[-1] else: return arr[0] lista = [ 1, 1, 1, 2, 1, 1 ] # exemplo print(find_uniq(lista)) # Primeiramente é feita a organização d...
false
6e9bfef9a57a241c80fe0b28905a4bbbb44a92ee
Kylekibet/days_to_birthday
/no_of_days_to_birthday.py
1,674
4.59375
5
#!/usr/bin/python3 import datetime # Get todays date dttoday = datetime.date.today() print("today is {}".format(dttoday)) while True: # Get users birtday date. bday = input("\nPlease enter you birthday(year-month-day) : ") # Check weather user entered date in the formart provided(year-month-day) try: ...
true
a04d9c7f8d8d7b7685e33f5125b77eac1ed0a763
damianquijano/PythonCurso3
/Scripts2/Clases/clase.py
1,472
4.15625
4
class Animal:#Mayúscula Mision= "Vivir" def caminar(self):# self toma el valor del nombre de la variable instanciada u objeto. print("Caminando") def soy(self,clase): print("Soy animal del tipo: "+ clase) def MiMision(self,vmision): print("Mi misión es: "+ self.Mision+ " y...
false
c123970f36c7f6c7b9c19a1bf21104ff1f196f27
gokadroid/pythonExample-2
/pythonExample2.py
571
4.34375
4
#Simple program to reverse a string character by character to show usage of for loop and range function def reverseString(sentence): reversed=[] #create empty list for i in range(len(sentence),0,-1): #starting from end, push each character of sentence into list as a character reversed.append(sentence[i-...
true
b259a0b53eabfcf8f3f31e4e7742bc1c7312c173
abbhowmik/PYTHON-Course
/Chapter 6.py/pr no.5.py
267
4.15625
4
a = input("Enter a name : \n: ") list = ["mohan", "rahul", "Ashis", "Arjun", "Sourav", "Amit"] if(a in list ): print("The name you choice from the list is present in the list ") else: print("The name you choice from the list is not present in the list")
true
6eae4ee9fb61284dfa148637bf2f8c971cae3379
abbhowmik/PYTHON-Course
/practice 4.py
1,022
4.53125
5
# name = input("Enter your name\n") # print("Good Afternoon," + name) # a = input("Enter your name\n") # print("Good Afternoon," + a ) letter = '''Dear <|Name|>, you are selected!,welcome to our coding family and we are noticed that you are scoring well in exam as before like. That's why your selected in our partne...
true
fd5a9faf7610477b3ba53f57764a5deed927fe47
mkhlvlkv/random
/like.py
952
4.15625
4
# -*- coding: utf-8 -*- def like(text, pattern, x='*'): """ simple pattern matching with * """ if pattern.startswith(x) and pattern.endswith(x): return pattern.strip(x) in text elif pattern.startswith(x): return text.endswith(pattern.strip(x)) elif pattern.endswith(x): return te...
true
c707df33626c32086a61f0ae1086b667bf500bce
ManiNTR/python
/Adding item in tuple.py
290
4.3125
4
values=input("Enter the values separated by comma:") tuple1=tuple(values.split(",")) print("The elements in the tuple are:",tuple1) key=input("Enter the item to be added to tuple:") list1=key.split(",") list2=list(tuple1) list2.extend(list1) print("The tuple elements are: ",tuple(list2))
true
2e471dab649540a085eee4b0730b18cca2902002
ManiNTR/python
/RepeatedItemTuple.py
307
4.46875
4
#Python program to find the repeated items of a tuple values=input("Enter the values separated by comma:") list1=values.split(",") tuple1=tuple(list1) l=[] for i in tuple1: if tuple1.count(i)>1: l.append(i) print("The repeated item in tuple are: ") print(set(l))
true
7a8c0d75d17d2fa9464fc8a21375947234310df9
SARANGRAVIKUMAR/python-projects
/dice.py
275
4.21875
4
import random # select a random number min = 1 max = 6 roll="yes" while(roll == "yes"or roll=="y"): print ("dice is rolling\n") print("the values is") print (random.randint(min,max)) #selecting a random no from max and min roll = input("Roll the dices again?")
true
30a86473eb301d9f0bd2a5f8f7a382a451c85b7b
NEDianfaiza/python-assignment
/Assignment no 4.py
1,569
4.1875
4
#Question1: '''dic={ 'first_name':input("Enter First Name"), 'last_name':input("Enter Last Name"), 'age':int(input("Enter Age")), 'city':input("Enter City") } print(dic) dic["qualification"]="High Academic Level" print(dic) del dic["qualification"] print(dic)''' #Question2: '''cities=...
false
34419cbbbbcd1e10d1c6205f2f9ec62a234dfb7e
SeanUnland/Python
/Python Day 5/main.py
1,869
4.28125
4
# for loops fruits = ["Apple", "Pear", "Peach"] for fruit in fruits: print(fruit) print(fruit + " Pie") # CODING EXERCISE # 🚨 Don't change the code below 👇 student_heights = input("Input a list of student heights ").split() for n in range(0, len(student_heights)): student_heights[n] ...
true
92d2d9fcf49f71a8e65805fba8bab48eb5eda9a7
codingscode/curso_python
/Work001/file032_funcoes_c_retorno.py
2,400
4.28125
4
""" Funções com retorno """ numeros = [20, 8, 34, 15, 43] retorno_de_pop = numeros.pop() print(f'retorno de pop: {retorno_de_pop}') impressao_print = print('oi') print(f'retorno de impressao_print: {impressao_print}') print('-------------------------') def quadrado_7(): print(7**2) # a...
false
efb6c8645ad458976400a2c8f16dcb21da9b7768
codingscode/curso_python
/Work001/file095_MRO.py
1,794
4.125
4
""" POO : MRO - Method resolution order Resolução de ordem de métodos -> é a ordem de execução dos métodos (quem será executado primeiro) Em Python, nós podemos conferir a ordem de execução dos métodos (MRO) de 3 formas: - Via propriedade da classe __mro__ - Via metodo mro() - Via help """ class Animal...
false
27d1b401280b87feb6208faeb48d5026e8b399e5
codingscode/curso_python
/Work001/file040_listas_aninhadas.py
1,167
4.46875
4
""" algumas linguagens de programação possuem uma estrutura de dados chamadas de arrays: - unidimensionais (arrays/vetores), - multidimensionais(matrizes ou listas aninhadas) """ listas = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] print(listas) print(type(listas)) print(listas[1]) print(listas[2][1]) print(listas...
false
af62551ed65edef450040bfc1f0a5b1c96a8d804
codingscode/curso_python
/Work001/file039_list_comprehension2.py
1,960
4.25
4
""" List Comprehension Usando a podemos gerar novas listas com dados processados a partir de outro iterável. # Sintaxe da List Comprehension [dado for dado in iteravel] """ numeros = [3, 7, 2, 50] res = [cada*10 for cada in numeros] print(res) def divisivelp2(valor): return valor % 2 == 0 ...
false
e9d862d3ede36849b703a4c24bac276c5f493c5e
codingscode/curso_python
/ifsp/012 - rasc.py
1,278
4.40625
4
# Orientação a Objetos """ """ class Usuario: contador = 0 def __init__(self, nome, email): # construtor self.nome = nome self.email = email Usuario.contador += 1 def diga_ola(self): print(f'Olá, meu nome é {self.nome} e meu email é {self.email}'...
false
e770de7e9bac485af103a2d747628f06e9dff368
codingscode/curso_python
/Work001/file044_map.py
1,393
4.59375
5
""" Map Map ≠ mapas - mapeamento função valor - Com map, fazemos mapeamento de valores função. """ import math def area(raio): return math.pi * raio**2 print(area(2)) print(area(1)) print('---------------------') raios = [0.5, 3, 4.2, 8] # Forma comum areas = [] for r in raios: a...
false
7d95f0f76e21a20a13047bd2686f6f64c51aeb02
codingscode/curso_python
/Work001/file048_generators.py
2,133
4.21875
4
""" Generators (Generator Expression) = tuple comprehensions """ nomes = ['Cecília', 'Caroline', 'Cassia', 'Carl', 'Roberto'] print(any(nome[0] == 'C' for nome in nomes)) # pelo menos 1 print(any([nome[0] == 'C' for nome in nomes])) # aqui não é generator print(any((nome[0] == 'C' for nome in nomes))) ...
false
096fb3fe3a21ca1ec5ef8e54ee299b813905ad41
codingscode/curso_python
/Work001/file122_tipos_em_comentarios.py
1,176
4.125
4
""" Tipos em comentarios """ import math """ def circunferencia(raio): # type: (float) -> float return 2 * math.pi * raio print(circunferencia(5)) # nao dá erro #print(circunferencia('geek')) """ #""" def circunferencia(raio): # def circunferencia(raio: float) -> float: # type...
false
63ac44be4b0e3bb805c7ea95cd7a9f782902ab13
python240419/05.07.2019
/dictionary.py
563
4.15625
4
# Dictionary # Hashmap -- key : value # key may appear only once - single appearence #12 -- moshe #14 -- moshe #12 -- danny # 2 keys have the same value # # # 3,4,5 moshe, danny, tamar # # key - may be anything # [1,2,3] #adress 4005 # [1,2,3] # create dictionary for cities population # TLV, LONDON, PA...
false
90ab88a33387a70de53d0eea736072ed7faad3ff
olszebar/tietopythontraining-basic
/students/marta_herezo/lesson_02/for_loop/adding_factorials.py
257
4.15625
4
# Given an integer n, print the sum 1!+2!+3!+...+n! print('Enter the number of factorials to add up: ') n = int(input()) factorial = 1 sum = 0 for i in range(1, n + 1): factorial = factorial * i sum += factorial print('Result = ' + str(int(sum)))
true