blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
fc38561aab9f7a41243707c4942025990318dc08
jean957/eulerproblems
/prob12b.py
1,554
4.25
4
from math import sqrt print(''' The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 ...
true
dfe728d7e38f68704ff6a353776e948ce0802ce2
ew67/CSE
/notes/List Notes.py
2,489
4.46875
4
# Lists shopping_list = ["whole milk", "PC", "Eggs", "Trash (Xbox One)", "Other Trash (PS4)", "Batteries"] print(shopping_list) print(shopping_list[0]) print("The second thing in the list is %s" % shopping_list[1]) print("The length of the list is %d" % len(shopping_list)) # Changing Elements in a list shopping_list[0...
true
640811ff6a744e85fed8dbdd264aaf6c87907a63
samuei/Snippets
/String Reversal.py
556
4.53125
5
#1. Write the function that reverses a string without using explicit loops. E.g. “Hello” should return “olleH”. # For Python 2.6+ users, comment out this line. Otherwise, keep it. from __future__ import print_function def StringRev(inString): if(len(inString)>0): print(inString[len(inString) -1:], end='')...
false
9740ad504a07c6140578cd5f74b7a71ec6c1de94
13jacole/Portfolio
/Project Euler/Problem 4/BruteForce.py
1,455
4.15625
4
# Brute Force Method #Largest possible product of two 3-digit numbers = 999*999 = 998001 --> largest palindrome beneath this is 997799 #Lowest possible product of two 3-digit numbers = 100*100 = 10000 --> smallest palindrome above this is 10001 ###METHODOLOGY### # 1) Starting at 997799, decrement until palindrome. # ...
true
84e84f247770cd75bc88abc1f0056f5e141d6607
brn016/cogs18
/18 Projects/Project_yax048_attempt_2018-12-12-10-21-46_COGS 18 Final Project/COGS 18 Final Project/my_module/while_loop.py
1,263
4.21875
4
def while_loop_answer(): """Keep reporting error if the answer is not valid""" msg = input('INPUT :\t') # Check if user's answer is valid(Yes or No) if msg == 'No': print('Thank you and have a great day!') chat = False elif msg == 'Yes': print('Okay, give me a second...'...
true
80a093d763ff33c3f45228d0db2e4ccec1c87344
xXYeetMasterXx/Py_Assignments-1
/A23.py
240
4.15625
4
def sum_three(): print ("This finds the sum of three numbers") a = int(input("Enter your first number:")) b = int(input("Enter your second number:")) c = int(input("Enter your third number:")) return (a+b+c) print(sum_three())
true
c7ba44d412a32d4e129b52794b42a32e1b4e55ea
pallavidesai/PythonDeepLearningICP
/Source/CountSentence.py
368
4.1875
4
#accepts a sentence and prints the number of letters anddigits in Sentence. string = input("Please Enter Your String") digit=0 letter=0 for count in string: if count.isdigit(): digit=digit+1 elif count.isalpha(): letter=letter+1 else: pass print("Number of Letters in Sentence", lett...
true
6715d0bcff9aa51db2facf3f40be8f562180070d
venuxvg/coding_stuff
/sortarray.py
213
4.40625
4
# python program to print the array elements in ascending order inp = int(input('How many elements you want to enter:')) arr = [] for i in range(inp): n = input() arr.append(int(n)) arr.sort() print(arr)
true
7961d302423591ffd311f55ba3c6e5bbcbeed4d1
jlunder00/blocks-world
/location.py
1,323
4.1875
4
''' Programmer: Jason Lunder Class: CPSC 323-01, Fall 2021 Project #4 - Block world 9/30/2021 Description: This is a class representing a location in the block world. It has a list of the blocks it contains, keeps track of which block is on top, and has the ability to place a given block on its stack and remove on...
true
c41ccd9bcf54dfd30c84f10fd2dea166a61c6903
digitalight/Python_Crash_Course
/042-classes2.py
2,770
4.53125
5
# Starting classes and OOP # Sun 19th April 2020 # Mike Glover class Car: """A simple attempt to represent a car.""" def __init__(self, make, model, year): """Initialize attributes to describe a car.""" self.make = make self.model = model self.year = year self.odometer_r...
true
0879773c17e20ab21a9290d05e4e3ee98cb49251
digitalight/Python_Crash_Course
/031-loadsofcats.py
202
4.15625
4
pets = ['dog', 'fish', 'cat', 'cat', 'rabbit', 'cat'] print(pets) # Use while loop and not a for loop as they can't track lists or dictionaries. while 'cat' in pets: pets.remove('cat') print(pets)
true
ff8230980f768c8291ea8f3da8306dd486bf6dfd
koichi21/lintCode
/linkedList/reverse.py
1,611
4.28125
4
#!/usr/bin/python """ Reverse a linked list. """ def main(): # create a linked list a = [1,2,3] head1 = getLinkedList(a) head2 = getLinkedList(a) # check print toList(head1) # reverse test = Solution() head1 = test.reverse(head1) print toList(head1) head2 = test.revers...
true
8c698e39fad48cc366ca6390012a9f3074858796
koichi21/lintCode
/binarySearch_sortedArray/mergeSortedArray.py
905
4.28125
4
#!/usr/bin/python """ Given two sorted integer arrays A and B, merge B into A as one sorted array. """ class Solution: """ @param A: sorted integer array A which has m elements, but size of A is m+n @param B: sorted integer array B which has n elements @return: void """ def merge...
true
0296328b041b70f1ea09cf2e72c5ec51355ae4c2
redyelruc/BoringStuff
/asterisk printer.py
983
4.4375
4
# module to validate input import pyinputplus as pyip # Dictionary containing value for each row ascending through the digits (0-2) # ( with spaces after digits so they are not all clumped together led = {'row1' : ['### ', '# ', '### '], 'row2' : ['# # ', '# ', ' # '], 'row3' : ['# # ', '# ', '...
true
757cf6122e08f1e5ca2f320d607638dd328b64ed
redyelruc/BoringStuff
/CaeserCypher.py
2,120
4.4375
4
import pyinputplus as pyip # CaeserCypher - a programme of simple encrpytion and decryption of text '''asks the user for one line of text to encrypt; asks the user for a shift value (an integer number from the range 1..25 prints out the encoded text.''' # Get the message and the code shift and validate them before ...
true
b7174c39bb28f021b0177a71b9e579ad01a37bb1
carl-parrish/codeEval
/findWriter.py2
783
4.15625
4
#!/usr/bin/python """ Find a Writer You have a set of rows with names of famous writers encoded inside. Each row is divided into 2 parts by pipe char (|). The first part has a writer's name. The second part is a "key" to generate a name. Your goal is to go through each number in the key (numbers are separated by spa...
true
4b454d4524ad8d02c883008d52eab7386104ee43
Devendra1998/Python-Basics
/deva8.py
245
4.125
4
print("enter your age") print("age should be in between 7 to 70") a1=int(input()) if a1<7&a1>77: print("Re enter your age") if a1<18: print("you cant drive") elif a1==18: print("you have to come") else: print("you can drive")
false
c92f1554c408d57233767610ee681d65811c8596
sritasngh/programming
/HackerRank/practice_python/find_a_string.py
442
4.15625
4
##https://www.hackerrank.com/challenges/find-a-string/problem def count_substring(string, sub_string): counter=0 n=len(string)-len(sub_string) for i in range (n+1): if string.find(sub_string,i,i+len(sub_string))>=0: counter+=1 return counter if __name__ == '__main__': strin...
true
466f2eb29300c9e545ab454252f10743eddd53f9
parxhall/com404
/1-basics/4-repetition/3-nested-loop/1-nested/bot.py
254
4.1875
4
#input row = int(input("how many rows should i have?\n")) column = int(input("how many coulmns should i have?\n")) #for for count in range(0,row,1): for count in range(0,column,1): print(":-)", end="") print("") #finish print("Done!")
true
87dcb8b247d209eb1054917bf5cf7c9ddfcd083e
parxhall/com404
/1-basics/3-decision/03-if-elif-else/bot.py
523
4.1875
4
#ask for input paint = input("Towards which direction should I paint (up, down, left or right)?\n") #if statement if paint == "up": print("I am painting in the upward direction!\n") #else if statements elif paint == ("down"): print("I am painting in the downward direction!\n") elif paint == ("left"): print(...
true
591f0a9cd226ff94e4feea95dec3e2768abe7b8e
AshayFernandes/PythonPrograms
/Assignment/assignment1.py
1,645
4.15625
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 5 17:56:53 2019 @author: Ashay Fernandes """ """<q> Create a list and do the following manipulation 1> Find the length of the list 2>Create a new list as an element of an existing list 3>use the slice Operator 4>Replace the second element of the list with a...
true
57d8912687ccae9e6b73cc49b95dba48a718620d
morris-necc/assignments
/Week7/JCassignment.py
2,370
4.34375
4
from __future__ import annotations #for the :Car typing, this apparently won't be necessary in Python 3.10 class Company: def __init__(self, name: str, cars: list): """ name: prints the name of the company cars: a list of 'Car' objects that this company manufactures """ self...
true
5dbd45475c7408103adef7870d7f840525d4ecd8
MilapPrajapati70/AkashTechnolabs-Internship
/day 4/task 1 (4).py
593
4.28125
4
# 1. Create a class cal1 that will calculate sum of three numbers. # Create setdata() method which has three parameters that contain numbers. # Create display() method that will calculate sum and display sum. class myclass: def setdata(self,n1,n2,n3): self.n1=n1 self.n2=n2 ...
true
ca594a7d1aecdcfe3f0abd307879e51a760c4f6e
Aniketthani/Python-Tkinter-Tutorial-With-Begginer-Level-Projects
/3grid.py
244
4.3125
4
from tkinter import * root=Tk() #Creating a Label Widget mylabel1=Label(root,text="Hello World") mylabel2=Label(root,text="Hi This is Tkinter") #showing it on screen mylabel1.grid(row=0,column=0) mylabel2.grid(row=3,column=3) root.mainloop()
true
2ba201d1203a8f64019be99e509592865e887359
jessejacob19/freeCodeCampPython
/if_statements.py
264
4.125
4
is_male = True is_tail = False if is_male and is_tail: print("you are a tall male") elif is_male and not(is_tail): print("you are a short male") elif not(is_male) and is_tail: print("you are not a male but are tall") else: print("you are neither")
false
e13507bd91d0478fa5170214daef004e7d567d2c
GarethAn/LeetCode
/No575_Distribute Candies/Python_Solution.py
1,340
4.1875
4
# -*- coding: utf-8 -*- # Renyi Hou. 23/6/2017 题目: Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these candies equally in number to brother and sister. Return the maxi...
true
6632e1092655ba9d4f79afd6bd4e95f0a84b3f62
yanbin0061/TensorFlow
/MyPython/functionTest.py
1,693
4.59375
5
""" 定义函数的规则 1.函数代码快以def开头, 后面接标识符合圆括号 """ def hello(): print('Hello world!') hello() # 计算矩形的面积 def area(width, height): return width * height def print_welcome(name): print("Welcome", name) print_welcome("闫斌") w = 4 h = 5 print("width:", w, "heigh:", h, "area = ", area(w, h)) # 定义函数 def p...
false
76813266c3c4b73bd2f167b312a0c46bd7f11a28
omaskery/yellow-lama
/material/conceptual/exercises/comparison.py
1,275
4.1875
4
#!/usr/bin/python import unittest # # This example involves writing a simple 'comparison' function # # The input will be two integers, a and b # If a is greater than b, the output should be "greater" # If a is less than b, the output should be "lesser" # If a is equal to b, the output should be "equal" # def compare...
true
ac1929211392f6252c10706a8ac93615d11fe217
elephannt/PythonTrain
/10-ExamenU2/ExamenPT2.py
708
4.125
4
#!/usr/local/bin/python # -*- coding: utf-8 -*- ##Diferentes ##list1, list2 = ["Verde","Rojo","Morado","Azul","Negro","Blanco","Rosa","Anaranjado"], ["Plateado","Guinda","Dorado","Menta","Gris","Lila","Amarillo","Crema"] ##Iguales list1, list2 = ["Verde","Rojo","Morado","Azul","Negro","Blanco","Rosa","Anaranjado"],...
false
3d52ecf60924f61ebc963ca04aa462b8345e8c9e
YellowDust/Projects
/Solutions/prime_factor.py
609
4.3125
4
"""Prime Factorization - Have the user enter a number and find all Prime Factors (if there are any) and display them.""" #Check if the number is prime. def is_prime(n): if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True input = int(raw_input("Enter a ...
true
b30c7ff4d25a8ca82ee30391453a81dce452307b
bravestone831/fundamental-python
/if.py
720
4.125
4
#if语句是自上而下判断,也就是说,if遇到第一个满足条件(判断为true)的语句, #就停止下面所有的判断(跳出if) s = int(input('Please enter your age:')) if s >6: print('teen') elif s >18: print('you\'re old') else: print('kid') birth = int(input('birth: '))#input返回是str,不能和2000这个整型比较,所以加int if birth < 2000: print('00前') else: print('...
false
cb3b03645efb41d5ec0abf9351ed165b0d2d0755
johannest18/timi409
/max_int.py
763
4.125
4
#taka við heiltölum í input num_int = int(input("Input a number: ")) # Do not change this line #Láta forritið muna eftir tölunni max_int = num_int #Ef að ekki er skráð inn jákvæð heiltala (0 meðtalinn) þá er hún hæsta talan og skal því prenta hana út. #Aftur skal biðja um heiltölu í input. # Ef hún er hærri en hæsta...
false
241da34541380a455a71fe0ba5e4f2518beac801
tianqing617/PythonStudy
/advancedUsage/generator.py
1,069
4.15625
4
# -*- coding: utf-8 -*- # generator的演变 # 使用场景:当一个List有很多个元素,而这些元素是可以通过计算得到的,此时可以使用generator。 # 例如:[1, 2, 3, 5, 8, 13, 21, ...]这个list是前后者是前两个的和。 # generator的演变过程 # 斐波拉契数列(Fibonacci),除第一个和第二个数外,任意一个数都可由前两个数相加得到: def fib(max): n, a, b = 0, 0, 1 while n < max: print(b) a, b = b, a + b n = n + 1 return...
false
113783d42b3836722d6d49d4ea7be02140abf0a4
fengxia41103/myblog
/content/downloads/euler/p4.py
762
4.25
4
# -*- coding: utf-8 -*- """A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ import itertools def is_palindromic(n): """Test n to be palindromic numb...
true
881657859f1ba39f3ead2a37ff25d54ccf6792ef
DarrenVictoriano/Python-Mastery
/Data_Structures/Singly_LinkedList/simple_singly_list.py
1,429
4.25
4
""" This is a simple singly linked list implementation from the book Elements of Programming Interview in Python. """ class ListNode: """ simple singly list self.data = data self.next = ListNode() """ def __init__(self, data=0, next_node=None): self.data = data self.next = nex...
true
fc859aa037ccb3206f4ced07d6397179899a68eb
sangeetameena580/Algo-DS
/Python/Misc/reverse_integer.py
822
4.3125
4
# Python Program to Reverse a Number using Functions def Reverse_Integer(num): rev = 0 sign = 1 if num < 0: num = -num sign = -1 while(num > 0): rem = num %10 rev = (rev *10) + rem num = num //10 return rev*sign num = int(input("Please Enter any Number: ")) ...
true
a68d1965b9ae8172a9f003b64770ff008ef12ce2
HLOverflow/school_stuffs
/Year2/Algorithm/mergesort.py
945
4.1875
4
# python 2 def mergesort(array): low = 0 high = len(array) - 1 mid = (low + high)/2 if (len(array)==1): return array else: array1 = mergesort(array[: mid+1]) array2 = mergesort(array[mid+1:]) return merge(array1, array2) def merge(array1,array2): #print...
false
b4d65cdefd0cf5eabd1a7446bcab010029a97227
kaistreet/python-text-manipulation
/palindrome_checker.py
784
4.53125
5
""" This script checks if a string is a palindrome. Author: Kai Street Date: 22 September 2019 """ def reverse(palindrome_checker): """ This function reverses a string and returns reversed string Author: Kai Street Date: 22 September 2019 Parameter palindrome_checker: a string to reverse Precondition: palind...
true
2a9655b037f4221066dc559bb2258e53f82deaf6
lfamarantine/Baruch-CIS-2300
/assignments/homework_4.py
2,436
4.34375
4
""" Write a program that asks the user to enter the number of hours they worked for in a given week. Number of hours entered should be in the range of 0 to 60. Also ask user to enter their pay rate. It should be a positive value above minimum wage (Assume minimum wage of $15). Your program should ask user to re-enter t...
true
606347a6cd7bb473379ed8e400c51c7c9eebdf4a
AndrewMatos/Random-Python-code
/car_class.py
1,389
4.3125
4
class Car: """A simple attempt to represent a car.""" def __init__(self, maker, model, year): """ Initialize attributes that describe a car """ self.maker= maker self.model= model self.year= year self.odometer_reading = 0 def get_descriptive_name(self): """ return a neatly formate descriptive name. """...
true
f713cd35248786f079e472e1c8115b363ed27a20
RohanPatil1/Programming_Problems_Solutions
/Basic Recursion/x_to_the_power_ n.py
238
4.1875
4
""" Write a program to find x to the power n (i.e. x^n). Take x and n from the user. You need to return the answer. Do this recursively. """ def power(x,n): if (n==1): return 1 return x*power(x,n-1) print power(2,5)
true
ffc466ff535b629ec05cf28615818378d0a9e8fb
BilalAhmedim/learn-python
/list/list_and_method.py
793
4.21875
4
# Declare Empty List list = ['0','1', '35', '449', '0'] # insert Method list.insert(0,'2') # insert 2 at location of 0 in the list # Modify list list[0] = '1' # insert item using append method at the last of the list # apppend metho use to add item at end of the list list.append('2') # delete item usin...
true
9db683d8b067434b88efd33b4bffcc4dda485d6e
JasonPBurke/Intro-to-Python-class
/Lab_7/Jason_Burke_Lab7b.py
1,929
4.375
4
# This program allows you to input and save student # names to a file #set a constant for the number of students student_no = 12 def main(): #create an empty list students = [] #create an accumulator and prime the while loop count = 0 #get the user to add students to the list if they ...
true
4480a541fb8e77509eb16de5983cda2b8a17bb6d
JasonPBurke/Intro-to-Python-class
/Lab_8/Jason_Burke_Lab8b.py
2,217
4.6875
5
# This program will allow a user to enter a date in # numeric format. It will test the month, day, and # year and have the user correct if errors are found. # It will then output the date in long date format. # Import the calander module to assist with renaming # months entered by the user. import calendar def main(...
true
4c43fe88fa960ecf2c92d6e070827a7f9e275301
harshadak/fun-functions
/index.py
934
4.125
4
# Odd/Even: def odd_even(): for i in range(1, 2001): if i % 2 == 0: print "Number is {}. This is an even number.". format(i) else: print "Number is {}. This is an odd number.". format(i) odd_even() # Multiply: def multiply(arr,num): for x in range(len(arr)):...
false
43f62555fd78c01351a434309368a3a6121509a4
sindredl/temp
/temp/mystuff/33-sim.py
769
4.1875
4
# -*- coding: utf-8 -*- numbers = [] def looping(number, increment): i = 0 while i < number: print "At the top i is %d" % i numbers.append(i) i = i + increment print "Numbers now: ", numbers print "At the bottom i...
true
e1acadcbb37a8de7e990553ab34dbfe1ed6e0cf8
JollenWang/study
/python/python_prj/using_tuple.py
516
4.125
4
#!/usr/bin/python # Demo of using tuple zoo = ('wolf', 'elephant', 'tiger', 'monkey', 'eagle') new_zoo = ('horse', 'cat', zoo) print('Number of animals in the zoo is:', len(zoo)) print('Number of animals in the new zoo is:', len(new_zoo)) print('All animals in the new zoo are:', new_zoo) print('Animals broug...
false
671d3ba572e8b16bb873239f61c61f556171342f
Ilya-Merkulov/ProjectEuler
/problem_1.py
647
4.28125
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. """ # my first result def multiples(a, b): sum = 0 for i in range(1, 1000): if i % a == 0 or i % b == 0: ...
true
cfc3af19e0fcb8f3da09e352057c238ee26d48bc
jc451073/workshops
/Prac02/ASCII.py
241
4.15625
4
lower = 10 upper = 100 print("Enter a number (" + str(lower) + "-" + str(upper) + "):") str = "Enter a number {} - {}:".format(lower, upper) print(str) for i in range(lower, upper): print("ASCII code for {} char is {}".format(i, chr(i)))
true
d1cacc95f1e12d055c4b32b7a2beddda33860080
adebraine/Project-Euler-Fun-Pastime
/Q09.py
604
4.125
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 18 22:16:55 2018 @author: Adebraine """ """ A Pythagorean triplet is a set of three natural numbers, a<b<c, for which a^2+b^2=c^2 For example, 3^2+4^2=9+16=25=5^2. There exists exactly one Pythagorean triplet for which a+b+c=1000. Find the product abc. """ n = 1000 ...
false
1197259909b840cb2df84d79e1c6510fdee195cc
MiaZhang0/Learning
/QuestionTypes/demo56.py
512
4.21875
4
#将三个全英文字符串(比如,‘ok’,‘hello’,‘thank you’)分行打印,实现左对齐、右对齐和居中对齐效果 a = ['ok','hello','thank you'] #len_max为最长字符串的长度 len_max = max([len(item) for item in a]) for item in a: print('"%s"'%item.ljust((len_max))) print('------------------------------------') for item in a: print('"%s"'%item.rjust(len_max)) print('--------...
false
300c20c47f79a629bcd3d42e7c293a304602ea10
MiaZhang0/Learning
/numpy_practice/demo01.py
719
4.15625
4
#利用numpy模块将列表转化为数组,并对数组进行运算 import numpy as np list = [[1,2,3],[4,5,6],[7,8,9]] #将二维列表转换成二维数组 array = np.array(list) print(array) #计算每一行的和,结果是3行1列的矩阵,瘦axis=1 sum = [] for row in range(3): sum.append(np.sum(array[row,:])) print(sum) sum1 = array.sum(axis=1) print(sum1) sum2 = np.sum(array,axis=1) print(sum2) #计算每...
false
24e0e3d6cc783635f5b265966406441feec11d15
kburchfiel/cdfcurve
/cdfplot.py
1,674
4.1875
4
#Program for plotting both the normal distribution and its corresponding cumulative density function #Helpful references included: #http://home.ustc.edu.cn/~lipai/auto_examples/plot_exp.html #https://courses.csail.mit.edu/6.867/wiki/images/3/3f/Plot-python.pdf #https://matplotlib.org/tutorials/introductory/pyplot.html...
true
246b8c45ddb3440c4ca86e91939a391aaa41bf47
WhosGotFrost/ATOM_DEV
/python/calulator.py
687
4.4375
4
#A simple calulator #try catch will catch an error if number or number2 is not a number try: number = int(input('Enter first number: ')); number2 = int(input('Enter second number: ')); operator = input("Enter a operator: "); #checks if the users added a valid operator. if(operator == "+"): pri...
true
ce795a7fd4bca9356b1181a677884e5320dc5e17
george39/hackpython
/funciones/calculadora.py
1,483
4.125
4
#!/usr/bin/env python #_*_ coding: utf8 _*_ def sumar(valor1, valor2): print("La suma es: {}".format(valor1 + valor2) ) def restar(valor1, valor2): print("La resta es: {}".format(valor1 - valor2) ) def dividir(valor1, valor2): print("La division es: {}".format(valor1 / valor2) ) def multiplicar(val...
false
8fa937db9b2277aadfa63d09681d282c28022248
bryandngo/PFB2017_problemsets
/elifpython.py
365
4.15625
4
#!/usr/bin/env python3 count = 20 if count < 0: message = "is less than 0" print(count, message) elif count < 20: message = "is less than 20" print(count, message) elif count > 20: message = "is greater than 20" print(count, message) elif count != 20: message = "NOT TRUE" print(count, message) else: ...
true
6b78dd87374d09e7f8639111d2581ee826f81582
Evilzlegend/Structured-Programming-Logic
/Chapter 07 - File Handling and Applications/Coding Snippets/Python/Reading Text with the read Method.py
1,417
4.6875
5
# TOPIC SUMMARY: # Once a file is opened for reading, we can get all the text from it in one # step using the file object's "read" method. This method reads the whole # file in one step. Once the text is read from a file, it is just a long string, # and Python's string manipulation tools may be applied to it. # ...
true
a24f595dbf3e0afdcae9891cad266e7747116ed7
Evilzlegend/Structured-Programming-Logic
/Chapter 07 - File Handling and Applications/Instructor Demos/read_emp_records.py
833
4.15625
4
# This program displays the records that are # in the employees.txt file. # Open the employees.txt file. empFile = open("employees.txt", 'r') # Read the first line from the file, which is # the name field of the first record. name = empFile.readline() # If a field was read, continue processing. while name...
true
deb9147894d3e9e261076ed1d30e973e0d7f5de7
Evilzlegend/Structured-Programming-Logic
/Chapter 02 - Elements of High Quality Programs/Coding Snippets/Python Codes/Strings in Python.py
1,526
4.5
4
# Topic Summary: # A string is a piece of text that is data in a program. In Python, # you can use single quotes or double quotes to mark the boundaries # of a string, so long as you use the same symbol at start and end: # 'a simple string', "another string" # TOPIC EXPLANATION: # Inside a string you can put an...
true
1dcdfba0c9fea904e2fba364e7e25f72b35e4d3f
Evilzlegend/Structured-Programming-Logic
/Chapter 06 - Arrays/Mindtap Assignments/List Basics in Python.py
2,368
4.53125
5
# SUMMARY # In this lab, you complete a partially prewritten Python program that uses a list. # The program prompts the user to interactively enter eight batting averages, which the pgoram # stores in an array. It should then find the minimum and maximum batting averages stored in the # array, as well as the aver...
true
c5d7058c8a4059ea04286c2f81112c868a1e5f89
Evilzlegend/Structured-Programming-Logic
/Chapter 10 - Object-Oriented Programming/D2L Assignments/joshua_tiemens_CH10PE1.py
2,657
4.3125
4
# importing the class wages to import wages # defining the main function here. def main(): # Disclaimer of what the program does. print("The program will create a class storing an employees name and calculates weekly pay for the employee.") print() # Initializer to start the class engagement...
true
e95249b190c21316fb2fbc093819c26174ae73eb
Evilzlegend/Structured-Programming-Logic
/Chapter 06 - Arrays/D2L Assignments/joshua_tiemens_CH6PE2.py
1,937
4.3125
4
# Explain what the program does. print("") # Break to display a clean presentation. print("This program will take a user supplied series of numbers and provide the Low, High, Total, and Average of the numbers input.") print("") # Break to display a clean presentation. # Declarations notQuit = "Y" numCount = [] ...
true
acf6eb3f92acad7428210099fc4921fd898aed27
Evilzlegend/Structured-Programming-Logic
/Chapter 09 - Advanced Modularization Techniques/MindTap Assignments/Passing Lists to Functions.py
1,348
4.6875
5
""" Passing Lists to Functions Summary In this lab, you complete a partially written Python program that reverses the order of five numbers stored in a list. The program should first print the five numbers stored in the array. Next, the program passes the array to a function where the numbers are reversed. Fina...
true
e5635433b38bc930e7d170d1e4ed483d19e7fedd
Evilzlegend/Structured-Programming-Logic
/Chapter 09 - Advanced Modularization Techniques/MindTap Assignments/Writing Functions that Return a Value.py
1,675
4.375
4
""" Writing Functions that Return a Value Summary In this lab, you complete a partially written Python program that includes a function that returns a value. The program is a simple calculator that prompts the user for two numbers and an operator ( +, -, *, or / ). The two numbers and the operator are passed to...
true
29f514a870e85f54f02384c1eaf6b4dfc607ef8c
Evilzlegend/Structured-Programming-Logic
/Chapter 02 - Elements of High Quality Programs/Coding Snippets/Python Codes/Arithmetic Shortcuts for Updating Variables.py
1,264
4.59375
5
# TOPIC SUMMARY: # We often update the value of a variable by applying some arithmetic operation to its old value. The # simplest case of this is incrementing or decrementing the value of a variable. Python provides a special # assignment operation to make incrementing and shorter to write. Instead of writing x = x ...
true
862accd5cb643fdf7e89cbc0614144e2bd50abf0
Ayesha116/official.assigment
/grading.py
851
4.125
4
print(input("enter your name ")) a = int(input("Enter your physics marks ")) b = int(input("Enter your mathematics marks ")) c = int(input("Enter your english marks ")) d = int(input("Enter your chemistry marks ")) e = int(input("Enter your urdu marks ")) Total_marks = a + b + c + d + e percentage = (Total_marks/500)*1...
false
6d39b9d412c6ac361b84e688ba939735502d7f66
Ayesha116/official.assigment
/ques42.py
259
4.1875
4
n = int(input("enter no of rows: ")) for rows in range(1, n+1): for columns in range (1 , rows+1): print(columns, end = "") print() for rows in range(n, 0, 1): for columns in range (rows-1,0,1): print(columns, end = "") print()
true
c7e63f0779360106e8178017dee9bc97b270477c
mikeplimo/finalproject17
/day32rocket.py
953
4.375
4
from math import sqrt class Rocket(): # Rocket simulates a rocket ship for a game, # or a physics simulation. def __init__(self, x=0, y=0): # Each rocket has an (x,y) position. self.x = x self.y = y def move_rocket(self, x_increment=0, y_increment=1): # Move the rocke...
true
f48bbfb02624f2fc16d077b19eb87bae67a3203d
japablaza/python
/2018/exercises/string_find.py
352
4.28125
4
#!/usr/bin/python3 a = ("No tengo idea cuantos caracteres tienes esta oracion, esta, esta") print(a) if "idea" in a: print("Esa palabra existe") else: print("la palabra idea no se encuentra") print("Encuentra la posicion de la palabra -esta-: ") c = input() b = a.find("c") print("La palabra que buscas se encuent...
false
f8028a5f18f1fc7b3cf4e6bff38b1a4a90e29226
VaibhavEng/PYTHON-CODES
/curd using list project +++++++++++++++++++++++++++++++.py
2,337
4.15625
4
student_name=[] while True: print("""select a option form the below menu: 1.Inserting one name 2.Inserting multiple names 3.Updating an exisiting name 4.deleting a name 5.view all the names 6.quit the program""") ch = int(input("enter your choice:")) if ch==1: #pass means nothing / there ...
true
73a3555b40047afa7c831d08259ae7da918c81b7
190599/ITP
/Chocolate machine.py
1,233
4.15625
4
#Enter the Price of the Chocolate bar) vPrice=float(input("Please enter the price of the chocolate you want:")) print(vPrice) #Enter the Cash to pay for hte chocolate vCash=float(input("Please enter the cash of the chocolate you want:")) print(vCash) ##Calculat the Change DUe vChangeDue=vPrice-vCash vChangeGiven=roun...
true
12c1a9be466a23ddedbaa35527e086a5bb0c9229
DragaDoncila/AssignmentOneCP1404
/DictionariesSetsPractice.py
1,495
4.1875
4
# contacts = {'bill': '353-1234', 'rich': '269-1234', 'jane': '352-1234'} # # print(contacts) # # print(contacts['bill']) # # print(contacts['jane']) # # contacts['barb'] = '271-1234' # # print(contacts) # # demo = {2: ['a', 'b', 'c'], (2,4): 27, 'x': {6: 2.5, 'a':3}} # # print(demo) # # print(demo[2]) # # print(demo[(...
false
826b097b15c73e156b264044e395178e1ec38d39
nmazzilli3/Intro_to_Self_Driving_Cars_Nanodegree
/Vehicle_Motion_Control/lesson2/int_acc_data.py
2,115
4.125
4
''' What to Remember Once again, don't try to memorize this code! The key thing to remember is this: An integral accumulates change by calculating the area of lots of little rectangles and summing them up. ''' from helpers import process_data, get_derivative_from_data from matplotlib import pyplot as plt PARALLEL_PA...
true
43f65417df793810d673e87d36aea7fb4aae1e84
dlavareda/Inteligencia-Artificial
/Ficha 1/5.py
1,436
4.25
4
""" A biblioteca numpy é muito útil para processamento matemático de dados (tipo matlab). Para a podermos usar devemos fazer o seguinte import: import numpy as np Agora podemos criar, por exemplo, um array 7x3 (7 linhas e 3 colunas) inicializado a zero com: a = np.zeros([7,3]) Escreva um programa um programa que peça a...
false
9e025c24d6aa536a3aaa130cc8b47cfbfc41929e
chihyuchin/SC-projects
/SC-projects/weather_master/weather_master.py
1,472
4.375
4
""" File: weather_master.py ----------------------- This program should implement a console program that asks weather data from user to compute the average, highest, lowest, cold days among the inputs. Output format should match what is shown in the sample run in the Assignment 2 Handout. """ # Type this number to st...
true
6458a883981897f05204794b775e85f223e3b818
alwinmreji/ROS-and-ML
/Assingment_#1/#5_factorial.py
269
4.125
4
######################################################## #Factorial of a number a = int(input("Enter the decimal number:\t")) mul = 1 for i in range(1,a+1): mul*= i print("Factorial of ",a,"is",mul) #OUTPUT: # Enter the decimal number: 5 # Factorial of 5 is 120
false
f2f959acff77d888078a28b430b00dde9b58697a
alwinmreji/ROS-and-ML
/Assingment_#1/#8_largest_among_three.py
343
4.375
4
###################################################### #Find largest among three print("Largest value ",max(int(input("Enter the first number: ")),int(input("Enter the second number: ")),int(input("Enter the third number: ")))) # OUPUT: # Enter the first number: 1 # Enter the second number: 6 # Enter the third number...
true
345d8324e1fa0d1541e86f27ae92275d2aaf79c3
alwinmreji/ROS-and-ML
/Assingment_#2/#1_max_outof_two.py
270
4.125
4
def maximum(x,y): if x>y: return x else: return y x = float(input("Enter first variable:\t")) y = float(input("Enter second variable:\t")) print("Greatest is ",maximum(x,y)) # OUTPUT # Enter first variable: 4 # Enter second variable: 5 # Greatest is 5.0
true
fdc907963bb826fdcdbd01693ec53ba97fe8b65c
alwinmreji/ROS-and-ML
/Assingment_#1/#9_smallest_in_list.py
302
4.15625
4
##################################################### #Find the smallest in the list a = int(input("Enter the number of terms:\t")) lst = [] while(a): lst.append(int(input())) a-=1 print("Minimum value",min(lst)) # OUTPUT: # Enter the number of terms: 5 # 3 # 2 # 8 # 6 # 1 # Minimum value 1
true
50c582d49f1918149df308d773d4a85172e47624
NBakulin/PythonStaff
/Lists/Lists.py
1,518
4.1875
4
class Node: def __init__(self, value): self.value = value self.next = None class LinkedList: def __init__(self): self.head = None def push(self, node): node.next = self.head self.head = node def sortedPush(self, node): if self.head is None: ...
false
394d7439a3f6e992d32cf5f16bf65899bfbee3d1
udayreddy026/pdemo_Python
/logical_aptitude/08-04-2021/Palindrome.py
430
4.15625
4
num = int(input("Enter a number:::")) temp = num res = 0 while num > 0: l_num = num % 10 # Getting Last number from user entered number its remainder num = num // 10 # Getting coefficient of number will become it means except last number remaining number will # stored in num res = (res*10)+l_num #print(r...
true
f62481278b39b3fa0e048a5caa09331efed3a486
shubham3796/ML_Introductory
/tryExceptSmallestLargest.py
689
4.25
4
largest = None smallest = None list = [] while True: num = input("Enter a number: ") if num == "done" : break try: number = int(num) except: print("Invalid input") continue list.append(number) print(list) for n in list: if largest is None: ...
false
853d13a6160712656d249958dc1d8e9b82d9dce5
duncanmichel/Programming-Problem-Solutions
/LeetCode/NumberOneBits.py
1,684
4.40625
4
""" Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight). Example 1: Input: 00000000000000000000000000001011 Output: 3 Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits. Example 2: Input: 00000000000...
true
65612bb67a0b106453dc7b4d4a9a9593426f70d4
pritamksahoo/III-IV-YEAR-Assignments
/BIO/triplets.py
1,143
4.125
4
no_char, pair = 4, 3 dict_char = {'a':0, 'c':1, 'g':2, 't':3} class Triplet(object): ''' Trie data structure to store triplets and their frequencies ''' def __init__(self): super(Triplet, self).__init__() self.freq = 0 self.children = [None for i in range(no_char)] def add_to_suffix_tree(triplet, part):...
true
9ec46eed13310d3a71be627e182d7d526313d2fa
em55/Python-exercises
/eight12.py
501
4.53125
5
"""This program takes a word and encrypts it usgin the ROTn method rotating the letters of the word n times""" #must be modified to rotate only alphabets, now it rotates among all ascii characters def rotate_word(s, n): char = "abcdefghijklmnopqrstuvwxyz" a = '' for c in s: a += char[(char.index(c)+n) % 26 ] ret...
true
bc9a6559e9e47ffd6604a8b69e3336f42b7926d3
em55/Python-exercises
/five3.py
385
4.21875
4
import math def check_fermat(a,b,c,n): if n>2: if (math.pow(a,n)+math.pow(b,n)) == math.pow(c,n): return "Holy smokes, Fermat was wrong!" return "No, that doesn't work" def main(): a = int(raw_input("Enter value a: ")) b = int(raw_input("Enter value b: ")) c = int(raw_input("Enter value c: ")) n = int(ra...
false
75ead60db9b7143f0a933fd20babeeca554cf1f4
em55/Python-exercises
/six2.py
290
4.15625
4
import math def hypo(a,b): c = math.sqrt(a**2+b**2) return c side_a = int(raw_input("Enter the length of side a of the triangle: ")) side_b = int(raw_input("Enter the length of side b of the triangle: ")) print "The hypotenuse of the right triangle is of length:", hypo(side_a, side_b)
true
fa860381fccfa267ece78f4fc2ec7edc8ca79be8
godinenbicicleta/IntroComputation
/SimpleAlgorithms/exhaustiveEnumeration.py
1,102
4.125
4
# -*- coding: utf-8 -*- # find the cube root of a perfect cube x = int(input('Enter an integer: ')) ans = 0 while ans**3 - abs(x) < 0: #this is de decrementing function ans = ans + 1 if ans**3 != abs(x): print( x, 'is not a perfect cube') else: if x < 0: ans *=-1 print( f'Cube root of {x} ...
true
06f38a305660d4b5f3193c6fccb41ee01810aaf8
godinenbicicleta/IntroComputation
/handlingExceptions/stringMethods.py
515
4.40625
4
# some useful string methods in python: s = 'hola bruno como estas - ' print('s = ',s) # counts how many times s1 occurs in s print('s.count("o") = ',s.count('o')) # returns index of first occurrence print('s.find("o") = ', s.find('o')) # same as find but from the right print('s.rfind("o") = ', s.rfind('o')) # prin...
false
da8c9fd68bc9ff81d934c94b63aaa31665b64674
jan-wo/data-cheatsheet
/pandas_missing_data.py
896
4.1875
4
""" This is small tutorial about what to do with the missing data. """ import pandas as pd import numpy as np # Fake data with missing values data = {'a': [1, 2, np.nan], 'b': [4, np.nan, np.nan], 'c': [3, 2, 1]} # Data frame: df = pd.DataFrame(data) # ------------------------ Dropping rows/columns -----------...
true
d53e50a5abb31e42a4ec079f82399f68028a3862
purvesh-patel/HackerRank
/printString.py
344
4.34375
4
# The included code stub will read an integer,n from STDIN. # # Without using any string methods, try to print the following: # 1234...n # Note that "..." represents the consecutive values in between. # # Example n = 5 # Print the string 12345. n = 5 string ="" for i in range(1,n+1): #print(i) string = string...
true
33403bd7ba0a7203ced5d88e8c660a91d5971e12
league-python-student/level1-module4-ezgi-b
/_01_dictionaries/_a_dictionaries_demo.py
2,696
4.625
5
""" Demonstration of dictionaries """ # Dictionaries are data structures that hold pairs of items. For example: # p_table = {1 : 'Hydrogen', 2 : 'Helium', 3 : 'Lithium', 4 : 'Beryllium'} # # The dictionary p_table contains 4 pairs of items, separated by commas, with # the first one being 1 : 'Hydrogen'. # The first ...
true
571844d871608fee02b41c6ab3a6fe5451b50554
shanjidakamal/csci127-assignments
/hw_05/hw_05.py
1,416
4.25
4
'''Write a function filterodd(l) that takes in a list and returns a new list that consists of only the odd numbers from the original list. That is the list [1,2,3,4,5,6,7,8] would return a new list [1,3,5,7]. The lists don't have to be in order.''' l=[1,2,3,4,5,6,7,8,9,10,11,12] def filterodd(l): newlist=[] f...
true
1da2e6db32fd5cd7bf80126001b7c8a8031aa832
zhouxiongh/cookbook
/3_date-and-time/3.3.py
366
4.15625
4
""" 你需要将数字格式化后输出,并控制数字的位数、对齐、千位分隔符和其他的细节 """ if __name__ == "__main__": x = 1234.56789 print(format(x, '0.2f')) print(format(x, '>10.1f')) print(format(x, '<10.1f')) print(format(x, '^10.1f')) print(format(x, ',')) print(format(x, '0.2E')) print(format(x, 'e'))
false
a343e782ddd97f129d666740cc06495109f2fb0b
zhouxiongh/cookbook
/7_fun/7.7.py
864
4.3125
4
""" 你用 lambda 定义了一个匿名函数,并想在定义时捕获到某些变量的值。""" if __name__ == "__main__": x = 10 a = lambda y: x + y x = 20 b = lambda y: x + y print(a(10)) print(b(10)) # lambda 表达式中的 x 是一个自由变量,在运行时绑定值,而不是定义时就绑定 # 因此在调用这个 lambda 表达式的时候,x 的值是执行时的值 # 如果你想让某个匿名函数在定义时就捕获到值,可以将那个参数值定义成默认参数即可 x = 10 ...
false
be93040a2768146375a5f9e28063d5800a2ce225
zhouxiongh/cookbook
/3_date-and-time/3.12.py
589
4.28125
4
""" 你需要执行简单的时间转换,比如天到秒,小时到分钟等的转换。 """ if __name__ == "__main__": from datetime import timedelta, datetime a = timedelta(days=2, hours=6) b = timedelta(hours=4.5) c = a + b print(c.days) print(c.seconds) print(c.seconds / 3600) print(c.total_seconds() / 3600) a = datetime(2012, 9, 2...
false
8e85ee56f90bdb0d623cf1cb772dc12fd42aae50
nicolecpeoples/python-basics
/strings.py
214
4.125
4
""" Built in functions .capitalize() .format() .lower() .upper() .swapcase() .find() .replace() """ first_name = "nicole" last_name = "peoples" print "Your name is {} {}".format(first_name, last_name).upper()
false
cb86e69bca028a95afc36491a1d75aaf522639e3
nicolecpeoples/python-basics
/assignments/grades.py
459
4.125
4
count=10 while count > 0: print "What is your grade?" grade = raw_input() if grade >= "90": print "Score: " , grade, "; Your grade is a A" elif grade >= "80": print "Score: " , grade, "; Your grade is a B" elif grade >= "70": print "Score: " , grade, "; Your grade is a C" elif grade >= "60": print "...
true
eb63bba945e75b3d1d897fb37b9ecc3b705b7829
claraj/web-autograder
/grading_module/example_assignments/example_python_assignment/lab_questions/q3_which_number_is_larger.py
787
4.40625
4
# Question 1: if-else in a function. Which number is larger? def main(): # You don't need to modify this function. a = input('Enter one number: ') b = input('Enter another number: ') compare = which_number_is_larger(a, b) if compare == 'same': print('The two numbers are the same') ...
true
c30dfd8de5ecd8153fdbcca2ec7183e74c92a1ab
claraj/web-autograder
/grading_module/example_assignments/example_python_assignment/lab_questions/Loop2fun.py
2,015
4.21875
4
""" NOTE Chapter 3 lab (Lab 6) & Homework assignments are redesigns of previous programs, to follow the new IPO structure.​ Use the code from the Loop-2 program from last time You will create functions called main(), inputNumbers(), processing(), and outputAnswer(). The old program and new program will have a simila...
true