blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
78c6cd735ab26eabf91d6888118f9e5ec1320ccf
denrahydnas/SL9_TreePy
/tree_calc.py
746
4.28125
4
# Step 1 # Ask the user for their name and the year they were born. name = input("What is your name? ") ages = [25, 50, 75, 100] from datetime import date current_year = (date.today().year) while True: birth_year = input("What year were you born? ") try: birth_year = int(birth_year) except Valu...
true
528a622f441ed7ac306bc073548ebdf1e399271e
prabhus489/Python_Bestway
/Length_of_a_String.py
509
4.34375
4
def len_string(): length = 0 flag = 1 while flag: flag = 0 try: string = input("Enter the string: ") if string.isspace()or string.isnumeric(): print("Enter a valid string") flag = 1 except ValueError: prin...
true
604a599edc09ff277520aadd1bb79fb8157272ee
pallu182/practise_python
/fibonacci_sup.py
250
4.125
4
#!/usr/bin/python num = int(raw_input("Enter the number of fibonacci numbers to generate")) if num == 1: print 1 elif num == 2: print 1,"\n", 1 else: print 1 print 1 a = b = 1 for i in range(2,num): c = a + b a = b b = c print c
true
ca5d8a47171f6b1fbc2d53f6648da8f0a6b9e900
km1414/Courses
/Computer-Science-50-Harward-University-edX/pset6/vigenere.py
1,324
4.28125
4
import sys import cs50 def main(): # checking whether number of arguments is correct if len(sys.argv) != 2: print("Wrong number of arguments!") exit(1) # extracts integer from input key = sys.argv[1] if not key.isalpha(): print("Wrong key!") exit(...
true
b87e9b3fa5910c2f521321d84830411b624e0c39
SDSS-Computing-Studies/005a-tuples-vs-lists-AlexFoxall
/task2.py
569
4.15625
4
#!python3 """ Create a variable that contains an empy list. Ask a user to enter 5 words. Add the words into the list. Print the list inputs: string string string string string outputs: string example: Enter a word: apple Enter a word: worm Enter a word: dollar Enter a word: shingle Enter a word: virus ['apple', '...
true
25e432397ff5acb6a55406866813d141dc3ba2c2
jyu001/New-Leetcode-Solution
/solved/248_strobogrammatic_number_III.py
1,518
4.15625
4
''' 248. Strobogrammatic Number III DescriptionHintsSubmissionsDiscussSolution A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to count the total strobogrammatic numbers that exist in the range of low <= num <= high. Example: Input: low = "5...
true
f73472838e6ab97b564a1a0a179b7b2f0667a007
Namrata-Choudhari/FUNCTION
/Q3.Sum and Average.py
228
4.125
4
def sum_average(a,b,c): d=(a+b+c) e=d/3 print("Sum of Numbers",d) print("Average of Number",e) a=int(input("Enter the Number")) b=int(input("Enter the Number")) c=int(input("Enter the Number")) sum_average(a,b,c)
true
b6c0dc8523111386006a29074b02d1691cf1e054
shivigupta3/Python
/pythonsimpleprogram.py
1,709
4.15625
4
#!/usr/bin/python2 x=input("press 1 for addition, press 2 to print hello world, press 3 to check whether a number is prime or not, press 4 for calculator, press 5 to find factorial of a number ") if x==1: a=input("enter first number: ") b=input("enter second number: ") c=a+b print ("sum is ",c) if x==2: print(...
true
9aa1b81bcb80494ea9b0c0b4a728a3981723fa43
eecs110/winter2019
/course-files/practice_exams/final/dictionaries/01_keys.py
337
4.40625
4
translations = {'uno': 'one', 'dos': 'two', 'tres': 'three'} ''' Problem: Given the dictionary above, write a program to print each Spanish word (the key) to the screen. The output should look like this: uno dos tres ''' # option 1: for key in translations: print(key) # option 2: for key in translations.keys(...
true
0fa9fae44540b84cb863749c8307b805e3a8d817
eecs110/winter2019
/course-files/lectures/lecture_03/demo00_operators_data_types.py
327
4.25
4
# example 1: result = 2 * '22' print('The result is:', result) # example 2: result = '2' * 22 print('The result is:', result) # example 3: result = 2 * 22 print('The result is:', result) # example 4: result = max(1, 3, 4 + 8, 9, 3 * 33) # example 5: from operator import add, sub, mul result = sub(100, mul(7, add(8...
true
b485405967c080034bd232685ee94e6b7cc84b4f
eecs110/winter2019
/course-files/practice_exams/final/strings/11_find.py
1,027
4.28125
4
# write a function called sentence that takes a sentence # and a word as positional arguments and returns a boolean # value indicating whether or not the word is in the sentence. # Ensure that your function is case in-sensitive. It does not # have to match on a whole word -- just part of a word. # Below, I show how I w...
true
40c91a64b489ecc92af2ee651c0ec3b48eba031e
amandameganchan/advent-of-code-2020
/day15/day15code.py
1,999
4.1875
4
#!/bin/env python3 """ following the rules of the game, determine the nth number spoken by the players rules: -begin by taking turns reading from a list of starting numbers (puzzle input) -then, each turn consists of considering the most recently spoken number: -if that was the first time the number has been spoke...
true
1321c47e1ea033a5668e940bc87c8916f27055e3
Tejjy624/PythonIntro
/ftoc.py
605
4.375
4
#Homework 1 #Tejvir Sohi #ECS 36A Winter 2019 #The problem in the original code is that 1st: The user input must be changed #into int or float. Float would be the best choice since there are decimals to #work with. The 2nd problem arised due to an extra slash when defining ctemp. #Instead of 5//9, it should be ...
true
4b11d8d1ea2586e08828e69e9759da9cd60dda23
petermooney/datamining
/plotExample1.py
1,798
4.3125
4
### This is source code used for an invited lecture on Data Mining using Python for ### the Institute of Technology at Blanchardstown, Dublin, Ireland ### Lecturer and presenter: Dr. Peter Mooney ### email: peter.mooney@nuim.ie ### Date: November 2013 ### ### The purpose of this lecture is to provide students with an ...
true
6187d788dd3f6fc9b049ded6d08189e6bb8923ed
lflores0214/Sorting
/src/iterative_sorting/iterative_sorting.py
1,583
4.34375
4
# TO-DO: Complete the selection_sort() function below def selection_sort(arr): # loop through n-1 elements print(arr) for i in range(0, len(arr) - 1): # print(f"I: {i}") cur_index = i smallest_index = cur_index # TO-DO: find next smallest element # (hint, can do in 3 ...
true
34517c82223ec7e295f5139488687615eef77d56
devineni-nani/Nani_python_lerning
/Takung input/input.py
1,162
4.375
4
'''This function first takes the input from the user and then evaluates the expression, which means Python automatically identifies whether user entered a string or a number or list. If the input provided is not correct then either syntax error or exception is raised by python.''' #input() use roll_num= input("enter ...
true
75b4292c4e85d8edd136e7bf469c60e9222e383f
Dragonriser/DSA_Practice
/Binary Search/OrderAgnostic.py
847
4.125
4
""" Given a sorted array of numbers, find if a given number ‘key’ is present in the array. Though we know that the array is sorted, we don’t know if it’s sorted in ascending or descending order. You should assume that the array can have duplicates. Write a function to return the index of the ‘key’ if it is present in ...
true
d6b9c248126e6027e39f3f61d17d8a1a73f687b0
Dragonriser/DSA_Practice
/LinkedLists/MergeSortedLists.py
877
4.1875
4
#QUESTION: #Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists. #APPROACH: #Naive: Merge the linked Lists and sort them. #Optimised: Traverse through lists and add elements to new list according to value, since both lists...
true
f0438d1379df6974702dc34ef108073385a3877e
Nightzxfx/Pyton
/function.py
1,069
4.1875
4
def square(n): """Returns the square of a number.""" squared = n ** 2 print "%d squared is %d." % (n, squared) <--%d because is comming from def (function) return squared # Call the square function on line 10! Make sure to # include the number 10 between the parentheses. square(10) ------------------------...
true
c7eed0a9bee1a87a3164f81700d282d1370cebdb
philuu12/PYTHON_4_NTWK_ENGRS
/wk1_hw/Solution_wk1/ex7_yaml_json_read.py
835
4.3125
4
#!/usr/bin/env python ''' Write a Python program that reads both the YAML file and the JSON file created in exercise6 and pretty prints the data structure that is returned. ''' import yaml import json from pprint import pprint def output_format(my_list, my_str): ''' Make the output format easier to read ...
true
96d7d761a9593d39c6d389de8c1dc506d61ef9b4
AASHMAN111/Addition-using-python
/Development/to_run_module.py
1,800
4.125
4
#This module takes two input from the user. The input can be numbers between 0 and 255. #This module keeps on executing until the user wishes. #This module can also be called as a main module. #addition_module.py is imported in this module for the addition #conversion_module.py is imported in this module for the co...
true
868ad4369cd64f877f4ea35f1a85c941aa9c7409
SaketJNU/software_engineering
/rcdu_2750_practicals/rcdu_2750_strings.py
2,923
4.40625
4
""" Strings are amongst the most popular types in Python. We can create them simply by enclosing characters in quotes. Python treats single quotes the same as double quotes. Creating strings is as simple as assigning a value to a variable. """ import string name = "shubham" print("Data in upper case : ",name.upper(...
true
7bbe18daf81dabb7aa2ddb7f20bca261734a17d8
dodooh/python
/Sine_Cosine_Plot.py
858
4.3125
4
# Generating a sine vs cosine curve # For this project, you will have a generate a sine vs cosine curve. # You will need to use the numpy library to access the sine and cosine functions. # You will also need to use the matplotlib library to draw the curve. # To make this more difficult, make the graph go from...
true
68d606253d377862c11b0eaf52f942f6b6155f56
DimaSapsay/py_shift
/shift.py
349
4.15625
4
"""" function to perform a circular shift of a list to the left by a given number of elements """ from typing import List def shift(final_list: List[int], num: int) -> List[int]: """perform a circular shift""" if len(final_list) < num: raise ValueError final_list = final_list[num:] + final_list[...
true
630d6de3258bef33cfb9b4a79a276d002d56c39c
VictoryWekwa/program-gig
/Victory/PythonTask1.py
205
4.53125
5
# A PROGRAM TO COMPUTE THE AREA OF A CIRCLE ## # import math radius=float(input("Enter the Radius of the Circle= ")) area_of_circle=math.pi*(radius**2) print("The Area of the circle is", area_of_circle)
true
5503ffdae3e28c9bc81f7b536fc986bf46913d34
jocogum10/learning_data_structures_and_algorithms
/doubly_linkedlist.py
1,940
4.21875
4
class Node: def __init__(self, data): self.data = data self.next_node = None self.previous_node = None class DoublyLinkedList: def __init__(self, first_node=None, last_node=None): self.first_node = first_node self.last_node = last_node def insert_at_end(self...
true
f9b9480cc340d3b79f06e49aa31a53dbea5379f5
abilash2574/FindingPhoneNumber
/regexes.py
377
4.1875
4
#! python3 # Creating the same program using re package import re indian_pattern = re.compile(r'\d\d\d\d\d \d\d\d\d\d') text = "This is my number 76833 12142." search = indian_pattern.search(text) val = lambda x: None if(search==None) else search.group() if val(search) != None: print ("The phone number is "+val(s...
true
be8b2ea14326e64425af9ee13478ec8c97890804
beajmnz/IEDSbootcamp
/pre-work/pre-work-python.py
1,135
4.3125
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 23 17:39:23 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ #Complete the following exercises using Spyder or Google Collab (your choice): #1. Print your name print('Bea Jimenez') #2. Print your name, your nationality and your job in 3 di...
true
28e93fcc30fca3c0adec041efd4fbeb6a467724e
beajmnz/IEDSbootcamp
/theory/03-Data Structures/DS6.py
452
4.34375
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Wed May 5 18:24:27 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ Write a Python program to count the elements in a list until an element is a tuple. Input: [10,20,30,(10,20),40] Output: 3 """ Input = [10,20,30,(10,20),40] counter = 0 for ...
true
e29dcf2e71f5f207a18e22067c0b26b530399225
beajmnz/IEDSbootcamp
/theory/02b-Flow Control Elements/FLOW3.py
468
4.125
4
#! /usr/bin/python3 # -*- coding: utf-8 -*- """ Created on Wed May 5 13:03:37 2021 @author: Bea Jimenez <bea.jimenez@alumni.ie.edu> """ """ Write a Python program that asks for a name to the user. If that name is your name, give congratulations. If not, let him know that is not your name Mark: be careful because the...
true
37b2d8a716c5e5a130cf1761e92a65ea3a517ab7
JovieMs/dp
/behavioral/strategy.py
1,003
4.28125
4
#!/usr/bin/env python # http://stackoverflow.com/questions/963965/how-is-this-strategy-pattern # -written-in-python-the-sample-in-wikipedia """ In most of other languages Strategy pattern is implemented via creating some base strategy interface/abstract class and subclassing it with a number of concrete strategies (as ...
true
ac896f90c9213c8bee169ffd3fbc74a6b4dc15e3
ICS3U-Programming-JonathanK/Unit4-01-Python
/sum_of_numbers.py
1,257
4.40625
4
#!/usr/bin/env python3 # Created by: Mr. Coxall # Created on: Sept 2019 # Modified by: Jonathan # Modified on: May 20, 2021 # This program asks the user to enter a positive number # and then uses a loop to calculate and display the sum # of all numbers from 0 until that number. def main(): # initialize the loop c...
true
e811211d279510195df3bbdf28645579c8b9f6de
megler/Day8-Caesar-Cipher
/main.py
1,497
4.1875
4
# caesarCipher.py # # Python Bootcamp Day 8 - Caesar Cipher # Usage: # Encrypt and decrypt code with caesar cipher. Day 8 Python Bootcamp # # Marceia Egler Sept 30, 2021 from art import logo from replit import clear alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',...
true
03839c78723e70f763d8009fea4217f18c3eff42
agustinaguero97/curso_python_udemy_omar
/ex4.py
1,624
4.15625
4
""""Your teacher asked from you to write a program that allows her to enter student 4 exam result and then the program calculates the average and displays whether student passed the semester or no.in order to pass the semester, the average score must be 50 or more""" def amount_of_results(): while True: t...
true
7be5665d75207fd063846d31adfc0012aaeee891
vlad-bezden/data_structures_and_algorithms
/data_structures_and_algorithms/quick_sort.py
512
4.21875
4
"""Example of quick sort using recursion""" import random from typing import List def quick_sort(data: List[int]) -> List[int]: if len(data) < 2: return data pivot, left, right = data.pop(), [], [] for item in data: if item < pivot: left.append(item) else: ...
true
4059405985761b3ae72fff1d6d06169cc35b1823
lakshay-saini-au8/PY_playground
/random/day03.py
678
4.46875
4
#question ''' 1.Create a variable “string” which contains any string value of length > 15 2. Print the length of the string variable. 3. Print the type of variable “string” 4. Convert the variable “string” to lowercase and print it. 5. Convert the variable “string” to uppercase and print it. 6. Use colon(:) operator to...
true
6a29cb24698e9390ac9077d431d6f9001386ed84
lakshay-saini-au8/PY_playground
/random/day26.py
1,164
4.28125
4
# Write a program to find a triplet that sums to a given value with improved time complexity. ''' Input: array = {12, 3, 4, 1, 6, 9}, sum = 24; Output: 12, 3, 9 Explanation: There is a triplet (12, 3 and 9) present in the array whose sum is 24. ''' # brute force apporach def triplet(arr, sums): n = len(arr) ...
true
fce872e76b3da0255f503a85d718dc36fd739dd6
Niraj-Suryavanshi/Python-Basic-Program
/7.chapter/12_pr_03.py
224
4.125
4
num=int(input("Enter a number: ")) prime=True for i in range(2,num): if(num%i==0): prime=False break if prime: print("Number is prime") else: print("Number is not prime")
true
69f491abbf9b757d6dc5b7fe6d5e7cd925785389
flerdacodeu/CodeU-2018-Group8
/cliodhnaharrison/assignment1/question1.py
896
4.25
4
#Using Python 3 import string #Input through command line string_one = input() string_two = input() def anagram_finder(string_one, string_two, case_sensitive=False): anagram = True if len(string_one) != len(string_two): return False #Gets a list of ascii characters alphabet = list(string.pr...
true
c425fd70a75756fa84add2f21f7593b8e91b1203
flerdacodeu/CodeU-2018-Group8
/aliiae/assignment3/trie.py
2,519
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Optional follow-up​: Implement a dictionary class that can be constructed from a list of words. A dictionary class with these two methods: * isWord(string): Returns whether the given string is a valid word. * isPrefix(string): Returns whether the given string is a pr...
true
6ddf930b444a33d37a4cc79308577c45cf45af96
Saraabd7/Python-Eng-54
/For_loops_107.py
1,117
4.21875
4
# For loops # Syntax # for item in iterable: mean something you can go over for e.g: list # block of code: import time cool_cars = ['Skoda felicia fun', 'Fiat abarth the old one', 'toyota corola, Fiat panda 4x4', 'Fiat Multipla'] for car in cool_cars: print(car) for lunch_time in cool_cars: print(car) ...
true
933c9d74c3dee9ac64fefe649af9aba3dcffce02
dmonzonis/advent-of-code-2017
/day24/day24.py
2,809
4.34375
4
class Bridge: """Represents a bridge of magnetic pieces. Holds information about available pieces to construct the bridge, current pieces used in the bridge and the available port of the last piece in the bridge.""" def __init__(self, available, bridge=[], port=0): """Initialize bridge variabl...
true
a68e2b0be94ba93bb4e9d123c55af80297ddc5d6
dmonzonis/advent-of-code-2017
/day19/day19.py
1,866
4.34375
4
def step(pos, direction): """Take a step in a given direction and return the new position.""" return [sum(x) for x in zip(pos, direction)] def turn_left(direction): """Return a new direction resulting from turning 90 degrees left.""" return (direction[1], -direction[0]) def turn_right(direction): ...
true
e140bd8915d97b4402d63d2572c056e61a0d9e5a
presstwice/Python-
/data_camp/simple_pendulum.py
487
4.1875
4
# Initialize offset offset = -6 # Code the while loop while offset != 0 :b # The goal is to get offset to always equal 0 print("correcting...") # Prints correcting to clearly state the loop point if offset > 0: # You start the if statement by checking if the offset is positive offset = offset - 1 # If...
true
d22f5a9a6851525504cc7e4f1952a2bbb8ab27ae
BalaRajendran/guvi
/large.py
336
4.21875
4
print ("Find the largest number amoung three numbers"); num=list() arry=int(3); a=1; for i in range(int(arry)): print ('Num :',a); a+=1; n=input(); num.append(int(n)) if (num[0]>num[1] and num[0]>num[2]): print (num[0]); elif (num[1]>num[0] and num[1]>num[2]): print (num[1]); else: prin...
true
5e0c461e5b4d1f9e6c328dcc78d88b5c8a08d410
UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019
/students/AndrewMiotke/lesson04/class_work/generators.py
466
4.21875
4
""" Generators are iterators that returns a value """ def y_range(start, stop, step=1): """ Create a generator using yield """ i = start while i < stop: """ yield, like next(), allows you to increment your flow control e.g. inside a loop """ yield i i += step...
true
603e12a667b8908776efbfef8d015c5e12b390c8
Super1ZC/PyTricks
/PyTricks/use_dicts_to_emulate_switch_statements.py
761
4.375
4
def dispatch_if(operator,x,y): """This is similar to calculator""" if operator == 'add': return x+y elif operator == 'sub': return x-y elif operator == 'mul': return x*y elif operator == 'div': return x/y else: return None def dispatch_dict(operat...
true
1af51d9ed56217484ab6060fc2f36ee38e9523df
rgvsiva/Tasks_MajorCompanies
/long_palindrome.py
560
4.21875
4
#This was asked by AMAZON. #Given a string, find the longest palindromic contiguous substring. #if there are more than one, prompt the first one. #EX: for 'aabcdcb'-->'bcdcb' main_St=input("Enter the main string: ") st=main_St palindrome=[st[0]] while len(st)>1: sub='' for ch in st: sub+=ch ...
true
b6aca7b55b08724d2a922f3788cc2b15c4465f8e
webclinic017/davidgoliath
/Project/modelling/17_skewness.py
1,280
4.125
4
# skewness python # https://www.google.com/search?q=skewness+python&oq=Skewness+python&aqs=chrome.0.0l4j0i22i30l6.3988j0j4&sourceid=chrome&ie=UTF-8 # https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.skew.html # https://www.geeksforgeeks.org/scipy-stats-skew-python/ ''' Statistical functions In simple w...
true
920fbc4957ec799af76035cbb258f2f41392f030
Reskal/Struktur_data_E1E119011
/R.2.4.py
1,096
4.5625
5
''' R-2.4 Write a Python class, Flower, that has three instance variables of type str, int, and float, that respectively represent the name of the flower, its number of petals, and its price. Your class must include a constructor method that initializes each variable to an appropriate value, and your class should in...
true
de037860649e57eab88dc9fd8ae4cdab26fcb47a
sahilqur/python_projects
/Classes/inventory.py
1,720
4.28125
4
""" Simple python application for maintaining the product list in the inventory """ class product: price, id, quantity = None, None, None """ constructor for product class """ def __init__(self, price, id, quantity): self.price = price self.id = id self.quan...
true
7279f2f62f5fab795ab14c5eaa8959fc8b1a1226
gdgupta11/100dayCodingChallenge
/hr_nestedlist.py
2,031
4.28125
4
""" # 100daysCodingChallenge Level: Easy Goal: Given the names and grades for each student in a Physics class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade. [["Gaurav",36], ["GG", 37.1], ["Rob", 42], ["Jack", 42]] Note: If there are multiple students w...
true
c93d362cfdbb5d7ff952181b68dda9d2b378d0c5
Berucha/adventureland
/places.py
2,813
4.375
4
import time class Places: def __init__(self, life): ''' returns print statements based on the user's input (car color) and adds or takes away life points accordingly ''' #testing purposes: # print('''In this minigame, the user has been walking along to Adventurland....
true
d0d009499f6dd7f4194f560545d12f82f2b73db8
starlinw5995/cti110
/P4HW1_Expenses_WilliamStarling.py
1,358
4.1875
4
# CTI-110 # P4HW1 - Expenses # William Starling # 10/17/2019 # # This program calculates the users expenses. # Initialize a counter for the number of expenses entered. number_of_expenses = 1 # Make a variable to control loop. expenses = 'y' # Enter the starting amount in your account. account = float(i...
true
3a0f1e27326226da336ceb45290f89e83bb1f781
dosatos/LeetCode
/Easy/arr_single_number.py
2,254
4.125
4
""" Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? Example 1: Input: [2,2,1] Output: 1 Example 2: Input: [4,1,2,1,2] Output: 4 Clarification ques...
true
2fc808a248480a8840944c8e927ebdb2f23e854a
dosatos/LeetCode
/Easy/ll_merge_two_sorted_lists.py
2,574
4.125
4
""" Percentile: 97.38% Problem: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example: Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4 Solution: Change "pointers" as in merge sort algorithm. Time Complexity = O(N+M) Sp...
true
066769bf25ea46c40333a8ddf2b87c35bfed4fae
arvindsankar/RockPaperScissors
/rockpaperscissors.py
1,646
4.46875
4
import random def correct_input(choice): while choice != "Rock" and choice != "Scissors" and choice != "Paper": # corrects rock if choice == "rock" or choice == "R" or choice == "r": choice = "Rock" # corrects scissors elif choice == "scissors" or choice == "S" or choice == "s": choice = "Scissors" ...
true
fd2236eaf9f68b84c79bc5ea679231c8d1678210
charuvashist/python-assignments
/assigment10.py
2,992
4.34375
4
'''Ques 1. Create a class Animal as a base class and define method animal_attribute. Create another class Tiger which is inheriting Animal and access the base class method.''' class Animal: def animal_attribute(self): print("This is an Animal Class") class Tiger(Animal): def display(self): pr...
true
a336d3cc2a6067b7716b502025456667631106d5
joemmooney/search-text-for-words
/setup.py
1,437
4.5625
5
# This file is the main file for running this program. import argparse from fileReader import read_file # The main function that is run when starting the program. # It sets up argument parsing for the file name to read, the number of most common words to print, # whether to return a json file, and the name for the js...
true
cb8844bcac1c3fa02a35fbab9c6e8fd5c993cb74
MysticSoul/Exceptional_Handling
/answer3.py
444
4.21875
4
# Program to depict Raising Exception ''' try: raise NameError("Hi there") # Raise Error except NameError: print "An exception" raise # To determine whether the exception was raised or not ''' '''Answer2.=> According to python 3.x SyntaxError: Missing parentheses in call to print ...
true
9aff241bff636fa31f64cc83cb35b3ecf379738a
devhelenacodes/python-coding
/pp_06.py
621
4.125
4
# String Lists # Own Answer string = input("Give me a word:\n") start_count = 0 end_count = len(string) - 1 for letter in string: if string[start_count] == string[end_count]: start_count += 1 end_count -= 1 result = "This is a palindrome" else: result = "This is not a palindrome" print(result) # Learned...
true
26fb03d7961e7a2d1c34fd0ef19b5ef2f6293061
emeryberger/COMPSCI590S
/projects/project1/wordcount.py
839
4.28125
4
# Wordcount # Prints words and frequencies in decreasing order of frequency. # To invoke: # python wordcount.py file1 file2 file3... # Author: Emery Berger, www.emeryberger.com import sys import operator # The map of words -> counts. wordcount={} # Read filenames off the argument list. for filename in sys.argv[1:]...
true
84533ee76a2dc430ab5775fa00a4cc354dfc2238
tkruteleff/Python
/16 - Password Generator/password_generator.py
1,239
4.3125
4
import random #Write a password generator in Python. #Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. #The passwords should be random, generating a new password every time the user asks for a new password. #Include your run-time co...
true
9777a2a85ad74c0cad75352fcded12ef838f3eb0
echang19/Homework-9-25
/GradeReport.py
987
4.15625
4
''' Created on Mar 12, 2019 @author: Evan A. Chang Grade Report ''' def main(): studentList={'Cooper':['81','86', '90', '97'],'Jennie':['98', '79','99', '87', '82'], 'Julia':['87', '80','75', '10', '78']} student='' read=input("Would you like to access a student's grades?") read.lower() ...
true
ed4293c4fcc473795705f555a305a4ee7c7a2701
mittal-umang/Analytics
/Assignment-2/VowelCount.py
977
4.25
4
# Chapter 14 Question 11 # Write a program that prompts the user to enter a # text filename and displays the number of vowels and consonants in the file. Use # a set to store the vowels A, E, I, O, and U. def main(): vowels = ('a', 'e', 'i', 'o', 'u') fileName = input("Enter a FileName: ") vowelCount = 0 ...
true
67593b7fcb04e87730e87066e587576fc3a88386
mittal-umang/Analytics
/Assignment-1/PalindromicPrime.py
1,189
4.25
4
# Chapter 6 Question 24 # Write a program that displays the first 100 palindromic prime numbers. Display # 10 numbers per line and align the numbers properly import time def isPrime(number): i = 2 while i <= number / 2: if number % i == 0: return False i += 1 return True def...
true
cea462ca0b7bf4c088e1a2b035f26003052fcef2
mittal-umang/Analytics
/Assignment-2/KeyWordOccurence.py
1,328
4.40625
4
# Chapter 14 Question 3 # Write a program that reads in a Python # source code file and counts the occurrence of each keyword in the file. Your program # should prompt the user to enter the Python source code filename. def main(): keyWords = {"and": 0, "as": 0, "assert": 0, "break": 0, "class": 0, ...
true
49837fed1d537650d55dd8d6c469e7c77bc3a4c6
mittal-umang/Analytics
/Assignment-1/ReverseNumber.py
502
4.28125
4
# Chapter 3 Question 11 # Write a program that prompts the user to enter a four-digit integer # and displays the number in reverse order. def __reverse__(number): reverseNumber = "" while number > 0: reverseNumber += str(number % 10) number = number // 10 return reverseNumber def main():...
true
c86efaf3ce656c67a47a6df3c036345d6e604001
mittal-umang/Analytics
/Assignment-2/AccountClass.py
1,428
4.1875
4
# Chapter 12 Question 3 class Account: def __init__(self, id=0, balance=100, annualinterestrate=0): self.__id = id self.__balance = balance self.__annualInterestRate = annualinterestrate def getMonthlyInterestRate(self): return str(self.__annualInterestRate * 100) + "%" def...
true
692505ec86ff96fe6e96802c2b2cf6306e11e2e0
mfnu/Python-Assignment
/Functions-repeatsinlist.py
554
4.1875
4
''' Author: Madhulika Program: Finding repeats in a list. Output: The program returns the number of times the element is repeated in the list. Date Created: 4/60/2015 Version : 1 ''' mylist=["one", "two","eleven", "one", "three", "two", "eleven", "three", "seven", "eleven"] def count_frequency(myl...
true
013cb916d56e94c09e5d0451ceff7c532c3a85cd
rustyhu/design_pattern
/python_patterns/builder.py
1,028
4.125
4
"Personal understanding: builder pattern emphasizes on the readability and user convenience, the code structure is not quite neat." class BurgerBuilder: cheese = False pepperoni = False lettuce = False tomato = False def __init__(self, size): self.size = size def addPepperoni(self): ...
true
4cc5e4aa3463e07ce239339aac99d5821ec786a1
ashok148/TWoC-Day1
/program3.py
423
4.34375
4
#Program to swap two variable without using 3rd variable.... num1 = int(input("Enter 1st number : ")) num2 = int(input("Enter 2nd number : ")) print("Before swaping") print("num1 = ",num1) print("num2 = ",num2) print("After swapping") #LOGIC 1:- of swapping # num1 = num1 + num2 # num2 = num1 - num2 # num1 = n...
true
9878feed23238d5a152e08b2547b8db64d616a35
send2manoo/All-Repo
/myDocs/pgm/python/ml/04-PythonMachineLearning/04-MatplotlibCrashCourse/01-LinePlot.py
547
4.25
4
''' Matplotlib can be used for creating plots and charts. The library is generally used as follows: Call a plotting function with some data (e.g. plot()). Call many functions to setup the properties of the plot (e.g. labels and colors). Make the plot visible (e.g. show()). ''' # The example below creat...
true
849647385e43448924aa7108a5f4986015c0c88a
send2manoo/All-Repo
/myDocs/pgm/python/ml/03-MachineLearningAlgorithms/1-Baseline machine learning algorithms/2-Zero Rule Algorithm Classification.py
1,166
4.125
4
from random import seed from random import randrange # zero rule algorithm for classification def zero_rule_algorithm_classification(train, test): output_values = [row[-1] for row in train] print 'output=',output_values print "set=",set(output_values) prediction = max(set(output_values), key=output_values.count) ...
true
57a99993916020b5c5780236c8efb052974c51b0
wuxu1019/1point3acres
/Google/test_246_Strobogrammatic_Number.py
908
4.15625
4
""" A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number is strobogrammatic. The number is represented as a string. Example 1: Input: "69" Output: true Example 2: Input: "88" Output: true Example 3: Input: "962" Outp...
true
bcb7788af7663d0e9c52057795c5f62acc349ba1
mennanov/problem-sets
/other/strings/string_all_unique_chars.py
1,371
4.125
4
# -*- coding: utf-8 -*- """ Implement an algorithm to determine if a string has all unique characters. """ def all_unique_set(string): """ Running time and space is O(N). """ return len(string) == len(set(string)) def all_unique_list(string): """ Running time is O(N), space is O(R) where R ...
true
367e5bcdd755649dbedac19066b4f77e3a1293d7
suminb/coding-exercise
/daily-interview/binary_tree_level_with_minimum_sum.py
1,516
4.125
4
# [Daily Problem] Binary Tree Level with Minimum Sum # # You are given the root of a binary tree. Find the level for the binary tree # with the minimum sum, and return that value. # # For instance, in the example below, the sums of the trees are 10, 2 + 8 = 10, # and 4 + 1 + 2 = 7. So, the answer here should be 7. # # ...
true
7cd442736a1d68ef5e38bdb4927f7b02f2180c3f
zgaleday/UCSF-bootcamp
/Vector.py
2,932
4.53125
5
class Vector(object): """Naive implementation of vector operations using the python list interface""" def __init__(self, v0): """ Takes as input the two vectors for which we will operate on. :param v0: A 3D vector as either a python list of [x_0, y_0, z_0] or tuple of same format ...
true
bf320a4a3eb4a61dbc1f485885196c0067208c94
cs-fullstack-2019-fall/python-classobject-review-cw-LilPrice-Code-1
/index.py
1,852
4.28125
4
def main(): pro1() pro2() # Problem 1: # # Create a Movie class with the following properties/attributes: movieName, rating, and yearReleased. # # Override the default str (to-String) method and implement the code that will print the value of all the properties/attributes of the Movie class # # # Assign a value...
true
1591a5a8e525549a24ed11f49346c6b207b2ef7c
Anthncara/MEMO
/python/coding-challenges/cc-001-convert-to-roman-numerals/Int To Roman V2.py
896
4.28125
4
print("### This program converts decimal numbers to Roman Numerals ###",'\nTo exit the program, please type "exit")') def InttoRoman(number): int_roman_map = [(1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'), (100, 'C'), (90, 'XC'),\ (50, 'L'), (40, 'XL'), (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1...
true
eebd301ffac344f8fe7bdf16a8cf9677bb542d3a
G00398275/PandS
/Week 05 - Datastructures/prime.py
566
4.28125
4
# This program lists out the prime numbers between 2 and 100 # Week 05, Tutorial # Author: Ross Downey primes = [] upto = 100000 for candidate in range (2, upto): isPrime = True # Required only to check if divisible by prime number for divisor in primes: # If it is divisible by an integer it isn't a prime num...
true
75a5d8161498d62cbdce415742715a9baac22543
G00398275/PandS
/Week 02/hello3.py
235
4.21875
4
# Week 02 ; hello3.py, Lab 2.2 First Programs # This program reads in a person's name and prints out that persons name using format # Author: Ross Downey name = input ("Enter your name") print ('Hello {} \nNice to meet you'.format (name))
true
a0986698fa2430008eb4d33ebf02b50e933fc09c
G00398275/PandS
/Week 03/Lab 3.3.1-len.py
270
4.15625
4
# Week 03: Lab 3.3.1 Strings # This program reads in a strings and outputs how long it is # Author: Ross Downey inputString = input ('Please enter a string: ') lengthOfString = len(inputString) print('The length of {} is {} characters' .format(inputString, lengthOfString))
true
8ff8959b62adcc0f3455ca00c1e9108a16fbf97e
G00398275/PandS
/Week 03/Lab 3.3.3 normalize.py
575
4.46875
4
# Week 03: Lab 3.3.2 Strings # This program reads in a string and removes any leading or trailing spaces # It also converts all letters to lower case # This program also outputs the length of the original string # Author: Ross Downey rawString = input("Please enter a string: ") normalisedString = rawString.strip().low...
true
59fc57e8d10d9f71c59999d297edfaf310676efd
G00398275/PandS
/Week 04-flow/w3Schools-ifElse.py
1,257
4.40625
4
# Practicing ifElse loops, examples in https://www.w3schools.com/python/python_conditions.asp # Author: Ross Downey a = 33 b = 200 if b > a: # condition is IF b is greater than a print("b is greater than a") # Ensure indentation is present for print, i.e. indent for condition code a = 33 b = 33 if b > a: print("b...
true
2e60abd703a5013e8ee5f7d2ce30b066833a7872
arnavgupta50/BinarySearchTree
/BinaryTreeTraversal.py
1,155
4.3125
4
#Thsi Program traverses the Binary Tree in 3 Ways: In/Post/Pre-Order class Node: def __init__ (self, key): self.left = None self.right = None self.val = key def insert(root, key): if root is None: return Node(key) else: if root.val==key: retu...
true
e6657c32a76d198d60ad812ef1fc5587e8a74465
subham-paul/Python-Programming
/Swap_Value.py
291
4.1875
4
x = int(input("Enter value x=")) y = int(input("Enter value y=")) print("The value are",x,"and",y) x = x^y y = x^y x = x^y print("After the swapping value are",x,"and",y) """Enter value x=10 Enter value y=20 The value are 10 and 20 After the swapping value are 20 and 10 """
true
eafda40ba1154d3f8d02c01d9b827f93f3d7edc6
audflexbutok/Python-Lab-Source-Codes
/audrey_cooper_501_2.py
1,788
4.3125
4
# Programmer: Audrey Cooper # Lab Section: 502 # Lab 3, assignment 2 # Purpose: To create a menu driven calculator # set calc equal to true so it runs continuously calc = True while calc == True: # adds two numbers def add(x, y): return x + y # subtracts two numbers def subtract...
true
71c813eeaea12d9f0b3791bbbf7c2c92fcaf391f
dedx/PHYS200
/Ch7-Ex7.4.py
797
4.46875
4
################################# # # ThinkPython Exercise 7.4 # # J.L. Klay # 30-Apr-2012 # # Exercise 7.4 The built-in function eval takes a string and evaluates # it using the Python interpreter. For example: # >>> eval('1 + 2 * 3') # 7 # >>> import math # >>> eval('math.sqrt(5)') # 2.2360679774997898 # >>> eval('t...
true
8617d6b008e47ed734b1ecaf568ae94dfc7db835
sathishmepco/Python-Basics
/basic-concepts/collections/dequeue_demo.py
1,329
4.34375
4
from collections import deque def main(): d = deque('abcd') print('Queue of : abcd') for e in d: print(e) print('Add a new entry to the right side') d.append('e') print(d) print('Add a new entry to the left side') d.appendleft('z') print(d) print('Return and remove the right side elt') print(d.pop()) p...
true
c5e31c20a1a55cec683250a8d64ebc8836c3f5b6
JKodner/median
/median.py
528
4.1875
4
def median(lst): """Finds the median of a sequence of numbers.""" status = True for i in lst: if type(i) != int: status = False if status: lst.sort() if len(lst) % 2 == 0: num = len(lst) / 2 num2 = (len(lst) / 2) + 1 avg = float(lst[num - 1] + lst[num2 - 1]) / 2 median = {"median": avg, "positi...
true
33487b5cd6e069e72cbe686724143ba1eb16979e
Tayuba/AI_Engineering
/AI Study Note/List.py
1,895
4.21875
4
# original list a = [1, 2, 3, 4, "m", 6] b = ["a", "b", "c", "d", 2, 9, 10] # append(), add an item to the end of already existing list c = 8 a.append(c) # interger append print(a) # [1, 2, 3, 4, 'm', 6, 8] d = "Ayuba" b.append(d) print(b) # ['a', 'b', 'c', 'd', 2, 9, 10, 'Ayuba'] # extend(), add all items to the t...
true
4f340717ec34d4d1ee5dc79b1bcac29c8be02600
OliverMathias/University_Class_Assignments
/Python-Projects-master/Assignments/Celsius.py
367
4.3125
4
''' A script that converts a user's celsius input into farenheight by using the formula and prints out an temp in farenheight ''' #gets user's temp Input temp_c = float(input("Please enter the current temperature in celsius: ")) # turns it into farenheight temp_f = temp_c*(9/5) + 32 #prints out farenheight print("The...
true
10ea306fedbee3cff2ce63c97add2561c9f2b54a
mbkhan721/PycharmProjects
/RecursionFolder/Practice6.py
2,445
4.40625
4
""" Muhammad Khan 1. Write a program that recursively counts down from n. a) Create a recursive function named countdown that accepts an integer n, and progressively decrements and outputs the value of n. b) Test your function with a few values for n.""" def countdown(n): # def recursive_function(parameters) if n...
true
3a21120c6e8e9814b6dad06431ec73beaeee9ff2
Roha123611/activity-sheet2
/prog15.py
366
4.1875
4
#prog15 #t.taken from fractions import Fraction def addfraction(st_value,it_value): sum=0 for i in range(st_value,it_value): sum=sum+Fraction(1,i) print('the sum of fractions is:',sum) return st_value=int(input('input starting value of series:')) it_value=int(input('enter ending value ...
true
4a917541eaf35c7e398ec8a4bb6acd1774541c9e
helgurd/Easy-solve-and-Learn-python-
/differBetw_ARR_LIST.py
978
4.4375
4
# first of all before we get into Python lists are not arrays, arrays are two separate things and it is a common mistakes that people think that lists are the same arrays. #in array if we append different data type will return typeerror which that is not case in the list. # ARRAY!=LIST ###example 1 python list import...
true
bfa347e6247121c5cd10b86b7769eb368d5ae487
helgurd/Easy-solve-and-Learn-python-
/open_and_read _string.py
1,310
4.6875
5
#write a program in python to read from file and used more than method. # read from file -------------------------------------------------------------------- #write a program in python to read from file and used more than method. # method1 # f=open('str_print.txt','r') # f.close() #--------- # method2 called con...
true
75964cfe90c20dbed87347908b79b899f45b593a
sachi-jain15/python-project-1
/main.py
1,206
4.1875
4
# MAIN FILE def output(): #Function to take user's choice print "\nWhich script you want to run??\n Press 1 for students_to_teacher\n Press 2 for battleship\n Press 3 for exam_stats" choice=int(raw_input('Your choice: ')) # To take users input of their choice if (choice==1): print "\n STUDENTS_...
true
91e7da83b03fe16d65782809e07e397a41aabb72
TheNathanHernandez/PythonStatements
/Unit 2 - Introductory Python/A1/Comments_Outputs_Errors.py
1,379
4.65625
5
print('Welcome to Python!') # Output: Welcome to Python # Why: String says "Welcome to Python print(1+1) # Output: 2 # Why: Math sum / 1 + 1 = 2 # print(This will produce an error) # Output: This will produce an Error # Why: The text doesn't have a string, it's invalid print(5+5-2) # Output: 8 # Why: 5 + 5 - 2 prin...
true
bbed8da2e0837f77df6ae36a03ef73ac25e172fd
TheNathanHernandez/PythonStatements
/Unit 2 - Introductory Python/A4 - Conditional Expressions/programOne.py
403
4.15625
4
# Program One - Write a number that asks the user to enter a number between 1 and 5. The program should output the number in words. # Code: Nathan Hernandez from ess import ask number = ask("Choose a number between 1 and 5.") if number == 1: print("One.") if number == 2: print("Two.") if number == 3: ...
true