blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
2bf12cc265f899db13119297227544c252fbe25e
lperri/CTCI-Practice-Problems
/ch1_arrays_strings/interview_questions/iq_4.py
941
4.34375
4
# palindrome permutation: write a function to check if a string is a permutation of a palindrome # the defining property of a palindrome that I will check is that it must have no more than 1 char # that appears an odd number of times -- all other chars must appear an even number of times # def is_permutation_palindro...
true
0d942835131e7e0c5c9a6a42a3e62c74719874b8
lperri/CTCI-Practice-Problems
/ch2_linkedlists/interview_questions/implementation.py
2,186
4.375
4
class Node: def __init__(self, val=None): ''' constructor containing the data in a given node and a pointer to the next node (if a next node exists) ''' self.val = val self.next = None class LinkedList: ''' wraps Node class; useful because if head node changes for one obj, other objs ca...
true
c1af1aaaa7c3e2af6251f334d13d26cfcd75509a
lperri/CTCI-Practice-Problems
/ch2_linkedlists/interview_questions/iq_3.py
1,324
4.125
4
# delete a node in the middle (any node other than first and last) given ONLY access to THAT node from implementation import * def delete_a_middle_node(node: Node) -> None: ''' strategy: shift the rest of the linked list (using values) back by one, thus deleting this node ''' rest_of_list_values = [] node_...
true
ad93e097e9040e6a3265ba54db03520a737294e8
sgoldenlab/simba
/simba/roi_tools/ROI_size_calculations.py
2,313
4.28125
4
import math import numpy as np def rectangle_size_calc(rectangle_dict: dict, px_mm: float) -> dict: """ Compute metric height, width and area of rectangle. :param dict rectangle_dict: The rectangle width and height in pixels. :param float px_mm: Pixels per millimeter in the video. :...
true
e847db09fd18d1d7b4dd1e357a06c9be33547fb5
Gajendra28121996/PythonGarden
/Python_If_Statement.py
609
4.4375
4
is_male=True is_tall=False if is_male: print("You are Male !!") else: print("You are Probably Good !") ##When one or both of value is true use OR if is_male or is_tall: print("You are Male && Tall!!") else: print("You are Probably Good Nor Tall!") ##Mandatory to both to be true print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
false
0ccca243f2e0c95ec7b519ef346be233efe95b6a
Gajendra28121996/PythonGarden
/Python_List_Function.py
1,165
4.25
4
## List of number list_Of_Number=[3,4,6,9,11,13] friends=["Gajendra","Stan Lee","Repeating","Enstine","Iron Man","Skarlett Jhonson","Repeating","Repeating"] print(friends) print(list_Of_Number) ## append() >>> Allows me to append another item to the list friends.append("Creed") print(friends) ##Print the Index of Li...
true
5b35d79e61d1f13c982f86418330e8fbf0fd35b3
slushhub/mining-mondays
/how-to-read-code/1.py
1,527
4.375
4
""" Variables Variables are just names for values. Names help in reading. Imagine asd vs my_telephone_number, which is more informative? """ # my name is Tero my_name = 'Tero' # my age is 24 my_age = 24 # teemus age is two times my age teemus_age = 2 * my_age """ Conditionals The point of...
true
93fd684abc67c7d66f4dbbe95807eee290f32970
Ankan002/Python-College-Practical-Code-and-Info
/Practical 11/code.py
207
4.34375
4
string = str(input("Enter the string for which you want to find the ASCII value: ")) new_ascii = "" for c in string: new_ascii = new_ascii + str(ord(c)) print("ASCII value of", string, "is:", new_ascii)
true
80ae29f7a2c28667febd972edff724c5159df732
samkit-jpss/DSA
/Queue/queue.py
943
4.15625
4
class Queue: def __init__(self): self.items=[] #Insertion of Element def Enqueue(self,data): self.items.insert(0,data) #Pop the element at the last or first inserted element def Dequeue(self): return self.items.pop() #Returns the size of the list def qsi...
true
14a4148c8197eaec9bd2449d7a619dfce139f8f6
Pavche/python_scripts
/dictionary2.py
728
4.1875
4
#!/usr/bin/python3 # This script demonstrates dictionary which is a part of Python programming language. birthdays = {'Маргарита':'28 март 1960','Румяна':'23 май 1961', 'Красимир':'27 декември' ,'Младен':'25 април 1976','Павлин':'30 юни 1979','Галя':'2 септември 1981', 'Драган':'17 юни 1985','Катерина':'28 октомври 20...
false
cafe7dbe26a417237e56b62d26dee6f5a6a37adf
BobIT37/Python3Programming
/venv/07-Built-in Functions/01-Map.py
645
4.4375
4
# map() takes in two or more arguments # a function and one or more iterables # syntax # map(function, iterable...) # map returns iterator my_pets = ["alfred", "tabitha", "william", "arla"] uppered_pets = [] ''' for pet in my_pets: pet_ = pet.upper() uppered_pets.append(pet_) print(uppered_pets) ''' uppered_...
true
a1c3cb52cd539c3d1b27e8d49c0f150cd3f7ed6b
akinahmet/python
/smallest_number.py
297
4.21875
4
number1=int(input("number1: ")) number2=int(input("number2: ")) number3=int(input("number3: ")) if number1<number2 and number1<number3: print("number 1 is the smallest") elif number2<number1 and number2<number3: print("number 2 is the smallest") else: print("number 3 is the smallest")
false
f58692c3858f078b4aacddaf8a01549d1658c32c
jsjimenez51/holbertonschool-higher_level_programming
/0x10-python-network_0/6-peak.py
958
4.125
4
#!/usr/bin/python3 """ finds a peak in a list of unsorted integers """ def find_peak(list_of_integers): """ finds peak using a binary search """ if list_of_integers: start = 0 end = len(list_of_integers) - 1 if start == end: return list_of_integers[start] # ...
true
88f8501b1125a38941f880cf381bf1e5e142c14b
jpicasso/LessonSummary3
/4Python/5HomeWork/9hw.py
647
4.65625
5
# Exercise 9. # A string is a palindrome if it is identical forward and backward. For example “anna”, “civic”, “level” and “hannah” are all examples of palindromic words. Write a program that reads a string from the user and uses a loop to determines whether or not it is a palindrome. Display the result, including a ...
true
696c6e6c8c0f663ff5e929881f5c6ea315947053
IacovColisnicenco/100-Days-Of-Code
/DAYS_001-010/Day - 003/Exercises/day-3-2-exercise.py
601
4.34375
4
height = float(input("Enter your height in Metres (m): ")) weight = float(input("Enter your weight in Kilograms (kg): ")) bmi = weight / height ** 2 bmi_result = round(bmi, 2) if bmi_result < 18.5: print(f"Your BMI is -> {bmi_result}, You are Underweight") elif bmi_result < 25: print(f"Your BMI is -> {bmi_r...
false
e6936a156c850aaed279bb7cad50e41f91b65a8e
IacovColisnicenco/100-Days-Of-Code
/DAYS_011-020/Day - 19 - Exercise/turtle_race.py
1,430
4.3125
4
from turtle import Turtle, Screen import random my_screen = Screen() my_screen.setup(width=800, height=600) user_bet = my_screen.textinput(title="Make Your Bet", prompt="Which turtle will win the race? Enter a color: ").lower() colors = ["red", "orange", "yellow", "green", "DarkBlue", "purple", "SpringGreen", "DarkTur...
true
15628f246ef699d41ba11f8c27162193a5c0129f
YashaswiniPython/pythoncodepractice
/7_Dictionary.py
1,413
4.25
4
# Python file Created By Bibhuti d={"a":"d",2:"Python"}; print(d); # print(type(d)); # print(d.get('a')); # print(d.get(2)); # print(d.get("b")); # if key is not available it will return None # print(d.keys()); # it will provide all the keys set # print(d.values()); # it will provide all the values # print(d.i...
true
84462e5404558af15885e666e0783c27a3b05ce9
Martiboy/Spotlight
/Machiel/word adventure.py
2,318
4.15625
4
def menu(lists, question): for entry in lists: print (1 + lists.index(entry)) print (" ) " + entry) return int(input(question)) - 1 items = ["pot plant","painting","vase","lampshade","shoe","door"] keylocation = 2 keyfound = 0 loop = 1 print ("Last night you went to sleep in the comfort of ...
true
c89bf29734f53ac1f3304173ad99b60544f404b6
Amy7/Python-task
/guessinggame.py
721
4.25
4
import random number = random.randint(1,10) #print(number) n = 3 while(n): try: guess = int(input(("please guess the number:"))) while(guess > 10 or guess < 0): guess = int(input(("please input your number from 1 to 10"))) n -= 1 if(guess == number): ...
true
c4a15cabe8aa9caefbac67b0326ee84d1e85fade
Samuel1P/Prep
/algorithms/binary_search_using_while.py
492
4.1875
4
# this code will search for a integer in a sorted list using while loop arr_ = [1, 1, 2, 3, 3, 3, 4, 5, 6, 7] def binary_search(arr, first, last): while (first <= last): mid = (first + last) // 2 if ele == arr[mid]: return f"Found {ele}" elif ele < arr[mid]: last =...
true
7e22593e514c169076f99900424e42fe3f775463
davray/lpthw-exercises
/ex15.py
2,236
4.40625
4
# import the function argv from module sys from sys import argv # give argv variables to unpack script, filename = argv # assign var txt to open var filename txt = open(filename) # print string with raw format char with var filename print "\nHere's your file %r:" % filename # print var txt contents open(file.read) prin...
true
cf68d0df2b2cc12f6ca2b3605628e18e79623d81
rravitanneru/python
/identical operators.py
408
4.21875
4
# there are two identical operators # is, is not # is by default evalutes to true if vars on both sides of operator pointing to same memory location, object,value # is not by default evalutes to true if vars on both sides of operator pointing to same memory location, object,value a = 10 b = 10 if(a is b): ...
true
9850628b90b5acf55b731ffeebe01edc6b43b1a4
developbiao/pythonbasics
/2023/guess_high_low.py
339
4.1875
4
#!/usr/bin/env python3 #! -*- coding:utf-8 -*- number = 18 guess = -1 print("Guess number game!") while guess != number: guess = int(input("Please Input guess number:")) if guess == number: print("Yes Correct!") elif guess < number: print("To low...") elif guess > number: print("To hight...") print("Hel...
false
acab9b007c20b3a87d3bacb197ed031e4d173832
developbiao/pythonbasics
/2023/oop/people.py
898
4.125
4
#!/usr/bin/env python3 #-*- coding:utf-8 -*- class people: # Public property name = '' age = 0 # Prive property __weight = 0 # Construct def __init__(self, name, age, weight): self.name = name self.age = age self.__weight = weight # Sepak def speak(self): ...
false
b5f0f634f1327d084dfc75a15fdc651eabc8aab1
developbiao/pythonbasics
/2023/intervidew-questions/bubble-sort.py
280
4.25
4
#!/usr/bin/env python3 def bubble_sort(arr): n = len(arr) for i in range(n): for j in range(0, n - i -1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] arr = [32, 64, 71, 89] bubble_sort(arr) print("Sorted a array:", arr)
false
2bd89f67c58952885d2c88787af5692d86cff020
kyuugi/saitan-python
/やってみよう_必修編/chapter06/6_7_people.py
746
4.125
4
# 空のリストを作成する people = [] # 人の辞書を作成してリストに追加する person = { 'first_name': 'たかのり', 'last_name': '鈴木', 'age': 49, 'city': '東京', } people.append(person) person = { 'first_name': 'せぶん', 'last_name': '鈴木', 'age': 2, 'city': '東京', } people.append(person) person = { 'first_name': 'にあ...
false
9942ee03ecf8a05d7e9f4f21c22ec38c6e2035f5
RasselJohn/AlgorithmExercises
/src/03.py
859
4.28125
4
# Check number on primary. import math def is_prime(number): """ If number is prime - return True :param number: int :return: boolean >>> is_prime(25) False >>> is_prime(12) False >>> is_prime(11) True >>> is_prime(1) Traceback (most recent call last): ... ...
true
fdd0b1dd24d97cc57ec3ea18ae5bf2bb61838274
RasselJohn/AlgorithmExercises
/src/05.py
288
4.125
4
# Change 2 variables without third. # one way a = 3 b = 2 print("a = {0}, b = {1}".format(a, b)) a, b = b, a print("a = {0}, b = {1}".format(a, b)) # second way a = 3 b = 2 print("a = {0}, b = {1}".format(a, b)) a = a + b b = a - b a = a - b print("a = {0}, b = {1}".format(a, b))
false
8aa28961dcbc8655bbfa0df490b841496cbdef91
haochen208/Python
/pyyyy/23 阶段综合练习三/01.py
240
4.1875
4
# 请将列表中所有的字符串变为小写 L = ["Hello", "World", "Apple", "Banana"] L1 = [] for i in L: L1.append(i.lower()) print(L1) # 列表推导式:[表达式 for 变量 in 序列] print([i.lower() for i in L])
false
15903f72755a22a5ec6d9a95c83d3b2df08bf887
haochen208/Python
/pyyyy/01 输入、输出、变量/02变量.py
575
4.28125
4
# a = 2 # b = a # print(b) # num1 = 1 # num2 = 2 # num3 = 3 # num1, num2, num3 = 1, 2, 3 # num1 = num2 = num3 = 4 # print(num1,num2,num3) # a = 10 # b = a # a = 20 # print(a,b) # 变量名命名规则: # (1)数字、字母、下划线,其中数字不能开头 # (2)不能与python关键字重名 # (3)见名知意 # 下划线_:shift + - # _123 # nu23_? # 1info # stud...
false
8d1a4bdcdc2561106225df1eab8dd8998b2bd062
BrantLauro/python-course
/module01/classes/class09a.py
2,657
4.375
4
from style import blue, red, purple, none a = 'Hello World!' print(f'The string {blue}is{none} {purple}{a} {none}\n' f'The {blue}index 2nd{none} is {purple}{a[2]} {none}\n' f'The string {blue}until the 3rd index{none} is {purple}{a[:3]} {none}\n' f'The string {blue}starting in the 3rd index{none} is...
false
e896dd1641e9cd3b823e9cd29c74c05e1c2678cb
BrantLauro/python-course
/module03/ex/ex082.py
548
4.125
4
numbers = [] pair = [] odd = [] choice = ' ' while True: while choice not in 'NY': choice = input('Do you want to add a number on the list? [Y/N] ').upper().strip()[0] if choice == 'N': break if choice == 'Y': number = int(input('Type a number: ')) numbers.append(number) ...
true
b5ce81277156b93bd26483fd54ccfdd67c18e368
BrantLauro/python-course
/module01/ex/ex017.py
312
4.15625
4
from math import hypot oside = float(input('What is the length of the opposite side? ')) aside = float(input('What is the length of the adjacent side? ')) h = hypot(oside, aside) print(f'The hypotenuse of the triangle whose opposite side and adjacent side measure respectively {oside} and {aside} is {h:.2f}')
false
ddd4b58144fcf47fa58039da5129f097d6f38619
royaldream/Python
/OOPS/Practice/Monk and circular distance.py
2,083
4.28125
4
"""Its time for yet another challenge, and this time it has been prepared by none other than Monk himself for Super-Hardworking Programmers like you. So, this is how it goes: Given N points located on the co-ordinate plane, where the point is located at co-ordinate , , you need to answer q queries. In the query, yo...
true
8dce269430fdc7db07ddeb21dfe79ae3940dc3e2
sjacksondev/bouncy_ball
/bouncy.py
850
4.21875
4
""" PROGRAM: bouncy.py NAME: Sabrina DATE: 9/5/19 Program calculate the total difference travelled by a bouncing ball. User will input: The starting height of the ball How bouncy the ball is How many bounces the ball will make Output will be the total distance the ball travels """ # Request the inputs...
true
eaa387f7a1ae2943c95610ef6220e15a1eec2328
martinthk/python-exercises
/code/Ex13_Heron'sConvergence.py
569
4.125
4
# Ex13: Heron’s method of convergence # compute √𝑎 using Heron's method of Convergence # Take as input a number (a), and an initial guess for the value of √𝑎 # and repeatedly apply equation 1 until the approximate solution converges to close to the true solution. import math a = int(input('Enter the value for a: ...
true
5e13c84ade3c1b2275afe75f006fd03e3409283a
samjabrahams/anchorhub
/anchorhub/util/hasattrs.py
736
4.4375
4
""" hasattrs() checks a list of string arguments and sees whether the provided object has all of them. It uses the built-in hasattr() method with each attribute name """ def hasattrs(object, *names): """ Takes in an object and a variable length amount of named attributes, and checks to see if the object h...
true
5927eacb5f5e6e10ef6874975eb47ffefad6947d
samjabrahams/anchorhub
/anchorhub/util/addsuffix.py
544
4.65625
5
""" File for helper function add_suffix() """ def add_suffix(string, suffix): """ Adds a suffix to a string, if the string does not already have that suffix. :param string: the string that should have a suffix added to it :param suffix: the suffix to be added to the string :return: the string wit...
true
3263741eeae211b01761513ce52b0f8c88a20632
pjgb/dailyprogrammer
/ch287e.py
2,897
4.1875
4
#!/usr/bin/env python3 # Write a function that, given a 4-digit number, returns the largest digit # in that number. Numbers between 0 and 999 are counted as 4-digit numbers # with leading 0's. # # largest_digit(1234) -> 4 # largest_digit(3253) -> 5 # largest_digit(9800) -> 9 # largest_digit(3333) -> 3 ...
true
7fdfdf1e450cdc5e88cc3db5bf09a3bcabf548fe
pbarton666/learninglab
/begin_advanced/py_class_support.py
1,671
4.28125
4
#py_class_support.py """Demonstrate basic class operations""" #a simple class class Mammal(): pass #a class instance (a specific Mammal) m = Mammal() #...upgraded to initialize with instance attribute class Mammal(): def __init__(self): self.warmblooded=True #a class instance m = Mammal() #single inheritance, ...
true
8c7460b07a9b10da69dc1bff93c7203ddb263699
MediaPreneur/Introduction-to-python
/twinx.py
481
4.1875
4
import matplotlib.pyplot as plt import numpy as np x = np.arange(0., 100, 1); y1 = x**2; # y1 is defined as square of x values y2 = np.sqrt(x); # y2 is defined as square root of x values fig = plt.figure() ax1 = fig.add_subplot(111) ax1.plot(x, y1, 'bo'); ax1.set_ylabel('$x^{2}$'); ax2 = ax1.twinx() # tw...
true
d2447fcd3ecbb9525e41efdcd06c99aee7d2382b
ivddorrka/OP_nutriotionproject
/examples/example_pandas.py
2,342
4.40625
4
''' This module demonstrates how to use some pandas functionality ''' import pandas as pd def series_examples(): ''' This function demonstrates some basic pandas functionality on how to work with Series ''' nums_list = [1, 7, 2] nums_list_serie = pd.Series(nums_list, index=["x", "y", "z"]) prin...
true
9ea487ecec4a6cba47c433571cd4cf2dbf4a15bf
5-digits/interview-techdev-guide
/Data Structures/Stack/Python/Stack.py
1,397
4.1875
4
# Implementation of stack using list in Python # Stack is "LIFO(Last In First Out)" # push method is used to add an item on top of stack # pop method is used to get the topmost item from stack import copy class Stack: """ Just for the sake of teaching, this stack is implemented in such a wa...
true
60e4b0ea0fccdd254b27bf3db7381ae89f6e142d
5-digits/interview-techdev-guide
/Data Structures/Trie/Trie.py
1,648
4.15625
4
class TrieNode(object): def __init__(self): self.children = [] #will be of size = 26 self.isLeaf = False def getNode(self): p = TrieNode() #new trie node p.children = [] for i in range(26): p.children.append(None) p.isLeaf = False return p...
true
1c3c733e9237ca2b137a127f4e72afc5569a3fee
ThomasKisner/pythonPractice
/calculator/main.py
1,224
4.15625
4
#import regex import re print("Our Magical Calculator") print("Type 'quit' to exit\n") #initializing previous total variable previous = 0 #initializing variable which the calc will refer to to see if it should keep running run = True def performMath(): #getting run and previous into the function's scope globa...
true
18f0d82657191e25db883856110f164c2ea14eaf
jkcomm113/compciv-2018-jkeel
/week-05/sortsequences/sort_numbers.py
770
4.53125
5
from datastubs import NUMBER_LIST def reverse_numerical_order(): """ Sort the list of numbers but in reverse order """ return sorted(NUMBER_LIST, reverse=True) def numerical_order(): """ Sort the list of numbers in numerical order """ return sorted(NUMBER_LIST) # fill it out de...
true
7233fd761b83d8ca2e835fe5f9f2c675734d6528
damiso15/mini_python_projects
/Tutorial/stringlists.py
393
4.59375
5
# Ask the user for a string and print out whether this string is a palindrome or not. # (A palindrome is a string that reads the same forwards and backwards.) palindrome = input("Enter your word: ") new_word = palindrome[::-1] if palindrome == new_word: print(f"This word '{palindrome.upper()}' is a palindrome") ...
true
68bd9399dd5e6c277088cda5e482911758b6bd63
damiso15/mini_python_projects
/Tutorial/fibonacci.py
1,176
4.65625
5
# Write a program that asks the user how many Fibonacci numbers to generate and then generates them. # Take this opportunity to think about how you can use functions. # Make sure to ask the user to enter the number of numbers in the sequence to generate. # (Hint: The Fibonacci sequence is a sequence of numbers where th...
true
4b57628098ef9b0119cf0972c2767a6b01ef128a
RotemHalbreich/Ariel_OOP_2020
/Classes/week_09/TA/simon_group/3-2-numbers.py
740
4.28125
4
# Type Conversion x = 1 print(type(x)) y = 3.4 print(type(y)) # convert from int to float: a = float(x) # convert from float to int: b = int(y) # 1.0 will be 1 a = str(3.444) print(a) print(type(a)) x = 2 print("Exponentiation is nice", x, "**2 =", x ** 2) # to make random num import random print(random.randrange(...
true
6d69a1d1ba294f493adc583638dbd9dd022038e8
RotemHalbreich/Ariel_OOP_2020
/Classes/week_09/TA/simon_group/6-1-functions.py
2,069
4.71875
5
#__________________________________________functions__________________________________________# #all python methods is built-in functions #assign def my_function(): print("Hello from a function") # Calling a Function my_function() # Parameters def my_function(fname): print(fname + " Refsnes") my_function("E...
true
a364892efd223ac885e7760869159a1e03264fee
MingduDing/A-plan
/leetcode/数组Array/exam088.py
1,105
4.28125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/7/16 14:25 # @Author : Domi # @File : exam088.py # @Software: PyCharm """ 88.合并两个有序数组(easy) 题目:给定两个有序整数数组nums1和nums2,将nums2合并到nums1中, 使得nums1成为一个有序数组。 思路:双指针。将指针p1置为nums1的末尾,p2为nums2的末尾,在每一 步将最小值放入输出数组中。 """ def merge(nums1, m, nums2, n): """ 88....
false
53f7b06bcc782e7a45bb253ffbf901b765d4a1b5
cyyrusli/mit6001
/finalexam/dict_interdict.py
569
4.125
4
# function f depends on the question def f(a,b): return a > b def dict_interdiff(d1, d2): ''' d1, d2: dicts whose keys and values are integers Returns a tuple of dictionaries according to the instructions above ''' intersect = {} difference = {} for key in d1: if key in d2: ...
true
47dc8198d00f854081d70b6ec9ad68c8ee80b27d
srknthn/InformationSecurity
/TheKey/PSet3_Encrypt.py
803
4.375
4
__author__ = 'sr1k4n7h' def substitution_cipher(text, key): H = {'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7, 'I': 8, 'J': 9, 'K': 10, 'L': 11, 'M': 12, 'N': 13, 'O': 14, 'P': 15, 'Q': 16, 'R': 17, 'S': 18, 'T': 19, 'U': 20, 'V': 21, 'W': 22, 'X': 23, 'Y': 24, 'Z': 25} ke...
false
7e73037b4d41b3712a758343ce09c5972a0c0e06
audrec/Information-System-in-Python
/Week2/audrec_hw_2/audrec_hw_2_1_1.py
870
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Yen-Chi Chen Class: CS 521 - Spring 2 Date: 29-Mar-2021 Homework Problem #: 2.1.1 This program prompts for a number, do calculation on the input, then print if the result matches the expected calculated value. """ def calc_num(num): num = ((num + 2) * 3 - 6) / 3...
true
7a126889b92cc23a3af824dae35a16dcbfa08744
audrec/Information-System-in-Python
/Week3/audrec_hw_3/audrec_hw_3_14_6.py
1,541
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Yen-Chi Chen Class: CS 521 - Spring 2 Date: 05-April-2021 Homework Problem #: 3.14.6 Description: This program check if the input file exists, write in the input, read the file line by line, write each line into a list, and put and print these lists of lists as the res...
true
3bce67d9c5e52b5de880c8b5aeae417dadb61791
audrec/Information-System-in-Python
/Week2/audrec_hw_2/audrec_hw_2_2_6.py
1,396
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Yen-Chi Chen Class: CS 521 - Spring 2 Date: 29-Mar-2021 Homework Problem #: 2.2.6 This program calculates and prints all the leap years from 1899 to 2021 using for-loop and while-loop. """ # Create a list to store the leap year list_1 = [] # Calculates and prints le...
true
d206443289bdf15b2eb046a768027b0e86552bd0
audrec/Information-System-in-Python
/Week2/audrec_hw_2/audrec_hw_2_1_3.py
882
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Yen-Chi Chen Class: CS 521 - Spring 2 Date: 29-Mar-2021 Homework Problem #: 2.1.3 This program prompts for a number, converts the input to an integer and make a calculation on it. Print the result with comma separation and with the desired format. """ # Function to ...
true
79c8959a444f21bc7da6201f69b2de369225281c
meghagoyal0602/Learn-Python
/class-1.py
655
4.3125
4
# name=input('input name: ') # print() # print('hello') # print(name) # first_name='Megha' # last_name='Goyal' # print(first_name last_name) # print(first_name +' ' + last_name) sentence='My name is Megha Goyal aaaa' print(sentence.upper()) print(sentence.lower()) print(sentence.count('a')) first_name=input('what ...
false
ec92cfcdd172a096c44a4e6fa2fa00fcfcce1cc5
Rider66code/PythonForEverybody
/bin/ex_04_06.py
1,989
4.4375
4
# 2.3 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking or bad use...
true
c8deb8da0a3081d6cfa416f07489452b51ec5265
Rider66code/PythonForEverybody
/bin/p3p_c2w3_ex_003.py
227
4.375
4
#Write a function called subtract_three that takes an integer or any number as input, and returns that number minus three. def subtract_three(num): subint=num-3 return subint number=6 x=subtract_three(number) print(x)
true
19a52856f363659f8fd757c8c1ad2fc5c4b13913
Rider66code/PythonForEverybody
/bin/ex_08_04.py
853
4.53125
5
# 8.4 Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort and...
true
1fcdd81958539b61521e74a6c8391f6591ef034e
Rider66code/PythonForEverybody
/bin/p3p_c2w2_practice011.py
538
4.15625
4
#5. Create a dictionary called lett_d that keeps track of all of the characters in the string product and notes how many times each character was seen. Then, find the key with the highest value in this dictionary and assign that key to max_value. product = "iphone and android phones" lett_d={} for char in product: ...
true
b441d98f935367351ba393e5d2b69e6eb62fc2e4
Rider66code/PythonForEverybody
/bin/p3p_c3w2_ex_005.py
348
4.1875
4
#2. The for loop below produces a list of numbers greater than 10. Below the given code, use list comprehension to accomplish the same thing. Assign it the the variable lst2. Only one line of code is needed. L = [12, 34, 21, 4, 6, 9, 42] lst = [] for x in L: if x > 10: lst.append(x) print(lst) lst2=[x for ...
true
f1f929084315b9ca80a5ad02efb0d3ba11d556bd
Rider66code/PythonForEverybody
/bin/ex_03_03.py
730
4.4375
4
# 3.3 Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following table: # Score Grade # >= 0.9 A # >= 0.8 B # >= 0.7 C # >= 0.6 D # < 0.6 F # If the user enters a value out of range, print a suitable err...
true
a61a9dd8e303173efe651c956ba240c0c80604ad
Rider66code/PythonForEverybody
/bin/p3p_c3w1_ex_001.py
619
4.1875
4
nested2 = [{'a': 1, 'b': 3}, {'a': 5, 'c': 90, 5: 50}, {'b': 3, 'c': "yes"}] #write code to print the value associated with key 'c' in the second dictionary (90) print(nested2[1]['c']) #write code to print the value associated with key 'b' in the third dictionary print(nested2[2]['b']) #add a fourth dictionary add the ...
true
44b53d49d776e220eddc6b61ecb2b5e817233d74
Rider66code/PythonForEverybody
/bin/p3p_c3w1_ex_006.py
562
4.59375
5
#2. Below, we have provided a list of lists that contain information about people. Write code to create a new list that contains every person’s last name, and save that list as last_names. info = [['Tina', 'Turner', 1939, 'singer'], ['Matt', 'Damon', 1970, 'actor'], ['Kristen', 'Wiig', 1973, 'comedian'], ['Michael', 'P...
true
37081bfd7e273b6261e209e6710ebafab8766439
Rider66code/PythonForEverybody
/bin/p3p_c4w1_ex_005.py
1,063
4.65625
5
#Create a class called Cereal that accepts three inputs: 2 strings and 1 integer, and assigns them to 3 instance variables in the constructor: name, brand, and fiber. When an instance of Cereal is printed, the user should see the following: “[name] cereal is produced by [brand] and has [fiber integer] grams of fiber in...
true
aa008441857c91d8dc8c08f4d23a330ff62a5e00
Rider66code/PythonForEverybody
/bin/p3p_c2w3_ex_005.py
312
4.4375
4
#12. Write a function named intro that takes a string as input. Given the string “Becky” as input, the function should return: “Hello, my name is Becky and I love SI 106.” def intro(s): newstr='Hello, my name is {} and I love SI 106.'.format(s) return newstr name='Becky' x=intro(name) print(x)
true
b20cf3e97aab795c3369a0059da6867465207741
Rider66code/PythonForEverybody
/bin/p3p_c2w5_ex_007.py
370
4.28125
4
#4. Sort the following dictionary’s keys based on the value from highest to lowest. Assign the resulting value to the variable sorted_values. dictionary = {"Flowers": 10, 'Trees': 20, 'Chairs': 6, "Firepit": 1, 'Grill': 2, 'Lights': 14} sorted_values=[] for key,value in sorted(dictionary.items(),key=lambda stock:stock[...
true
5cb05183bc3130546e2d3066d9284c041644d29e
Rider66code/PythonForEverybody
/bin/p3p_c2w4_example_011.py
273
4.25
4
# this works names = ["Jack","Jill","Mary"] for n in names: print("'{}!' she yelled. '{}! {}, {}!'".format(n,n,n,"say hello")) # but this also works! names = ["Jack","Jill","Mary"] for n in names: print("'{0}!' she yelled. '{0}! {0}, {1}!'".format(n,"say hello"))
false
4d464b49cfc49a35a3dd7e6a6e8218db0b3f87ea
Rider66code/PythonForEverybody
/bin/p3p_c2w3_ex_009.py
241
4.125
4
#2. Write a function called count that takes a list of numbers as input and returns a count of the number of elements in the list. def count(x): cnum=0 for num in x: cnum+=1 return cnum nlist=(1,2,3) print(count(nlist))
true
7eff73ede7c96cb6bfad9696369029c261af97c3
rahuladream/LeetCode
/April_LeetCode/Week_1/Queue/adding_element_enque.py
638
4.1875
4
class Queue: def __init__(self): self.queue = list() def add_element(self, val): # Insert element if val not in self.queue: self.queue.insert(0, val) return True return False def size(self): # Size of queue return len(self.que...
true
ee2624e6d8dfac12498e1ef101bcb90633d0c4e4
rohanmahajan1993/pythonlibrary
/generators_iterators.py
688
4.4375
4
''' Iterators can be passed in to many built in functions and also are used in for loops. All that is required is that we have a iter method that returns an object that can has next init. Usually, one class does both. ''' class IterableObject: def __init__(self, n): self.i = 0 self.n = n def __iter__(self)...
true
d60a399e157fad6646fd6b94dcbcbf6b59cfeb45
MANOJPATRA1991/Data-Structures-and-Algorithms-in-Python
/Recursion/factorial_of_a_number.py
230
4.125
4
def factorial(num): # This is the most efficient base case as it keeps our program from crashing # if you try to compute the factorial of a negative number. if num <= 1: return 1 else: return num * factorial(num-1)
true
5d4a1145efcfe5df20efb15dd010c7116d35304e
MANOJPATRA1991/Data-Structures-and-Algorithms-in-Python
/Trees/Tree_Structure_Using_Classes/__init__.py
2,034
4.3125
4
class BinaryTree: """ Creates a Binary Tree with a root, left child and right child. Attributes: rootObj(any): The value of the root of the tree leftChild(BinaryTree): The left child of the tree rightChild(BinaryTree): The right child of the tree """ def __init__(self...
true
85cf8486dba0b0a8ea95b8eabe0de226ffb07dc2
javi12135/FreeCodeCamp-Challenges
/Scientific Computing with Python/Exercises/06 Strings/06-05_EX.py
404
4.5
4
#Exercise 5: Take the following Python code that stores a string: #str = 'X-DSPAM-Confidence:0.8475' #Use find and string slicing to extract the portion of the string after the colon character and then use the float function to convert the extracted string into a floating point number str = 'X-DSPAM-Confidence:0.8475' ...
true
5b3fa8ced6372df9c2070f4376468fcaedee4552
javi12135/FreeCodeCamp-Challenges
/Scientific Computing with Python/Exercises/06 Strings/06-03_EX.py
383
4.125
4
#Exercise 3: Encapsulate this code in a function named count, and generalize it so that it accepts the string and the letter as arguments #_def count(tocount): # count = 0 # for letter in word: # if letter == tocount: # count += 1 # print(count) word=input("What is your word?: ") tocount=in...
true
a552714cbd6f094cd8bab4e95d9d927a7a7a27c2
zamanwebdeveloper/OOP_in_Python
/92.Inheritance3.py
458
4.125
4
# Inheritance # is a relationship # Car is vehicle # Truck is vehicle class Vehicle: def __init__(self,name): self.vehicle_name = name def name(self): print(self.vehicle_name) class Car(Vehicle): def drive(self): print(self.vehicle_name,'is dirve') class Truck(Vehicle): def wheel...
false
459fdabf8b73d59e5f3e55884526fd6061e727cf
santi7779/PythonCrashCourse
/Chapter3/names.py
583
4.125
4
# friends = [ "Billy", "Bob", "Trevor", "Frank", "Oscar"] # print(friends[0]) # print(friends[1]) # print(friends[2]) # print(friends[3]) # print(friends[4]) # print(f"Hello {friends[0]} how are you?") # print(f"Hello {friends[1]} how are you?") # print(f"Hello {friends[2]} how are you?") # print(f"Hello {friends[3]} ...
false
d12289fa550924c56dd8058922640c952a3ddc3a
kaushiktalukdar/utility_Python
/inheritance/inheritance_demo4.py
805
4.3125
4
# https://www.w3schools.com/python/python_inheritance.asp class Person: def __init__(self, fname, lname): self.firstname = fname self.lastname = lname def printname(self): print(self.firstname, self.lastname) # now, have a Student class inherit Person class and with __init__ method amd super() class ...
true
b8415210ee2e6cdce020e57a6ce54e0f5da9a86f
ramasawmy/assignment
/Assignment_6.py
779
4.125
4
list_1 = [] list_2 = [] list1 = int(input("Enter the length of list_1:")) print("enter odd value in list_1:") for i in range(list1): list1_value = int(input()) list_1.append(list1_value) list2 = int(input("Enter the length of list_2:")) print("enter even value in list_2:") for j in range(list...
false
fb4554919ffb11208d378e59babd90f0d478ca73
ksm0207/Study_P
/Part#1/example02-2.py
1,943
4.1875
4
# 슬라이싱 으로 문자열 나누기 data = "20010331Rainy" day = data[:8] # data[:8]은 data[8] 이 포함되지 않습니다 weather = data[8:] # data[8:] 은 data[8] 을 포함합니다 print("20010331 = ", day) print("Rainy = ", weather) print("Year : ", data[0:4]) print("Day : ", data[4:8]) print("Weather : ", data[8:]) # 슬라이싱 연습문제 나눠서 출력하기 name =...
false
40188ed9783ccf80a57df4c9f7e1674b2003218f
sandeepgholve/Python_Programming
/Python 3 Essential Training/05 Variables/variables-dictionaries.py
539
4.125
4
#!/usr/bin/python3 def main(): d = { "one": 1, "two": 2, "three": 3, "four": 4, "five": 5 } print("Dictionaries: ", d) for k in d: print(k, d[k]) print("Sorted by Keys: ") for k in sorted(d.keys()): print(k, d[k]) print("Dictionaries are mutable objects") dd = dict( ...
false
f23d3a877daba5711631d8ebce25517164f6d0b7
CKowalczuk/Python---Ejercicios-de-Practica-info2021
/fun_ej10.py
1,424
4.28125
4
""" Ejercicio 10: Precedencia del operador Escriba una función llamada precedencia que devuelve un número entero que representa la precedencia de un operador matemático. Una cadena que contiene el operador se pasará a la función como su único parámetro. Su función debe devolver 1 para + y -, 2 para * y /, y 3 p...
false
a1ab9d4bf1738928d4e72e221703ae7eedcf4a43
CKowalczuk/Python---Ejercicios-de-Practica-info2021
/fun_ej16.py
1,645
4.125
4
""" Ejercicio 16: Dígitos hexadecimales y decimales Escriba dos funciones, hex2int e int2hex, que conviertan entre dígitos hexadecimales (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E y F) y enteros de base 10. La función hex2int es responsable de convertir una cadena que contiene un solo dígito hexadecimal en un...
false
74f998c6890376ec70bcfde78fcc5443bb6950a3
richrosenthal/Day3_Choose_Your_Own_Adventure
/main.py
1,353
4.34375
4
#Day 3 Making a choose your own Adventur game #Author Richard Rosenthal #Date 5-11-21 import time print("Welcome to escape Ikea!") user_name = input("What is your name?") print(f"Hello {user_name}") print("\nYou awake on a couch in a darken building") print("\nAs you come to your senses you realize you fell asle...
true
8475bf43520d376399d0685774af9639e64b3c37
karthikeyansa/python-placements-old
/python-day-2/prob4.py
247
4.21875
4
#4)Write a Python program to find the repeated items of a tuple.\ n=tuple(map(int,input("Enter the set of numbers separated by space: ").split())) m=[] for i in n: if i not in m: m.append(i) else: print(i,"repeated items")
true
eb0474408306e293bffdc85c3bcaea8c44500906
hungryglobe8/Games
/TrafficJam/coordinate.py
1,797
4.15625
4
class Coordinate(): def __init__(self, x, y): self.x = x self.y = y def __str__(self): ''' Print coordinate in (x, y) notation. ''' return f"({self.x}, {self.y})" def __eq__(self, other): return self.x == other.x and self.y == other.y def shift_left(sel...
false
06d1261bc25aa98aa951aa9a5a2075b152fbc330
MohammedGhafri/data-structures-and-algorithms-python
/data_structures_and_algorithms/challenges/queue_with_stacks/queue_with_stacks.py
2,331
4.25
4
from data_structures_and_algorithms.challenges.stacks_and_queues.stacks_and_queues import Node,Stack s1=Stack() s2=Stack() class PseudoQueue: """ This class create a queue with 2 stacks Has two method -till now- enqueue and dequeue """ def __init__(self): self.s1=Stack() self.s2=Stac...
false
4905790ec2556d50a4cf35d0ec8a1b7cf8dc4a30
PixElliot/andela-bc-5
/Fizz Buzz Lab.py
382
4.125
4
#!/usr/bin/env python def fizz_buzz(num): if (num % 3 == 0) and (num % 5 == 0): # If num divisible by 3 & 5 return 'FizzBuzz' elif num % 3 == 0: # If num divisible by 3 return 'Fizz' elif num % 5 == 0: # If num divisible by 5 return 'Buzz' els...
false
65a0f82d98dd8ac8b102310ba030decb8d5c0768
xingshuiyueying/NewLearner
/palindome1.py
966
4.1875
4
# 网上copy下来的,未完成要求 # 设置需要过虑的标点符号 forbidden = (".", "?", "!", ":", ";", "-", "—", "()", "[]", "...", "'", '""', "/", ",", " ") # 获取一个字符串,书中要求确认"Rise to vote, sir."是回文 text = input("请输入:") #将字符串倒过来 def reverse(text): str_tmp = [] str = "" for i in range(0,len(text)): if text in forbidden: c...
false
1a7af0f7c7a05a307648e13984082765187e8fef
dani-fn/Projetinhos_Python
/projetinhos/ex#60 - cálculo de fatorial.py
424
4.1875
4
from math import factorial n = int(input('Digite um número para saber seu fatorial: ')) sequence = 0 while sequence != 2: if n == 1 or n == 0: sequence = 2 print('!{} '.format(n), end='') else: print('!{} = '.format(n), end='') for sequence in range(n, 1, -1): ...
false
faf6eec81bb3cb2e2628495b9123f0f86ac7c229
dani-fn/Projetinhos_Python
/aulas/Aula#17-listas1.py
1,222
4.25
4
lanche = ['hamburguer', 'suco', 'pizza', 'pudim'] print(lanche) lanche[2] = 'sorvete' # São MUTÁVEIS print(lanche) lanche.append('cookie') # Adiciona no final print(lanche) lanche.insert(0, 'hot dog') # Adiciona onde eu quiser, sem tirar nada print(lanche) del(la...
false
ae2cb20b5f88cc8af74842fb577ed4601a6b904e
dani-fn/Projetinhos_Python
/aulas/Aula#7 - operadores aritméticos - anotações.py
660
4.3125
4
print('"+" Adição') print('"-" Subtração') print('"*" Multiplicação') print('"/" Divisão real') print('"**" Potenciação') print('"//" Divisão inteira') print('"%" Módulo ou resto da divisão') print('------------------------------------') #Todo operador(no caso, os operadores aritméticos), precisa de um...
false
8139dee0d7a7febfb105846a4b8bb298fadf410f
mithrandil444/Make1.2.1
/leeftijd.py
809
4.3125
4
#!/usr/bin/env python """ This script will ask you in which year you were born en calculate how old you are and in which year you will be 50 years old.. Bron : https://www.youtube.com/watch?v=7lg5BHLrw4E """ # IMPORTS import datetime __author__ = "Sven De Visscher" __email__ = "sven.devisscher@student.kdg.be" __statu...
true
817b67418e4de2ac72ab26c8686f989d29042a0f
Kotarosz727/python-algorism
/bubble_sort.py
468
4.125
4
def bubble_sort(numbers): len_numbers = len(numbers) while len_numbers > 1: len_numbers -= 1 for i in range(0, len_numbers): if numbers[i] > numbers[i+1]: numbers[i] , numbers[i+1] = numbers[i+1], numbers[i] return numbers # numbers = [2,5,1,8,7,4,3] ...
true
1d148131a8f0533658493bf9ad4de3e6f40e8ace
abdalimran/46_Simple_Python_Exercises
/28.py
324
4.1875
4
from functools import reduce def find_max(x,y): if x>y: return x else: return y def find_longest_word(words): lengths = list(map(len,words)) return (reduce(find_max,lengths)) def main(): words = input("Enter the list of words: ").split() print(find_longest_word(words)) if __name__=="__main__": mai...
true
9d7036a5b7a93956ece880558141aeb556cfebf6
maherme/python-deep-dive
/Variables_Memory/EverythingObject.py
1,007
4.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 24 20:33:42 2021 @author: maherme """ #%% a = 10 print(type(a)) # Notice a is a class b = int(10) # We can create a new class using the constructor as an integer print(b) print(type(b)) #%% # You can get some help using help(int) for example # We...
true
2588dc0d7a0f92cec88cb9d49ad448bc571d9ff8
maherme/python-deep-dive
/Extras/RandomSeeds.py
1,783
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 10 00:35:44 2021 @author: maherme """ #%% import random for _ in range(10): print(random.randint(10, 20), random.random()) #%% # Every time you reset the seed the sequence will start with the same values: random.seed(0) for _ in range(10): ...
true
26a1d204dcfbd8f918d2e4cca6f822ed84cac3cf
maherme/python-deep-dive
/Basics/for.py
1,928
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 9 23:43:32 2021 @author: maherme """ #%% # In Python, an iterable is an object capable of returning values one at a # time. # In other lenguages a for loop is similar to: for(int i=0; i<5; i++){...} # This is similar to a while loop: i = 0 whi...
true