blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
8bf756db6183232e427214af5df6d0d67b19b98c
meraj-kashi/Acit4420
/lab-1/task-1.py
286
4.125
4
# This script ask user to enter a name and number of cookies # script will print the name with cookies name=input("Please enter your name: ") number=int(input("Please enetr number of your cookies: ")) print(f'Hi {name}! welcome to my script. Here are your cookies:', number*'cookies ')
true
9b80a85e7d931de6d78aeddeeccc2c154897a88b
vikrampruthvi5/pycharm-projects
/code_practice/04_json_experimenter_requestsLib.py
1,217
4.125
4
""" Target of this program is to experiment with urllib.request library and understand GET and POST methods Tasks: 1. Create json server locally 2. retrieve json file using url 3. process json data and perform some actions 4. Try POST method """ """ 1. Create json server locally a. From...
true
5cb010b426cfff62548f9612eabbaad320954a78
vikrampruthvi5/pycharm-projects
/04_DS_ADS/02_dictionaries.py
1,038
4.4375
4
""" Dictionaries : Just like the name says, KEY VALUE pairs exists """ friends = { 'samyuktha' : 'My wife', 'Badulla' : 'I hate him', 'Sampath' : 'Geek I like' } for k, v in friends.items(): # This can be used to iterate through the dictionary and print keys, values print(k ,v) """ Trying...
false
aa322e4df062956a185267130057767ad450dc6e
JRose31/Binary-Lib
/binary.py
937
4.34375
4
''' converting a number into binary: -Divide intial number by 2 -If no remainder results from previous operation, binary = 0, else if remainder exists, round quotient down and binary = 1 -Repeat operation on remaining rounded-down quotient -Operations complete when quotient(rounded down or not) == 0...
true
5b17c79d9830601e3ca3f21b2d1aa8f334e93f13
piumallick/Python-Codes
/LeetCode/Problems/0104_maxDepthBinaryTree.py
1,405
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 14 20:12:03 2020 @author: piumallick """ # Problem 104: Maximum Depth of a Binary Tree ''' Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf n...
true
c5f5581f816bd354b3ee78d660c58aab13bb3906
piumallick/Python-Codes
/LeetCode/Leetcode 30 day Challenge/April 2020 - 30 Day LeetCode Challenge/02_isHappyNumber.py
1,406
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Apr 25 22:49:19 2020 @author: piumallick """ # Day 2 Challenge """ Write an algorithm to determine if a number n is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum...
true
48a6871dba994b1244835a8fcc2a5edf9b206ca1
piumallick/Python-Codes
/LeetCode/Problems/0977_sortedSquares.py
909
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 7 15:01:17 2020 @author: piumallick """ # Problem 977: Squares of a Sorted Array ''' Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1: Inp...
true
3da3dfcf8bdba08539c1a0ecb23f7a908a8718f6
piumallick/Python-Codes
/LeetCode/Problems/0009_isPalindrome.py
973
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 29 15:46:03 2020 @author: piumallick """ # Problem 9: Palindrome Number """ Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input:...
true
a4b659635bbc3dbafabce7f53ea2f2387281daa3
piumallick/Python-Codes
/Misc/largestNumber.py
613
4.5625
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Sep 27 10:59:35 2019 @author: piumallick """ # Python Program to find out the largest number in the array # Function to find out the maximum number in the array def largestNumber(arr, n): # Initialize the maximum element max = arr[0] ...
true
78784eb5050732e41908bbb136a0bac6881bc29b
phenom11218/python_concordia_course
/Class 2/escape_characters.py
399
4.25
4
my_text = "this is a quote symbol" my_text2 = 'this is a quote " symbol' #Bad Way my_text3 = "this is a quote \" symbol" my_text4 = "this is a \' \n quote \n symbol" #extra line print(my_text) print(my_text2) print(my_text3) print(my_text4) print("*" * 10) line_length = input("What length is the line?" >) chara...
true
5ce0153e690d86edc4b835656d290cda02caa2c7
plee-lmco/python-algorithm-and-data-structure
/leetcode/23_Merge_k_Sorted_Lists.py
1,584
4.15625
4
# 23. Merge k Sorted Lists hard Hard # # Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. # # Example: # # Input: # [ # 1->4->5, # 1->3->4, # 2->6 # ] # Output: 1->1->2->3->4->4->5->6 def __init__(self): self.counter = itertools.count() def mergeKLists(self,...
true
cec13d4024f52f100c8075e5f1b43408790377bb
aquatiger/misc.-exercises
/random word game.py
1,175
4.5625
5
# does not do what I want it to do; not sure why # user chooses random word from a tuple # computer prints out all words in jumbled form # user is told how many letters are in the chosen word # user gets only 5 guesses import random # creates the tuple to choose from WORDS = ("python", "jumble", "easy", "difficult"...
true
30be4f414ed675c15f39ccf62e33924c7eb9db3b
Deepanshudangi/MLH-INIT-2022
/Day 2/Sort list.py
348
4.46875
4
# Python Program to Sort List in Ascending Order NumList = [] Number = int(input("Please enter the Total Number of List Elements: ")) for i in range(1, Number + 1): value = int(input("Please enter the Value of %d Element : " %i)) NumList.append(value) NumList.sort() print("Element After Sorting List in Asce...
true
34028b34420e05f24493049df0c8b5b0391eb9b9
sammaurya/python_training
/Assignment6/Ques4.py
879
4.4375
4
''' We have a function named calculate_sum(list) which is calculating the sum of the list. Someone wants to modify the behaviour in a way such that: 1. It should calculate only sum of even numbers from the given list. 2. Obtained sum should always be odd. If the sum is even, make it odd by adding +1 and if the sum...
true
2b5069c18e127d08dbaf55b1e0c7da11f1f87440
sammaurya/python_training
/classes.py
1,090
4.1875
4
# class A: # def __init__(self): # self.name = "sam" # self._num = 9 #protected # self.__age = 22 #private # a = A() # print(a.name, a._num) # a.__age = 23 # print(a._A__age) # print(dir(a)) # a = 8 # b=10 # print(a.__add__(2)) # for i in range(5): # print(i) # print(range(5))...
false
44f4b11f6819b285c3698ab59571f03591ad72b8
sahilsehgal81/python3
/computesquareroot.py
308
4.125
4
#!/usr/bin/python value = eval(input('Enter the number to find square root: ')) root = 1.0; diff = root*root - value while diff > 0.00000001 or diff < -0.00000001: root = (root + value/root) / 2 print(root, 'squared is', root*root) diff = root*root - value print('Square root of', value, "=", root)
true
cfcd0baa03e8b3534f59607103dfec97f760ea28
zoeang/pythoncourse2018
/day03/exercise03.py
699
4.40625
4
## Write a function that counts how many vowels are in a word ## Raise a TypeError with an informative message if 'word' is passed as an integer ## When done, run the test file in the terminal and see your results. def count_vowels(word): if (type(word)==str)==False: raise TypeError, "Enter a string." else: vowel...
true
bb7941ec61dab5e4798f20fb78222c933efdcfe4
Quantum-Anomaly/codecademy
/intensive-python3/unit3w4d6project.py
757
4.5
4
#!/usr/bin/env python3 toppings = ['pepperoni', 'pineapple', 'cheese', 'sausage', 'olives', 'anchovies', 'mushrooms'] prices = [2,6,1,3,2,7,2] num_pizzas = len(toppings) #figure out how many pizzas you sell print("we sell " + str(num_pizzas) + " different kinds of pizza!") #combine into one list with the prices attache...
true
8ad608b134e6244dc51b15a8b94e33fd316a063d
Huynh-Soup/huynh_story
/second.py
391
4.1875
4
""" Write a program that will ask the user what thier age is and then determine if they are old enough to vote or not and respond appropriatlely """ age = int(input("Hello, how old are you?: ")) if age < 17 : print("You can't vote") if age > 18 : print("Great, who would you vote for in 2020? (a,b,c) ")...
false
544c379a54a69a59d25a1241727d02f9414d6d1b
Murrkeys/pattern-search
/calculate_similarity.py
1,633
4.25
4
""" Purpose : Define a function that calculates the similarity between one data segment and a given pattern. Created on 15/4/2020 @author: Murray Keogh Program description: Write a function that calculates the similarity between a data segment and a given pattern. If the segment is shorter than the pat...
true
13593ebd81e6210edd3981895623975c820a72bc
MurrayLisa/pands-problem-set
/Solution-2.py
367
4.4375
4
# Solution-2 - Lisa Murray #Import Library import datetime #Assigning todays date and time from datetime to variable day day = datetime.datetime.today().weekday() # Tuesday is day 1 and thursday is day 3 in the weekday method in the datetime library if day == 1 or day == 3: print ("Yes - today begins with a T") ...
true
00c63f2572974a410eb7dfeaad043c1e067dfdf4
room29/python
/FOR.py
1,820
4.21875
4
# lista en python mi_lista = ['pocho', 'sander', 'caca'] for nombre in mi_lista: print (nombre) # Realizar un programa que imprima en pantalla los números del 20 al 30. for x in range(20,31): print(x) '''La función range puede tener dos parámetros, el primero indica el valor inicial que tomará la variable ...
false
c0babd8461d2df8c5c3fe535b4fcc9ae15464adf
dcassells/Project-Euler
/project_euler001.py
565
4.46875
4
""" If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ def three_multiple(x): if x%3 == 0: return 1 else: return 0 def five_multiple(x): if x%5 == 0: return 1 else...
true
5af9348c7a72d67d0985911be231eb92519c8610
elagina/Codility
/lessons/lesson_1.py
580
4.15625
4
""" Codility Lesson 1 - Iterations BinaryGap - Find longest sequence of zeros in binary representation of an integer. """ def solution(N): bin_N = str("{0:b}".format(N)) max_counter = 0 counter = 0 for ch in bin_N: if ch == '1': if max_counter < counter: max_coun...
true
b3bd54dd4116a00744311a671f01040d70799f98
josemigueldev/algoritmos
/07_factorial.py
442
4.21875
4
# Factorial de un número def factorial(num): result = 1 if num < 0: return "Sorry, factorial does not exist for negative numbers" elif num == 0: return "The factorial of 0 is 1" else: for i in range(1, num + 1): result = result * i return f"The factorial of ...
true
c5cdfbda5e8cb293bb7773ef345ddb5c8157313e
udhay1415/Python
/oop.py
861
4.46875
4
# Example 1 class Dog(): # Class object attribute species = "mammal" def __init__(self, breed): self.breed = breed # Instantation myDog = Dog('pug'); print(myDog.species); # Example 2 class Circle(): pi = 2.14 def __init__(self, radius): self.radius = radius ...
true
f7ba7fbb5be395558e1d8451e6904279db95952d
Nour833/MultiCalculator
/equation.py
2,637
4.125
4
from termcolor import colored import string def equation(): print(colored("----------------------------------------------------------------", "magenta")) print(colored("1 ", "green"), colored(".", "red"), colored("1 dgree", "yellow")) print(colored("2 ", "green"), colored(".", "red"), colored("2 degree...
true
f9d07c3b4fbdc162b266613270fb975eac8e097d
lidongdongbuaa/leetcode2.0
/位运算/汉明距离/461. Hamming Distance.py
1,551
4.28125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/1/16 20:33 # @Author : LI Dongdong # @FileName: 461. Hamming Distance.py '''''' ''' 题目分析 1.要求:The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Input: x = 1, y = 4 Output: 2 Explanation: 1 (...
true
e88f7472da1d78f89cd3a23e98c97c3bc054fba7
lidongdongbuaa/leetcode2.0
/二叉树/二叉树的遍历/DFS/145. Binary Tree Postorder Traversal.py
1,978
4.15625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/2/19 20:15 # @Author : LI Dongdong # @FileName: 145. Binary Tree Postorder Traversal.py '''''' ''' 题目分析 1.要求: Given a binary tree, return the postorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ ...
true
7b2ffd07955b5c356405909fc2649e6f88a5542d
lidongdongbuaa/leetcode2.0
/位运算/数学相关问题/201. Bitwise AND of Numbers Range.py
1,796
4.15625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/1/18 9:39 # @Author : LI Dongdong # @FileName: 201. Bitwise AND of Numbers Range.py '''''' ''' 题目分析 1.要求:Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. Example 1: Input: [5,7] Output:...
false
8a4ccf34efe6041af0f3d69dae882df49b30d0e8
lidongdongbuaa/leetcode2.0
/二分搜索/有明确的target/33. Search in Rotated Sorted Array.py
2,283
4.21875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/3/12 15:24 # @Author : LI Dongdong # @FileName: 33. Search in Rotated Sorted 数组.py '''''' ''' 题目分析 - 本题重点看 find the target value in the sorted rotated array, return its index, else return -1 O(logN) binary search problem input: nums:list[int], repeated valu...
true
01aeba94e37e74be60c0b9232b80b18edcdf251e
lidongdongbuaa/leetcode2.0
/二叉树/路径和/257. Binary Tree Paths.py
2,842
4.1875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/2/26 16:16 # @Author : LI Dongdong # @FileName: 257. Binary Tree Paths.py '''''' ''' 题目分析 1.要求:Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example: Input: 1 / \ 2 ...
true
7fab504e2bf2fbdf95ba142fb630b38fb34b4ab4
lidongdongbuaa/leetcode2.0
/二分搜索/有明确的target/367. Valid Perfect Square.py
2,926
4.34375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/3/12 11:19 # @Author : LI Dongdong # @FileName: 367. Valid Perfect Square.py '''''' ''' 题目分析 1.要求:Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function suc...
true
656d6352c80b070e9760832e961a7c3443ed5c94
lidongdongbuaa/leetcode2.0
/二分搜索/有明确的target/81. Search in Rotated Sorted Array II.py
2,724
4.1875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/3/17 11:18 # @Author : LI Dongdong # @FileName: 81. Search in Rotated Sorted 数组 II.py '''''' ''' 题目概述:在rotated sorted array里面找目标值 题目考点: 在分块后,块可能不是sorted的,出现头值l和尾值mid重复,怎么处理 解决方案: 不断缩进left part的left边界,直到l不等于mid,此时left块是sorted,再进行binary search 方法及方法分析:brute fo...
false
b20e9404095fe9b959a709747ef4685a3ac5798a
lidongdongbuaa/leetcode2.0
/二分搜索/没有明确的target/458. Last Position of Target (Lintcode).py
1,173
4.21875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/3/12 18:52 # @Author : LI Dongdong # @FileName: 458. Last Position of Target (Lintcode).py '''''' ''' 题目分析 Description Find the last position of a target number in a sorted array. Return -1 if target does not exist. Example Given [1, 2, 2,...
false
c7c49fdd8806c4b5e06b0502cb892511d82cec67
lidongdongbuaa/leetcode2.0
/数据结构与算法基础/leetcode周赛/200301/How Many Numbers Are Smaller Than the Current Number.py
1,974
4.125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2020/3/1 11:32 # @Author : LI Dongdong # @FileName: How Many Numbers Are Smaller Than the Current Number.py '''''' ''' 题目分析 1.要求: 2.理解:in a arr, count how many elem in this list < list[i], output 3.类型:array 4.确认输入输出及边界条件: input: list, length? 2<= <= 500; valu...
true
51a7a056f3efed50e627e4e07e0b63053e4f499e
masskro0/test_generator_drivebuild
/utils/plotter.py
1,910
4.5625
5
"""This file offers several plotting methods to visualize functions or roads.""" import matplotlib.pyplot as plt import numpy as np def plotter(control_points): """Plots every point and lines between them. Used to visualize a road. :param control_points: List of points as dict type. :return: Void. ""...
true
0e6b1edba6cc8b19d81a97ba4af49a79f41bca5c
TomasHalko/pythonSchool
/School exercises/day_2_exercise_5.py
789
4.28125
4
dictionary = {'cat': 'macka', 'dog': 'pes', 'hamster': 'skrecok', 'your_mom': 'tvoja mama'} print("Welcome to the English to Slovak translator.") print("---------------------------------------------") print("English\t - \tSlovak") print("---------------------------------------------") for key,value in dictionary.item...
false
7265ea38cd157f595842c3ef9b309107ce72703a
FalseFelix/pythoncalc
/Mood.py
381
4.1875
4
operation=input("what mood are you in? ") if operation=="happy": print("It is great to see you happy!") elif operation=="nervous": print("Take a deep breath 3 times.") elif operation=="sad": print("kill yourself") elif operation == "excited": print("cool down") elif operation == "relaxed": print("dr...
true
fc080b5de22363064f268a18b5fd5767d3fc170f
wcleonard/PythonBridge
/Algorithm/sort/heap_sort.py
2,472
4.375
4
# @Time : 2019/4/21 0:49 # @Author : Noah # @File : heap_sort.py # @Software: PyCharm # @description: python -m doctest -v heap_sort.py # 利用堆这种数据结构所设计的一种排序算法 # 堆是一个近似完全二叉树的结构 # 并同时满足堆积的性质: # 每个结点的值都大于或等于其左右孩子结点的值,称为大顶堆 # 每个结点的值都小于或等于其左右孩子结点的值,称为小顶堆 # heapify函数作用是将待排序序列构造成一个大顶堆,此时整个序列的最大值就是堆顶的根节点 def heapify(u...
false
20b4b1e4590ec30986cd951656926c9777e9b35b
kingdayx/pythonTreehouse
/hello.py
1,232
4.21875
4
SERVICE_CHARGE = 2 TICKET_PRICE =10 tickets_remaining = 100 # create calculate_price function. It takes tickets and returns TICKET_PRICE * tickets def calculate_price(number_of_tickets): # add the service charge to our result return TICKET_PRICE * number_of_tickets + SERVICE_CHARGE while tickets_remaining: ...
true
6bb6ae0cb5373c6619deda59adfbf5a33263419e
darshikasingh/tathastu_week_of_code
/day 3/program3.py
271
4.34375
4
def duplicate(string): duplicateString = "" for x in string: if x not in duplicateString: duplicateString += x return duplicateString string = input("ENTER THE STRING") print("STRING AFTER REMOVING DUPLICATION IS", duplicate(string))
true
bb62403136e8af65bfecf341f083bb6c1db0b2de
annalyha/iba
/For_unit.py
949
4.28125
4
#Реализуйте рекурсивную функцию нарезания прямоугольника с заданными пользователем сторонами a и b на квадраты # с наибольшей возможной на каждом этапе стороной. # Выведите длины ребер получаемых квадратов и кол-во полученных квадратов. a = int(input("Длина стороны a: ")) b = int(input("Ширина стороны b: ")) ...
false
b15f207ad94ebec1fd8365a66a54563c1589e958
vrashi/python-coding-practice
/upsidedowndigit.py
228
4.25
4
# to print the usside-down triangle of digits row = int(input("Enter number of rows")) a = row for i in range(row+1, 0, -1): for j in range(i+1, 2, -1): print(a, end = " ") a = a - 1 print() a = row
true
394e5870361f046e78b91c28e4a0b9584e2cb158
os-utep-master/python-intro-Jroman5
/wordCount.py
1,513
4.125
4
import sys import string import re import os textInput ="" textOutput ="" def fileFinder(): global textInput global textOutput if len(sys.argv) is not 3: print("Correct usage: wordCount.py <input text file> <output file>") exit() textInput = sys.argv[1] textOutput = sys.argv[2] if not os.path.exists(textInp...
true
0008d5d1d0598ec37b494351fe76f7d0fd49011b
AdityanBaskaran/AdityanInterviewSolutions
/Python scripts/evenumbers.py
371
4.125
4
listlength = int(input('Enter the length of the list ... ')) numlist = [] for x in range(listlength): number = int(input('Please enter a number: ')) numlist.append(number) numlist.sort() def is_even_num(l): enum = [] for n in l: if n % 2 == 0: enum.append(n) return enum print (...
true
e9741e14864c9005a628a75da45532e32d4c3697
Jocapear/TC1014
/WSQ05.py
224
4.125
4
f = float(input("Give me your temperature in F°")) c = float(5 * (f - 32)/9) print(f,"F° is equivalent to ",c,"C°.") if(c>99): print("Water will boil at ",c,"C°.") else: print("Water will NOT boil at ",c,"C°.")
false
4914e373050abc2fc202a357d4e8a82ee7bd87c7
laurakressin/PythonProjects
/TheHardWay/ex20.py
920
4.1875
4
from sys import argv script, input_file = argv # reads off the lines in a file def print_all(f): print f.read() # sets reference point to the beginning of the file def rewind(f): f.seek(0) # prints the line number before reading out each line in the file def print_a_line(line_count, f): print line_count...
true
c9f68086ab8f97bad4b3b1c1961a0216f655f14c
cscoder99/CS.Martin
/codenow9.py
275
4.125
4
import random lang = ['Konichiwa', 'Hola', 'Bonjour'] user1 = raw_input("Say hello in English so the computer can say it back in a foreign langauge: ") if (user1 == 'Hello') or (user1 == 'hello'): print random.choice(lang) else: print "That is not hello in English"
true
6bac138771347788474a115b37b56b241d8cc8f7
anjosanap/faculdade
/1_semestre/logica_programacao/exercicios_apostila/estruturas_sequenciais_operadores_expressoes/ex6.py
298
4.15625
4
""" Faça um programa que peça a temperatura em grausFahrenheit, transforme e mostre a temperatura em graus Celsius. """ fahrenheit = float(input('Insira sua temperatura em graus Fahrenheit: ')) celsius = (fahrenheit - 32) * 5 / 9 print('Sua temperatura em Celsius é:', '%.1f' % celsius, 'ºC')
false
2052521302b0654c70fc5e7065f4a2cd6ff71fb1
martinfoakes/word-counter-python
/wordcount/count__words.py
1,035
4.21875
4
#!/usr/bin/python file = open('word_test.txt', 'r') data = file.read() file.close() words = data.split(" ") # Split the file contents by spaces, to get every word in it, then print print('The words in this file are: ' + str(words)) num_words = len(words) # Use the len() function to return the length of a list (words...
true
fbc2c2b14924d71905b9ad9097f2e9d7c9e541fc
davidobrien1/Programming-and-Scripting-Exercises
/collatz.py
1,533
4.78125
5
# David O'Brien, 2018-02-09 # Collatz: https://en.wikipedia.org/wiki/Collatz_conjecture # Exercise Description: In the video lectures we discussed the Collatz conjecture. # Complete the exercise discussed in the Collatz conjecture video by writing a # single Python script that starts with an integer and repeatedly a...
true
d31bfb61f8e01688b186e6ccf860c12f8b1184de
j-kincaid/LC101-practice-files
/LC101Practice/Ch13_Practice/Ch13_fractions.py
543
4.21875
4
class Fraction: """ An example of a class for creating fractions """ def __init__(self, top, bottom): # defining numerator and denominator self.num = top self.den = bottom def __repr__(self): return str(self.num) + "/" + str(self.den) def get_numerator(self): return...
true
878934e0c30544f1b8c659ed41f789f20d9ac809
j-kincaid/LC101-practice-files
/LC101Practice/Ch10_Practice/Ch10Assign.py
1,008
4.15625
4
def get_country_codes(prices): # your code here """ Return a string of country codes from a string of prices """ #_________________# 1. Break the string into a list. prices = prices.split('$') # breaks the list into a list of elements. #_________________# 2. Manipulate the individual element...
true
01c29535868a34895b949fa842ba41393251e622
j-kincaid/LC101-practice-files
/LC101Practice/Ch9_Practice/Ch_9_Str_Methods.py
880
4.28125
4
#___________________STRING METHODS # Strings are objects and they have their own methods. # Some methods are ord and chr. # Two more: ss = "Hello, Kitty" print(ss + " Original string") ss = ss.upper() print(ss + " .upper") tt = ss.lower() print(tt + " .lower") cap = ss.capitalize() # Capitalizes the first chara...
true
c2570e4c6ef6f4d83565952d783fa681eed14981
lunaxtasy/school_work
/primes/prime.py
670
4.34375
4
""" Assignment 3 - Prime Factors prime.py -- Write the application code here """ def generate_prime_factors(unprime): """ This function will generate the prime factors of a provided integer Hopefully """ if isinstance(unprime, int) is False: raise ValueError factors = [] #for c...
true
b241bbd11590407332240b8254c911742e4382cc
TangMartin/CS50x-Introduction-to-Computer-Science
/PythonPractice/oddoreven.py
264
4.28125
4
number = -1 while(number <= 0): number = int(input("Number: ")) if(number % 2 == 0 and number % 4 != 0): print("Number is Even") elif(number % 2 == 0 and number % 4 == 0): print("Number is a multiple of four") else: print("Number is Odd")
true
32d0aa6e3c5c083e6db1e174c3726a3ae99835ab
Kartavya-verma/Competitive-Pratice
/PyLearn/demo1.py
362
4.125
4
'''for i in range(0,5,1): for j in range(0,5,1): if j<=i: print("*",end="") print()''' '''for i in range(6): for j in range(6-i): print("*",end="") print()''' q=int(input("Enter a num: ")) for i in range(2,q): if q%i==0: print("Not a prime num") ...
false
36020e1b3eaa7ce3cfd732813f6f86b0948245e3
Kartavya-verma/Competitive-Pratice
/Linked List/insert_new_node_between_2_nodes.py
1,888
4.125
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def inserthead(self, newnode): tempnode = self.head self.head = newnode self.head.next = tempnode del tempnode def li...
true
34e7f7e3d1b5c3688c8091c12c360da3f4563c45
PoojaKushwah1402/Python_Basics
/Sets/join.py
1,642
4.8125
5
# join Two Sets # There are several ways to join two or more sets in Python. # You can use the union() method that returns a new set containing all items from both sets, # or the update() method that inserts all the items from one set into another: # The union() method returns a new set with all items from both sets: ...
true
52355dd175d820141ce23ace508c0c73501a74b0
PoojaKushwah1402/Python_Basics
/variable.py
809
4.34375
4
price =10;#this value in the memory is going to convert into binary and then save it price = 30 print(price,'price'); name = input('whats your name ?') print('thats your name '+ name) x, y, z = "Orange", "Banana", "Cherry" # Make sure the number of variables matches the number of values, or else you will get an error....
true
692f1ef93f6b188a9a3244d45c73239e18ded92c
PoojaKushwah1402/Python_Basics
/Sets/sets.py
999
4.15625
4
# Set is one of 4 built-in data types in Python used to store collections of data. # A set is a collection which is both unordered and unindexed. # Sets are written with curly brackets. # Set items are unordered, unchangeable, and do not allow duplicate values. # Set items can appear in a different order every time you...
true
9df5a51bffcc602bc34b04de97ef2b65e1a7759f
PoojaKushwah1402/Python_Basics
/List/list.py
1,906
4.4375
4
#Unpack a Collection # If you have a collection of values in a list, tuple etc. Python allows you extract the #values into variables. This is called unpacking. fruits = ["apple", "banana", "cherry"] x, y, z = fruits print(x,'x') print(y,'y') print(z,'z') # Lists are one of 4 built-in data types in Python used to sto...
true
f87ea76282626fba9e5f4e590bfdf282304346d4
Franco414/DASO_C14
/Ejercicios_Extras/Unidad7/Ejercicio_7_4.py
1,649
4.46875
4
""" a) Escribir una función que reciba dos vectores y devuelva su producto escalar. b) Escribir una función que reciba dos vectores y devuelva si son o no ortogonales. c) Escribir una función que reciba dos vectores y devuelva si son paralelos o no. d) Escribir una función que reciba un vector y devuelva su norma. """ ...
false
dcfa6ed57445ecd90fdec3e3f5c431f0628bf3db
Franco414/DASO_C14
/Ejercicios_Extras/Unidad5/Ejercicio_5_9.py
816
4.375
4
""" Ejercicio 5.9. Escribir una función que reciba dos números como parámetros, y devuelva cuántos múl- tiplos del primero hay, que sean menores que el segundo. a) Implementarla utilizando un ciclo for, desde el primer número hasta el segundo. b) Implementarla utilizando un ciclo while, que multiplique el primer número...
false
1749fc700b55dc9860bfe2f98b8336ee151c29ce
Franco414/DASO_C14
/Ejercicios_Extras/Unidad4/Ejercicio_4_4.py
1,727
4.28125
4
""" Ejercicio 4.4. Escribir funciones que permitan encontrar: a) El máximo o mínimo de un polinomio de segundo grado (dados los coeficientes a, b y c), indicando si es un máximo o un mínimo. b) Las raíces (reales o complejas) de un polinomio de segundo grado. Nota: validar que las operaciones puedan efectuarse antes de...
false
17044fe456f5ab3ea5e6d5fdb9b3bdc4b736158c
tskiranmayee/Python
/3.Functions/FuncEx.py
261
4.125
4
# -*- coding: utf-8 -*- """ Created on Fri May 7 12:07:56 2021 @author: tskir """ """Example : Add two numbers""" def add(a,b): c=a+b return c a=int(input("Enter first value:")) b=int(input("Enter second value:")) print("sum={}".format(add(a,b)))
false
6811f8a6667506b20213934697e0b3207ace1520
tskiranmayee/Python
/5. Set&Tuples&Dictionary/AccessingItems.py
393
4.21875
4
# -*- coding: utf-8 -*- """ Created on Tue May 18 15:49:01 2021 @author: tskir """ """ Accessing Items in Dictionary """ dictEx={1:"a",2:"b",3:"c",4:"d"} i=dictEx[1] print("Value of the key 1 is: {}".format(i)) """Another way of Accessing Items in Dictionary""" j=dictEx.get(1) print("Another way to get value for key...
true
c2e88d79e03904bc41c849691d12962c9165c683
Marlon-Poddalgoda/ICS3U-Assignment5-B-Python
/times_table.py
1,287
4.1875
4
#!/usr/bin/env python3 # Created by Marlon Poddalgoda # Created on December 2020 # This program calculates the times table of a user input import constants def main(): # this function will calculate the times table of a user input print("This program displays the multiplication table of a user input.") ...
true
fb976318bdc72e4137aa11b60af4d05b579fada8
Oleg20502/infa_2020_oleg
/hypots/hypot4.py
240
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 8 12:40:38 2020 @author: student """ import turtle n = 1000 step = 1000/n for i in range(n): turtle.shape('turtle') turtle.forward(step) turtle.left(360/n)
false
62fb9d429b269174283f7ce361fbf4b03a088308
PashaKim/Python-Function-Leap-year
/Leap-year.py
264
4.1875
4
print ("This function(is_year_leap(year)) specifies a leap year") def is_year_leap (y): if y%400==0: print(y," is leap year") elif y%4==0 and y%100!=0: print(y," is leap year") else: print(y," is common year")
false
ad841fe2c7b77c9f500e9a1962d9460b3dfc0425
sweetmentor/try-python
/.~c9_invoke_74p4L.py
2,562
4.3125
4
# print('Hello World') # print('Welcome To Python') # response = input("what's your name? ") # print('Hello' + response) # # print('please enter two numbers') # a = int(input('enter number 1:')) # b = int(input('enter number 2:')) # print(a + b) # num1 = int(input("Enter First Number: ")) # num2 = int(input("Enter S...
true
88a00a55774274724298e6641d778fc1ef0e77d7
pavelgolikov/Python-Code
/Data_Structures/Linked_List_Circular.py
1,978
4.15625
4
"""Circular Linked List.""" class _Node(object): def __init__(self, item, next_=None): self.item = item self.next = next_ class CircularLinkedList: """ Circular collection of LinkedListNodes === Attributes == :param: back: the lastly appended node of this CircularLinkedList ...
true
dbaa1a417e12832ee0865031534e3d04de7e6d04
pavelgolikov/Python-Code
/Old/Guessing game.py
808
4.15625
4
import random number = random.randint (1,20) i=0 print ('I am thinking about a number between 1 and 20. Can you guess what it is?') guess = int(input ()) #input is a string, need to convert it to int while number != guess: if number > guess: i=i+1 print ('Your guess is too low. You used ...
true
9d841232854343600926341d118f977d258536be
pavelgolikov/Python-Code
/Old/Dictionary practice.py
1,576
4.1875
4
"""Some functions to practice with lists and dictionaries.""" def count_lists(list_): """Count the number of lists in a possibly nested list list_.""" if not isinstance(list_, list): result = 0 else: result = 1 for i in list_: print(i) result = re...
true
3e43132819bc8bae1eb277d76ca981b9827fcde4
enrique95ae/Python
/Project 01/test007.py
391
4.1875
4
monday_temperatures = [9.1, 8.8, 7.5, 6.6, 8.9] ##printing the number of items in the list print(len(monday_temperatures)) ##printing the item with index 3 print(monday_temperatures[3]) ##printing the items between index 1 and 4 print(monday_temperatures[1:4]) ##printing all the items after index 1 print(monday_tem...
true
835bbc207ec0ffb49e6a0edcf82dc3aeb3b28504
fbakalar/pythonTheHardWay
/exercises/ex26.py
2,999
4.25
4
#---------------------------------------------------------| # # Exercise 26 # Find and correct mistakes in someone else's # code # # TODO: go back and review ex25 # compare to functions below # make sure this can be run by importing ex25 # #-----------------------------------------...
true
1832a289dececef43f9f2e08eaf902bc5ced7016
fbakalar/pythonTheHardWay
/exercises/ex22.py
1,248
4.1875
4
##################################################### # # Exercise 22 from Python The Hard Way # # # C:\Users\berni\Documents\Source\pythonTheHardWay\exercises # # # What do you know so far? # # TODO: # add some write up for each of these # ##################################################### ''' thi...
true
d8feb89430783948201453c395aa1d4a3c1ab9d2
meet-projects/TEAMB1
/test.py
305
4.15625
4
words=["ssd","dsds","aaina","sasasdd"] e_word = raw_input("search for a word in the list 'words': ") check = False for word in words: if e_word in word or word in e_word: if check==False: check=True print "Results: " print " :" + word if check==False: print "Sorry, no results found."
true
1b5404d371c0af7e0d3b1b48d6f517966d7f9a03
berchj/conditionalsWithPython
/condicionales.py
2,007
4.375
4
cryptoCurrency1 = input('Enter the name of the first cryptocurrency: ') cryptoCurrencyVal1 = float(input('Enter the value of ' + str(cryptoCurrency1) + ': ')) cryptoCurrency2 = input('Enter the name of the second cryptocurrency: ') cryptoCurrencyVal2 = float(input('Enter the value of ' + str(cryptoCurrency2) + ': ')) c...
false
7f9c909e6b9c0575d923b4f149f176b2f2ebb5be
josue-93/Curso-de-Python
/Py/Ejemplo8.py
366
4.25
4
#Realzar un programa que imprima en pantalla los numeros del 20 al 30 for x in range(20,31): print(x) '''La funcion range puede tener dos parametros, el primero indica el valor inicial que tomara la variable x, cada vuelta del for la variable x toma el valor siguiente hasta llegar al valor indicado por el segundo...
false
63f15390b441813b85bfa8c35efa0a06db9be552
lachlanpepperdene/CP1404_Practicals
/Prac02/asciiTable.py
434
4.3125
4
value = (input("Enter character: ")) print("The ASCII code for",value, "is",ord(value),) number = int(input("Enter number between 33 and 127: ")) while number > 32 and number < 128: print("The character for", number, "is", chr(number)) else: print("Invalid Number") # Enter a character:g # The A...
true
ecee3c7834b468cec5f437d173b91fc9665f63d1
Git-Pierce/Week8
/MovieList.py
1,487
4.21875
4
def display_menu(): print("MOVIE LIST MENU") print("list - List all movies") print("add - Add a movie") print("del - Delete a movie") print("exit - Exit program") print() def list(movie_list): i = 1 for movie in movie_list: print(str(i) + "- " + movie) i += 1 print()...
true
750845c87efe9e65c001c95cd24af1e9285fb40f
renansald/Python
/cursos_em_video/Desafio73.py
851
4.125
4
times = ["Plameira", "Santos", "Flamengo", "Internacional", "Atletico Mineiro", "Goiás", "Botafogo", "Bahia", "São Paulo", "Corinthias", "Grêmio", "Athlitico-PR", "Ceará SC", "Fortaleza", "Vasco da Gama", "Fluminense", "Chapecoense", "Cruzeiro", "CSA", "Avaí",]; print(f"Os 5 primeiros colocados são {times[:5]}\nOs 4 ul...
false
8129f3085e028d4cf50277d65812ff56e26f1f4e
renansald/Python
/Apostila/Capitulo2/Exercicio17.py
410
4.125
4
from math import sqrt a = float(input("Informe o valor de \'a\': ")); b = float(input("Informe o valor de \'b\': ")); c = float(input("Informe o calor de \'c\': ")); delta = (b**2) - (4*a*c); if(delta > 0): print(f"As raízes são {((-b) + sqrt(delta))/(2*a)} e {((-b) - sqrt(delta))/(2*a)}"); elif(delta == 0): pr...
false
1d66b04c774e3346197d17c4ca559a4c5642f3e9
green-fox-academy/Chiflado
/week-03/day-03/horizontal_lines.py
528
4.40625
4
from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pack() # create a line drawing function that takes 2 parameters: # the x and y coordinates of the line's starting point # and draws a 50 long horizontal line from that point. # draw 3 lines with that function. def drawing_hori...
true
95908f7ea38b97f342408bbdeac0b56f276d74d5
green-fox-academy/Chiflado
/week-02/day-02/matrix.py
539
4.125
4
# - Create (dynamically) a two dimensional list # with the following matrix. Use a loop! # # 1 0 0 0 # 0 1 0 0 # 0 0 1 0 # 0 0 0 1 # # - Print this two dimensional list to the output def matrix2d(x, y): matrix = [] for i in range(x): row = [] for j in range(y): if i == j:...
true
eccb62bc74d79af4e65142572fdb175ff1ca479d
green-fox-academy/Chiflado
/week-02/day-05/anagram.py
395
4.21875
4
first_string = input('Your first word: ') sorted_first = sorted(first_string) second_string = input('Aaaaand your second word: ') sorted_second = sorted(second_string) def anagram_finder(sorted_first, sorted_second): if sorted_first == sorted_second: return 'There are anagrams!' else: return 'T...
true
6f52eeb81dedf18d2dc0b356e818818a953fcad5
alessandraburckhalter/python-rpg-game
/rpg-1.py
2,163
4.15625
4
"""In this simple RPG game, the hero fights the goblin. He has the options to: 1. fight goblin 2. do nothing - in which case the goblin will attack him anyway 3. flee""" print("=-=" * 20) print(" GAME TIME") print("=-=" * 20) print("\nRemember: YOU are the hero here.") # create a main class to ...
true
88561d8cc5a2b0a3778877fbf87a05d0a378d21d
gssasank/UdacityDS
/DataStructures/LinkedLists/maxSumSubArray.py
805
4.25
4
def max_sum_subarray(arr): current_sum = arr[0] # `current_sum` denotes the sum of a subarray max_sum = arr[0] # `max_sum` denotes the maximum value of `current_sum` ever # Loop from VALUE at index position 1 till the end of the array for element in arr[1:]: ''' # ...
true
562547cb28e651432ca6be189ebd212e0ba50d31
gssasank/UdacityDS
/PythonBasics/conditionals/listComprehensions.py
784
4.125
4
squares = [x**2 for x in range(9)] print(squares) #if we wanna use an if statement squares = [x**2 for x in range(9) if x % 2 == 0] print(squares) #if we wanna use an if..else statement, it goes in the middle squares = [x**2 if x % 2 == 0 else x + 3 for x in range(9)] print(squares) # QUESTIONS BASED ON THE CONCEPT ...
true
e6908a1fede2583910d752dec6b6af8ddf2a0460
gssasank/UdacityDS
/PythonBasics/functions/scope.py
483
4.1875
4
egg_count = 0 def buy_eggs(): egg_count += 12 # purchase a dozen eggs buy_eggs() #In the last video, you saw that within a function, we can print a global variable's value successfully without an error. # This worked because we were simply accessing the value of the variable. # If we try to change or reassign ...
true
006dc8d3d41608e3ecee53ef09350e01428e5f82
faizjamil/learningally-summer-coding-workshop
/helloWorld.py
285
4.15625
4
#!/usr/bin/python3 # prints 'hello world' print('hello world') # var for name name = 'Faizan' #print 'hello' + name print('Hello ' + name) # loop and print 'hello' + name for i in range(0, 5): if (i % 2 == 0): print('hello world') else: print('Hello ' + name)
false
9d5ffed0062bed15ae172ae26589eb30fee2e74f
JeahaOh/Python_Study
/Do_It_Jump_To_Python/1_Basic/02_Type/02_String/03_IndexingSlicing.py
1,377
4.25
4
# 문자열의 인덱스와 잘라내기 ㅁ = 'Life is too short, You need Python.' print(ㅁ) print('ㅁ -7 : ' + ㅁ[-7]) # 문자열 슬라이싱. b = ㅁ[0:4] print('ㅁ[0:4] : ' + b) ''' 문자열 슬라이싱은 문자열[시작 idx : 끝 idx]으로, 끝 인덱스는 포함하지 않는다. 시작 idx <= 대상 문자열 < 끝 idx ''' # 끝 idx를 생략하면 문자열의 끝까지 뽑아낸다. print('ㅁ[19:] : ' + ㅁ[19:]) # 시작 idx를 생략하면 처음부터 끝까지 뽑아낸다. print('...
false
188bd91cfa5302a8cc99c2f09e4aa376c35895b7
gredenis/-MITx-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python
/ProblemSet1/Problem3.py
1,187
4.25
4
# Assume s is a string of lower case characters. # Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, # if s = 'azcbobobegghakl', then your program should print # Longest substring in alphabetical order is: beggh # In the case of ties, print the first...
true
19d990ea9b35b7224bef4f99aa49bee947abd4ef
dejoker95/baekjoon
/기초/11729.py
234
4.125
4
def hanoi(n, start, dest, other): if n < 2: print(start, dest) return hanoi(n-1, start, other, dest) print(start, dest) hanoi(n-1, other, dest, start) n = int(input()) print((2**n)-1) hanoi(n, 1, 3, 2)
false
ec72975409e3eda6707fcb67778244299c00431e
Rhotimie/ZSSN
/lib/util_sort.py
1,361
4.125
4
import itertools def sort_tuple_list(tuple_list, pos, slice_from=None): """ Return a List of tuples Example usage: sort_tuple_list([('a', 1), ('b', 3), ('c', 2)]) :param status: list of tuples :type status: List :param list: :param int: :return: sorted list of tuples e.g [('a', ...
true
b445be9fa502014837bbc795a20d74940eb7d72d
NotBobTheBuilder/conways-game-of-life
/conways.py
2,242
4.125
4
from itertools import product from random import choice def cells_3x3(row, col): """Set of the cells around (and including) the given one""" return set(product(range(row-1, row+2), range(col-1, col+2))) def neighbours(row, col): """Set of cells that directly border the given one""" return cells_3x3(ro...
true
1db2a4fbd6827d302d3adb1562911e404b3ed2f5
EvgeniiGrigorev0/home_work-_for_lesson_2
/Lesson_3/HW_2_Lesson_3.py
1,162
4.125
4
# 2. Реализовать функцию, принимающую несколько параметров, # описывающих данные пользователя: имя, фамилия, год рождения, # город проживания, email, телефон. Функция должна принимать # параметры как именованные аргументы. Реализовать вывод # данных о пользователе одной строкой. ... name = input('Введите ваше имя: ')...
false
c5b638d3bb9940c3d92c8d1f5bb6616b0244256d
emir-naiz/first_git_lesson
/Courses/1 month/3 week/day 5/Задача №1.py
344
4.28125
4
# Программа имеет список и выводит список из 3 элементов: # первого, третьего и второго с конца элементов. list1 = [1,2,3,4,5,6,7,8,9,10] list2 = [] list2.append(list1[0]) list2.append(list1[2]) list_len = len(list1) list2.append(list1[list_len-2]) print(list2)
false