blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
24b03adda55bc74c4365e93ecf529f3cc1c4453d | ravisjoshi/python_snippets | /Permutation-Combination/PermutationAndCombination.py | 879 | 4.3125 | 4 | """
"My fruit salad is a combination of apples, grapes and bananas" We don't care what order the fruits are in, they could also be "bananas, grapes and apples" or "grapes, apples and bananas", its the same fruit salad.
"The combination to the safe is 472". Now we do care about the order. "724" won't work, nor will "247... | true |
c90e7d6f56a990f373775438722f91d821f1ff1f | ravisjoshi/python_snippets | /Basics-2/NumberOfDaysBetweenTwoDates.py | 815 | 4.21875 | 4 | """
Write a program to count the number of days between two dates.
The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples.
Input: date1 = "2019-06-29", date2 = "2019-06-30" / Output: 1
Input: date1 = "2020-01-15", date2 = "2019-12-31" / Output: 15
Constraints: The given dates are ... | true |
228e9868f9142aec935642cae53376452d296029 | monreyes/SelWebDriver | /PythonProj1/Sec3-UnderstandingVariablesAndDataTypes/319-StringMethods-Part2/string-methods2.py | 404 | 4.3125 | 4 | """
Examples to show available string methods in python
"""
# Replace Method
a = "1abc2abc3abc4abc"
print(a.replace('abc', 'ABC'))
#print(a.upper()) # another way to convert if all is need to upper case (or a.lower if all needed to be in lower case)
# Sub-Strings
# starting index is inclusive
# Ending index is exclus... | true |
902b77933c6d369a13fa8963737cde0a22c0d01b | monreyes/SelWebDriver | /PythonProj1/Sec3-UnderstandingVariablesAndDataTypes/314-Numbers-ExponentiationAndModulo/numbers_operations.py | 427 | 4.28125 | 4 | # This is a one line comment
# Exponentiation
exponents = 10**2
print(exponents)
"""
this is a multi line comment
modulo - returns the remainder
"""
a=100
b=3
remainder = a % b
print("Getting the modulo of " + str(a)+ " % "+ str(b) + " is just like getting the remainder integer when " + str(a) +"... | true |
ddb4a47288b73951542d6c1aa3854b7c3846cf9c | DysphoricUnicorn/CodingChallenges | /extra_char_finder.py | 1,630 | 4.3125 | 4 | """
This is my solution to the interview question at https://www.careercup.com/question?id=5101712088498176
The exercise was to write a script that, when given two strings that are the same except that one string has an extra
character, prints out that character.
"""
import sys
def find_extra_char(longer_string, shor... | true |
6a563dbae7b8cf7a46621ba9013275c2856ffc95 | pratikmallya/interview_questions | /sorting/insertion_sort.py | 1,011 | 4.34375 | 4 | """
Insertion Sort
Pick lowest element, push it to the front of the list
This will be an in-place sort. Why? Because that's a little
more complicated.
"""
import unittest
from random import sample
from copy import deepcopy
class TestAlg(unittest.TestCase):
def test_case_1(self):
v = [10, 9, 8, 7, 6, 5, ... | true |
4206e176b23841534c80170b24ca94ee87170c1a | navnathsatre/Python-pyCharm | /BasicOprations.py | 580 | 4.25 | 4 | num1=int(input("Enter the value for num1 "))
num2=int(input("Enter the value for num2 "))
#num1=568
#num2=64
add=num1+num2
multi=num1*num2
sub=num1-num2
div=num1/num2
pow=num1**num2
"""print("addition of num1 and num2 is:-",add)
print("multiplication of num1 and num2 is:-",multi)
print("substraction of num1 ... | true |
147560dd844918b281b381aedec10aac292711e6 | navnathsatre/Python-pyCharm | /pyFunc_3.py | 301 | 4.1875 | 4 | # Factorial of number
# 5! = 5*4*3*2*1
#1! = 0
#0! = 0
def iterFactorial(num):
result = 1
for item in range(1, num+1):
result = result*item
return result
n = int(input("Enter the number: "))
out = iterFactorial(n)
print("Factorial of {} is {} ".format(n, out)) | true |
dc8d1e68476d077ab36ca4aece654e6ac5ef63bb | RyanLongRoad/Records | /Test scores.py | 745 | 4.15625 | 4 | #Ryan Cox
#29/01/15
#Store and display students test scores
#Blue print
class studentMarks:
def __init__(self):
self.testScore = "-"
self.studentName = "-"
#main program
def create_record():
new_studentMarks = studentMarks
def enter_enformation():
studentMarks... | true |
3cdcc8c5f51e8b0813fad7ad93b09331af801b9a | tamkevindo97/Runestone-Academy-Exercises | /longest_word_dict.py | 456 | 4.28125 | 4 | import string
def longest_word(text):
text.translate(str.maketrans('', '', string.punctuation))
list_text = list(text.split())
dictionary = {}
for aChar in list_text:
dictionary.update({aChar: len(aChar)})
max_key = max(dictionary, key=dictionary.get)
print(dictionary)
r... | true |
08f8761330af9c9dccb0ed64557e1b45516b2bc4 | PacktPublishing/Learn-Python-Programming-Second-Edition | /Chapter01/ch1/scopes3.py | 450 | 4.21875 | 4 | # Local, Enclosing and Global
def enclosing_func():
m = 13
def local():
# m doesn't belong to the scope defined by the local
# function so Python will keep looking into the next
# enclosing scope. This time m is found in the enclosing
# scope
print(m, 'printing from th... | true |
d19cb3e849ab5d6e7d43843a000d24992e0a3b22 | llewyn-jh/codingdojang | /calculate_trigonometric_function.py | 1,046 | 4.28125 | 4 | """Calculate cosine and sine funtions in person"""
import math
def calculate_trigonometric_function(radian_x: float) -> float:
"""This function refer to Taylor's theorm.
A remainder for cos or sin at radian_x follows Cauchy's remainder.
The function has 2 steps. Step1 get a degree of
Taylor polynomial... | true |
e78bb6f14e5aa6a3fc8e765ac206b458bcaa2fb3 | sirobhushanamsreenath/DataStructures | /Stacks/stack.py | 1,026 | 4.21875 | 4 | # Implementation of stack data structure using linkedlist
class Node:
def __init__(self, data=None, next=None):
self.next = next
self.data = data
def has_next(self):
return self.next != None
class Stack:
def __init__(self, top=None):
self.top = top
def print_stack(s... | true |
c33c1e6d9251779cf6f7f8484d8e431575e8d1fa | ronshuvy/IntroToCS-Course-Projects | /Ex2 - Math/shapes.py | 1,529 | 4.46875 | 4 | # FILE : shapes.py
# WRITER : Ron Shuvy , ronshuvy , 206330193
# EXERCISE : intro2cs1 2019
import math
def shape_area():
""" Calculates the area of a circle/rectangle/triangle (Input from user)
:return: the area of a shape
:rtype: float
"""
def circle_area(r):
""" Calculate... | true |
e3a613de2b32756b5a6bad7846b1db69cd134bab | SonnyTosco/HTML-Assignments | /Python/sonnytosco_pythonoop_bike.py | 1,603 | 4.3125 | 4 | class Bike(object):
def __init__(self, price,max_speed):
self.price=price
self.max_speed=max_speed
self.miles=0
print "Created a new bike"
def displayInfo(self):
print "Bike's price:"+ str(self.price)
print "Bike's max speed:"+str(self.max_speed)+'mph'
pri... | true |
13ff32648e515107376972672ac74737c6670379 | HanaAuana/PyWorld | /DNA.py | 2,807 | 4.21875 | 4 | #Michael Lim CS431 Fall 2013
import random
# A class to hold a binary string representing the DNA of an organism
class DNA():
#Takes an int representing the number of genes, and possibly an existing genotype to use
def __init__(self, numGenes, existingGenes):
self.numGenes = numGenes
#If a g... | true |
697f05adc3fd045a5d8b4757ba1ceae1a92de41c | DrewStanger/pset7-houses | /import.py | 1,595 | 4.375 | 4 | from sys import argv, exit
from cs50 import SQL
import csv
# gives access to the db.
db = SQL("sqlite:///students.db")
# Import CSV file as a command line arg
if len(argv) != 2:
# incorrect number print error and exit
print(f"Error there should be 1 argv, you have {argv}")
exit(1)
# assume CSV file e... | true |
0606a46baee937e230d7ae503a69c4724957c3d0 | elaineli/ElaineHomework | /Justin/hw2.py | 834 | 4.125 | 4 | ages = { "Peter": 10, "Isabel": 11, "Anna": 9, "Thomas": 10, "Bob": 10, "Joseph": 11, "Maria": 12, "Gabriel": 10, }
# 1 find the number of students
numstudents = len(ages)
print(numstudents)
# 2 receives ages and returns average
def averageAge(ages):
sum = 0
for i in ages.values():
sum += i
lengt... | true |
8e472f11b1d5e9c6d3cec5500c8fb2229f3a6641 | Kakadiyaraj/Leetcode-Solutions | /singalString.py | 539 | 4.21875 | 4 | #Write a program that reads names of two python files and strips the extension. The filenames are then concatenated to form a single string. The program then prints 'True' if the newly generated string is a palindrome, or prints 'False' otherwise.
name1 = input('Enter a first file name : ')
name2 = input('Enter a seco... | true |
55a870349405f243b9a7b6fad1a4a27c82d9017a | rohitgit7/Ethans_Python | /Class4_[13-10-2018]/dictionary.py | 2,117 | 4.40625 | 4 | #Dictionary is a collection which is unordered, changeable and indexed
data = { 'name' : 'Rohit',
'roll_no' : 20, #will be overriden by last key value
'city' : 'Pune',
'roll_no' : 34,
2 : 234}
#dict() is a constructor too
print data
print "type(data)", type(data)
data['name'] = 'India'
data['call'] = 12345... | true |
afe039a8f713e6a13372d2de91ec8c0d972a3d6d | gwlilabmit/Ram_Y_complex | /msa/msas_with_bad_scores/daca/base_complement.py | 1,870 | 4.3125 | 4 | #sequence = raw_input("Enter the sequence you'd like the complement of: \n")
#seqtype = raw_input("Is this DNA or RNA? \n")
sequence = ''
seqtype = 'DNA'
def seqcomplement(sequence, seqtype):
complement = ''
for i in range(len(sequence)):
char = sequence[i]
if char == 'A' or char == 'a':
if 'R' in seqtype o... | true |
5eead0bd31ab85a27925a22a450abc5eeff8f689 | gayathrib17/pythonpractice | /IdentifyNumber.py | 1,356 | 4.40625 | 4 | # Program to input from user and validate
while True:
try: # try is used to catch any errors for the input validation into float
num = int(input("Please input a integer between -9999 and 9999: "))
except ValueError: # ValueError is raised when we are attempting to convert a non numeric string into floa... | true |
1110b8b86c71d30e8e220e005cc60ac2c3ce546a | oscarhuang1212/Leecode | /LeetCode#073_Set_Matrix_Zeroes.py | 2,350 | 4.15625 | 4 | # File name: LeetCode#73_Set_Matrix_Zeroes.py
# Author: Oscar Huang
# Description: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.
#
# Example 1:
# Input:
# [
# [1,1,1],
# [1,0,1],
# [1,1,1]
# ]
# Outp... | true |
2392192820c230c919b684c3d2d9ba92b8ca4d59 | Gt-gih/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 594 | 4.25 | 4 | #!/usr/bin/python3
"""
Module with function that add two integers
"""
def add_integer(a, b=98):
"""Function that add two numbers
Raises:
TypeError: a parameter must be integer type
TypeError: b parameter must be integer type
Args:
a (int): The first parameter.
b (int):... | true |
3b5f8c3e6f1bd65ba15d4af55840ef50afae0ffe | Gt-gih/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/2-uniq_add.py | 362 | 4.1875 | 4 | #!/usr/bin/python3
def uniq_add(my_list=[]):
# new list
new_list = []
for element in my_list:
# checking element not exist in list 🔄
if element not in new_list:
new_list.append(element)
result = 0
# adding each element in list into result 🔴
for item in new_list:
... | true |
e047b0eeda1e934eebcef822d70a9403f30f7eec | ngchrbn/DS-Roadmap | /DS Code/1. Programming/Python/Projects/banking_system.py | 1,217 | 4.28125 | 4 | """
Banking System using OOP:
==> Holds details about a user
==> Has a function to show user details
==> Child class : Bank
==> Stores details about the account balance
==> Stores details about the amount
==> Allows for deposits, withdrawals, and view balance
"""
class User:
def __init__(self, name, age, gender... | true |
cb217a8a547a07eb1c02e065e9a0db8416ffd117 | shaniajain/hello-world | /ShaniaJainLab3.py | 2,792 | 4.15625 | 4 | ###############################################################################
# CS 21A Python Programming: Lab #3
# Name: Shania Jain
# Description: Password Verification Program
# Filename: ShaniaJainLab3.py
# Date: 07/25/17
###############################################################################
def main()... | true |
ce0198d5caa2eb033fb1b4c40198232063d0de38 | asiftandel96/Python-Implementation | /LambdaFunctions.py | 2,580 | 4.40625 | 4 | """ Python Lambda Functions/Anonymous Functions.Anonymous function are those function which are without name."""
# Defining a Normal functions.
def addition_num(a, b):
c = a * b
print(c)
addition_num(2, 42)
# Using A Lambda
# Syntax lambda arguments:expression
# Note-(Lambda Function can take si... | true |
413f32f1367a8cbf5183add9771d598e630f9534 | amarinas/algo | /chapter_1_fundamentals/leapyear.py | 484 | 4.21875 | 4 | # write a function that determines whether a given year is a leap year
# if the year is divisible by four, its a leap year
# unless its divisible by 100
# if it is divisible by 400 than it is
def leapyear(year):
if year % 4 == 0:
print "it is a leap year"
elif year % 100 ==0:
print "not a leap... | true |
ef06ee1de6b838599b98c1bab5883c595086f514 | amarinas/algo | /Hack_rank_algo/writefunction.py | 304 | 4.1875 | 4 | #Determine if a year is a leap yesar
def is_leap(year):
leap = False
#condition for a leap year
if year % 4 == 0 and year % 400 == 0 or year % 100 != 0:
return True
#return leap if the above condition is false
return leap
year = int(raw_input())
print is_leap(year)
| true |
9554a30f82c858f0aacab04102ba43a7f7057f02 | amarinas/algo | /random_algo_exercise/strings_integers.py | 208 | 4.15625 | 4 | # Read a string,S , and print its integer value; if S cannot be converted to an integer, print Bad String
import sys
S = raw_input().strip()
try:
print(int(S))
except ValueError:
print("Bad String")
| true |
096abdbc6c7a049bbfbc7c8afc516bad0ec5d022 | amarinas/algo | /PlatformAlgo/reversing.py | 474 | 4.65625 | 5 | #Given an array X of multiple values (e.g. [-3,5,1,3,2,10]), write a program that reverses the values in the array. Once your program is done X should be in the reserved order. Do this without creating a temporary array. Also, do NOT use the reverse method but find a way to reverse the values in the array (HINT: swa... | true |
f9bd0cca25a8e163eb84c490e44fc305f3e1dc85 | amarinas/algo | /PlatformAlgo/square_value.py | 477 | 4.21875 | 4 | #Given an array x (e.g. [1,5, 10, -2]), create an algorithm (sets of instructions) that squares each value in the array. When the program is done x should have values that have been squared (e.g. [1, 25, 100, 4]). You're not to use any of the pre-built function in Javascript. You could for example square the value b... | true |
7f90da219ab5807749f17964bdd7b1ff78b3c1eb | amarinas/algo | /random_algo_exercise/arrays_day7.py | 302 | 4.125 | 4 | # Given an array, A, of N integers, print A's elements in reverse order as a single line of space-separated numbers.
from __future__ import print_function
import sys
n = int(raw_input().strip())
arr = map(int,raw_input().strip().split(' '))
arr.reverse()
for num in arr:
print(num + " ", end='')
| true |
113abd3f4d90aa0b95d135b2b7928b6400738fa1 | amarinas/algo | /PlatformAlgo/iterate_array.py | 394 | 4.3125 | 4 | #Given an array X say [1,3,5,7,9,13], write a program that would iterate through each member of the array and print each value on the screen. Being able to loop through each member of the array is extremely important. Do this over and over (under 2 minutes) before moving on to the next algorithm challenge.
def Itera... | true |
a06208c839a3331629c2116f667e73a693dc62a9 | chyidl/chyidlTutorial | /root/os/DSAA/DataStructuresAndAlgorithms/python/sort_selection_array_implement.py | 1,878 | 4.34375 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
#
# sort_selection_array_implement.py
# python
#
# 🎂"Here's to the crazy ones. The misfits. The rebels.
# The troublemakers. The round pegs in the square holes.
# The ones who see things differently. They're not found
# of rules. And they have no respect for the status q... | true |
3b2d4f6855512f17e98d393348cdf39f855ab739 | lstobie/CP1404_practicals | /prac_03/ASCII.py | 612 | 4.125 | 4 | def main():
LOWER_LIMIT = 33
UPPER_LIMIT = 127
char = input("Enter a character: ")
print("The ASCII code for {} is {}".format(char, ord(char)))
cord = int(input("Enter a number between {} and {}: ".format(LOWER_LIMIT, UPPER_LIMIT)))
if LOWER_LIMIT <= cord <= UPPER_LIMIT:
print("The chara... | true |
967bb21482280ffe1eff1b09ee403dcaac27858d | alexpsimone/other-practice | /repls/anagram_finder.py | 2,072 | 4.1875 | 4 | # anagram finder
# write a function that takes two strings and returns whether or not they are anagrams
# abc cab -> true
# abc abc -> true
# abc abd -> False
# '' '' -> True
# abc1 1abc -> True
# abcd abc -> False
# numbers and letters, no spaces, any length strings
def anagram(x, y):
# if the stri... | true |
bb40fb86a454d0617480ae24c842a1cd91ca9c7c | erijones/phs | /python/intro/prime_finder.py | 1,815 | 4.40625 | 4 | #!/usr/bin/python3
# This program runs as ./prime_finder (with correct permissions), but
# incorrectly! The program's goal is to list the prime numbers below a certain
# number using the Sieve of Eratosthenes, discovered around 200 BC.
# Run the file, and mess around with the testing area below. Debug and
# troublesho... | true |
4885d8d60b7b2245f2bc4c8d398a66e26a5620e9 | noehoro/Python-Data-Structures-and-Algorithms | /Recursion/recursiveMultiply.py | 349 | 4.15625 | 4 | def iterative_multiply(x, y):
results = 0
for i in range(y):
results += x
return results
def recursive_multiply(x, y):
# This cuts down on the total number of
# recursive calls:
if y == 0:
return 0
return x + recursive_multiply(x, y - 1)
x = 500
y = 2000
print(x * y)
pri... | true |
9ea9de95112cbcf5d0c6dc1e87833c67b9602bf1 | prince6635/expert-python-programming | /syntax_best_practices/coroutines.py | 2,417 | 4.1875 | 4 | """
Coroutines:
A coroutine is a function that can be suspended and resumed, and can have multiple entry points.
For example, each coroutine consumes or produces data, then pauses until other data are passed along.
PEP 342 that initiated the new behavior of generators also
provides a full example on ho... | true |
98aefb8c8ae08939ef877e268bfc10a54a0be896 | alancyao/fun-times | /Algorithms/reverse_contiguous_subset_to_sort.py | 794 | 4.21875 | 4 | #!/usr/bin/env python3
""" Problem description:
You have an array of n distinct integers. Determine whether it is possible to sort the array by reversing exactly one contiguous segment of the array. For example, 1 [4 3 2] 5 => 1 [2 3 4] 5.
"""
""" Some variables for testing """
possible = [1, 2, 6, 5, 4, 3, 7, 8]
imp... | true |
0e0bbc7c9d542fe1967d7b1fdd36cda4548bf5f7 | nicklambson/pcap | /class/subclass2.py | 460 | 4.28125 | 4 | class A:
def __init__(self):
self.a = 1
class B(A):
def __init__(self):
# super().__init__()
A.__init__(self)
# self.a = 2
self.b = 3
# use super() to access the methods of the parent class
# or A.__init__(self)
# use super().__init__() to initialize from the parent cla... | true |
3123e526b96d7aa2d5eaaa3e22bc676e127f9307 | nicklambson/pcap | /exceptions/which_exception.py | 419 | 4.125 | 4 | '''
try:
raise Exception
except:
print("c")
except BaseException:
print("a")
except Exception:
print("b")
'''
# error: default except: must be last
try:
raise Exception
except BaseException:
print("a")
except Exception:
print("b")
except:
print("c")
# a
try:
raise Exception
excep... | true |
e616966a28dbd8bbd905ecba525b13c87ce2980d | deelm7478/CTI110 | /P4T2_BugCollector_MathewDeel.py | 602 | 4.3125 | 4 | # Collects and displays the number of bugs collected.
# 10/15/18
# CTI-110 P4T2 - Bug Collector
# Mathew Deel
#
def main():
#Initialize the accumulator
total = 0
#Get the bugs collected for each day.
for day in range(1, 6):
#Prompt user for amount of bugs that day
print('E... | true |
9583849c3077e5aeefc86c503f69043286d0edf9 | amit70/Python-Interview-Examples | /isPower2.py | 481 | 4.28125 | 4 | #Given an integer, write a function to determine if it is a power of two.
def isPower(n):
# Base case
if (n <= 1):
return True
# Try all numbers from 2 to sqrt(n)
# as base
for x in range(2, (int)(math.sqrt(n)) + 1):
p = x
# Keep multiplying p with x while
# is sm... | true |
134d690ef5727cce192900151ddb83c8d67b73b8 | jananee009/DataStructures_And_Algorithms | /Arrays_And_Strings/ReverseString.py | 1,183 | 4.6875 | 5 | # Implement a program to reverse a string.
# Follow up: Write a function to reverse an array of characters in place. "In place" means "without creating a new string in memory."
def reverseString(inputStr):
reversed = ""
for i in range(len(inputStr)-1,-1,-1):
reversed = reversed + inputStr[i]
return reversed
de... | true |
d8c39538141f5d4065f9a6c89a0b438d66648a9e | jananee009/DataStructures_And_Algorithms | /Arrays_And_Strings/ReplaceAllSpaces.py | 749 | 4.4375 | 4 | # Write a method to replace all spaces in a string with '%20'. Assume that the string has sufficient space at the end of the string to hold the additional characters
# and that you are given the true length of the string.
# E.g. Input: "Mr John Smith ", 13
# Output: "Mr%20John%20Smith"
def replaceAllSpaces(inpu... | true |
f90911ff384b918a697fd987bf4e12b814bbc92c | jananee009/DataStructures_And_Algorithms | /Miscellaneous/Parentheticals.py | 1,984 | 4.125 | 4 | # Write a function that, given a sentence, , finds the position of an opening parenthesis and the corresponding closing parenthesis.
# Source: https://www.interviewcake.com/question/python/matching-parens?utm_source=weekly_email&__s=ibuidbvzaa2i67rfb2mc
# Approach: 1. Process the string character by character.
# We c... | true |
89167fe59613bc1eba62d18d09deea19c0bad38f | jananee009/DataStructures_And_Algorithms | /Stacks_And_Queues/Stack.py | 1,046 | 4.25 | 4 | # Write a program to implement a stack (LIFO). Implement the operations : push, pop, peek.
class Stack:
def __init__(self):
self.stack = []
def isEmpty(self):
if(len(self.stack)==0):
return True
else:
return False
def push(self,element):
self.stack.append(element)
def pop(self):
if(len(self.stac... | true |
95c1d47ade4d105851b29eb1bbacf6231d188fbd | GuND0Wn151/Python_OOP | /13_MagicMethods_1.py | 1,670 | 4.4375 | 4 | #C0d3 n0=13
#made By GuND0Wn151
"""
there are some methods in python class
Magic methods in Python are the special methods which add "magic"
to your class. Magic methods are not
meant to be invoked directly by you, but the invocation happens
internally from the class on a certain action.
"""
... | true |
53f18b79d98cfc5fb94bc561d54248cb33c62165 | GuND0Wn151/Python_OOP | /10_Getter.py | 609 | 4.28125 | 4 | #C0d3 n0=10
#made By GuND0Wn151
'''
The getattr() method retu
the value of the named attribute of an object.
If not found, it returns the default value provided to the function.
'''
class person:
legs=2
hands=2
hair_color='black'
def __init__(self,a):
self.name=a
person1=person("k... | true |
28719c5fed80810c43c3376758b82f851f56a05b | DAVIDMIGWI/python | /lesson 3b.py | 399 | 4.15625 | 4 |
a = 40
b = 50
c = 500
if a > b:
print("A is greater than B")
if a > c:
print("A is also greater than C")
else:
print("A is not greater than C")
if c > b:
print("C is the largest")
else:
print("A is the largest")
else:
if b... | true |
369d0f3e749c5419d5e40d9e41f3db3a43c946b7 | jmmiddour/Old-CS-TK | /CS00_Intro_to_Python_1/src/05_lists.py | 1,707 | 4.625 | 5 | # For the exercise,
# look up the methods and functions that are available for use with Python lists.
# An array can only have one data type, list can have multiple data types.
# If you want to add to an array you have to create a new array twice the size of
# the one you have, taking up more space.
# You need to use... | true |
2589aa703538ead00de18c0b828a84f27aeb16c1 | jmmiddour/Old-CS-TK | /CS00_Intro_to_Python_1/src/14_cal.py | 2,934 | 4.59375 | 5 | """
The Python standard library's 'calendar' module allows you to
render a calendar to your terminal.
https://docs.python.org/3.6/library/calendar.html
Write a program that accepts user input of the form
`14_cal.py [month] [year]`
and does the following:
- If the user doesn't specify any input, your program should
... | true |
d86a00d4050862b4e14da77ed994e90595b5e40a | Paahn/practice_python | /reverse_word_order.py | 265 | 4.34375 | 4 | # Write a program that asks the user
# for a long string containing multiple words.
# Print back to the user the same string, except with the words in backwards order.
a = input("Gimme a string containing multiple words:\n")
b = a.split(' ')
print(b[::-1])
| true |
7588d9c2400c665eb0be8ca319c3dc17f03ec568 | Paahn/practice_python | /guessing_game.py | 997 | 4.375 | 4 | # Generate a random number between 1 and 9 (including 1 and 9).
# Ask the user to guess the number, then tell them whether they guessed too low,
# too high, or exactly right.
# Keep the game going until the user types “exit”
# Keep track of how many guesses the user has taken, and when the game ends, print this out... | true |
47717a3918ae9d4522508d3125763b31c3298a4d | elenaozdemir/Python_bootcamp | /Week 1/Day Two/Practicing with lists & functions.py | 747 | 4.53125 | 5 | # practicing with lists and functions
# EXAMPLE: Define a function that returns a list of even numbers
# between A and B (inclusive)
def find_events(A,B):
# make an empty list to return to something
evens = []
for nums in range (A,B+1): #inclusive
if (nums % 2 == 0):
evens.append(nums)
... | true |
4c5a3b9f23c9910631860938ce17e86c87a31939 | SBenkhelfaSparta/eng89_python_basics | /string_casting_concatenation.py | 1,567 | 4.34375 | 4 | # using and managing strings
# strings casting
# string concatenation
# Casting methods
# Single and double quotes
single_quotes = 'These are single quotes and working perfectly fine!'
double_quotes = "These are double quotes also working fine"
# print(single_quotes)
# print(double_quotes)
# concatenation
# firs... | true |
95a2ee3b58d7fdf3e0bcc499b37b7bfa59a286b6 | Ms-Noxolo/Predict-Team-7 | /EskomFunctions/function3.py | 591 | 4.375 | 4 | def date_parser(dates):
""" This function returns a list of strings where each element in the returned list contains only the date
Example
-------
Input: ['2019-11-29 12:50:54',
'2019-11-29 12:46:53',
'2019-11-29 12:46:10']
Output: ['2019-11-29', '2019-... | true |
813a5288fc26121aee0081f4b9ab131a2190e321 | aprabhu84/PythonBasics | /Methods and Functions/Level 1/03_Makes_Twenty.py | 473 | 4.15625 | 4 | #MAKES TWENTY:
# -- Given two integers,
# -- return True if the sum of the integers is 20
# -- or if one of the integers is 20.
# -- If not, return False
#makes_twenty(20,10) --> True
#makes_twenty(12,8) --> True
#makes_twenty(2,3) --> False
def makes_twenty(number1, number2):
int_num1 = int(number1)
... | true |
f751e02345f05a8f287ff20671542153c6e88cac | aprabhu84/PythonBasics | /Methods and Functions/Level 2/02_Paper_Doll.py | 394 | 4.15625 | 4 | # PAPER DOLL: Given a string, return a string where for every character in the original there are three characters
# paper_doll('Hello') --> 'HHHeeellllllooo'
# paper_doll('Mississippi') --> 'MMMiiissssssiiippppppiii'
def paper_doll(someString):
resultString = ""
for pos in range(0,len(someString)):
... | true |
46be0a96d81cb8c48dc94ab9a2883c6ffdbaddd8 | Aleksandraboy/basics | /nesting.py | 2,894 | 4.5 | 4 | # 03/20/21
# 1. A List of Lists
# 2. A List of Dictionary
# 3. A List in a Dictionary
# 4. A Dictionary in a Dictionary
print('*** 1. A List of Lists***')
countries = ['usa', 'russia', 'spain', 'france']
cities = ['new york', 'moscow', 'barcelona', 'paris']
companies = ['level up', 'abc company', 'ola company']
custo... | true |
20127e1855c3307e7b25812eccb46818d7db4609 | JoseVteEsteve/Lists | /LI_03.py | 289 | 4.1875 | 4 | #given a list of numbers, find and print all the elements that are greater than the previous element.
list = [1,3,7,9,2,4,11,10,8,5,14,16]
n = len(list)
max = 0
for i in range(n):
if list[i] > list[i - 1]:
print(str(list[i]) + " is greater than " + str(list[i - 1]))
| true |
a3d204581bd24365e6ebb3ce7fb1d750e795237f | tieje/holbertonschool-higher_level_programming | /0x0B-python-input_output/0-read_file.py | 240 | 4.1875 | 4 | #!/usr/bin/python3
"""This module reads a text file"""
def read_file(filename=""):
"""This method reads a file."""
with open(filename, mode="r", encoding="utf_8") as file:
for line in file:
print(line, end='')
| true |
32040098ac2f626214124dab1cc919b8aebd8eb9 | GaryGonzenbach/python-exercises | /control_structures_examples.py | 1,991 | 4.3125 | 4 | print('Good Morning Ada!')
i_like_coffee = True # switch to False to test else
if i_like_coffee:
print('I like coffee!')
else:
print('Ok - lets have some tea')
# ---
pizza_reference = input('What kind of pizza do you like?')
if pizza_reference == 'pineapple and hot sauce':
print('Wow - what a coincidence!... | true |
b27acfbc54aeae4b5741ed27fa849e09d9c8a46a | skyrydberg/LPTHW | /ex3/ex3.py | 1,251 | 4.25 | 4 | # Exercise 3: Numbers and Math
# I addressed Exercises 1 & 2 in the same post because they
# are trivial. This one gets its own post.
print "I will now count my chickens:"
# Note the order of operations holds here, a kind programmer
# would type this 25 + (30 / 6) for clarity, we divide 30 by 6
# and then add the res... | true |
618535ad2c3d769521c1a60f73b2e37f26ee5cc3 | GaddamMS/PythonMoshYT | /own_program_weather_notify_0.py | 1,481 | 4.4375 | 4 | '''Feature: Intimate user with precautions based on weather when going outside
Problem Statement: We should identify the weather and tell the user of necessary precautions
Solution:
1. We will ask the user for temperature
2. Based on the given temperature, we will intimate user with self - defined precautions
'''
... | true |
7b28907cfd5737677e3d0380f631272847cfe936 | monsybr11/FirstCodingAttempts | /textrealiser.py | 535 | 4.21875 | 4 | abc = input("Type any text in.\n")
abc = str(abc) # converting the input to a string in case of text and digits being used.
if abc.islower() is True:
print("the text is lowercase!")
if abc.isupper() is True:
print("the text is Uppercase!")
if abc.isupper() is False and abc.islower() is False and ... | true |
095c16d2e25fe3e5d076ea09bad8b18c0e0e140a | SastreSergio/Datacademy | /paper_scissors.py | 2,815 | 4.1875 | 4 | #A game of Scissors, paper and stone against the machine
import random
def choice_player2(): #Function with random for the other player, in this case: the machine
options = ['Scissors', 'Paper', 'Stone']
random_choice = random.choice(options)
return random_choice
def play(choice_player1, choice_player2):... | true |
27804af36166140fc6655be1c6fd1f60096f34ef | vickiedge/cp1404practicals | /prac_04/quick_picks.py | 584 | 4.125 | 4 | #relied heavily on solution for this exercise. Still not printing all quick picks
import random
MIN_NUMBER = 1
MAX_NUMBER = 45
NUMBER_PER_LINE = 6
number_of_quick_picks = int(input("How many quick picks? "))
for i in range(number_of_quick_picks):
quick_pick = []
for j in range(NUMBER_PER_LINE):
numbe... | true |
11ed3a0ab634d3fc1568dbfb38c9d9aff5aced21 | introprogramming/exercises | /exercises/fibonacci/fibonacci-iterative.py | 735 | 4.25 | 4 | '''An iterative version, perhaps more intuitive for beginners.'''
input = int(input("Enter a number: "))
def fibonacci_n(stop_after):
"""Iteratively searches for the N-th fibonacci number"""
if stop_after <= 0:
return 0
if stop_after <= 2:
return 1
prev = 1
curr = 1
count = 2... | true |
e435dd76259d6ad09b57f30f5b8b3647f565b086 | shea7073/Algorithm_Practice | /phone_number.py | 495 | 4.28125 | 4 | # Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string
# of those numbers in the form of a phone number.
def create_phone_number(arr):
if len(arr) != 10:
return ValueError('Array Must be 10 digits long!')
for i in arr:
if i > 9 or i < 0:
... | true |
dd7aa50d126ddab75b24da79f3b0ac1b0d61bcf3 | gy09/python-learning-repo | /PythonLearning/FunctionLearning/forLoop.py | 290 | 4.15625 | 4 | def upperConversion():
sentence = input("Enter the sentence to loop on:")
for word in sentence:
print(word.upper())
def listLoop():
friends = ["test1","test2","test3","test4"]
for friend in friends:
print(friend.upper())
upperConversion()
listLoop()
| true |
c2853f4bd7682ed91b22dd8040e727299bff2b52 | vharmers/Kn0ckKn0ck | /Parsing/Readers/Reader.py | 1,416 | 4.1875 | 4 | import abc
class Reader:
"""
Abstract class which defines the minimal functionality of Readers. You will need to extend from tis class
if you want to create your own reader.
"""
def __init__(self):
pass
@abc.abstractmethod
def get_count(self):
"""
Gets ... | true |
f2e3ddcbfedf9b3860590b28dbfd032e106e9390 | aayush2906/learning_curve | /for.py | 559 | 4.34375 | 4 | '''
You are given a number N, you need to print its multiplication table.
'''
{
#Initial Template for Python 3
//Position this line where user code will be pasted.
def main():
testcases=int(input()) #testcases
while(testcases>0):
numbah=int(input())
multiplicationTable(numbah)
print()
... | true |
a4e7ded1eac764352cb65888ba36ef4289bd6c4b | nathanesau/data_structures_and_algorithms | /_courses/cmpt225/lecture09/python/stack.py | 1,661 | 4.15625 | 4 | class Node:
def __init__(self, data):
self.data = data
self.prev = None
class StackLinkedList:
"""
linked list implementation of stack
- similar to singly linked list
"""
def __init__(self):
self.top = None
def push(self, data):
"""
add element to ... | true |
9a044231cb1d922651e6b3463e5f3696cf7b18af | nathanesau/data_structures_and_algorithms | /_courses/cmpt225/practice4-solution/question6.py | 892 | 4.1875 | 4 | """
write an algorithm that gets a tree and computes its
depth using iterative implementation.
"""
"""
write an algorithm that gets a tree and computes its size
using iterative implementation.
"""
from binary_tree import build_tree1, build_tree2, build_tree3
def get_depth(bt):
"""
use level-order iterative a... | true |
3875d9590a0a90962b5680329c571b9e300d4540 | Pranav2507/My-caption-project | /project 2.py | 398 | 4.125 | 4 | filename=input('Enter a filename: ')
index=0
for i in range(len(filename)):
if filename[i]=='.':
index=i
print(filename[index+1: ])
filename = input("Input the Filename: ")
f_extns = filename.split(".")
print ("The extension of the file is : " + repr(f_extns[-1]))
fn= input("Enter Filena... | true |
aba6611d825897b03b9d9c4a7adca8f2e6b66c69 | uniite/anagram_finder | /modules/util.py | 449 | 4.125 | 4 | import string
def remove_punctuation(word):
"""
Return the given word without any punctuation:
>>> remove_punctuation("that's cool")
'thatscool'
"""
return "".join([c for c in word if c in string.ascii_letters])
def save_anagram_sets(sets, output_file):
"""
Save the given list of a... | true |
5d8b5f6d8436b68596e79fd29672031d4e0fbd03 | kwstu/Algorithms-and-Data-Structures | /BubbleSort.py | 443 | 4.15625 | 4 | def bubble_sort(arr):
# Go over every element (arranged backwards)
for n in range(len(arr)-1,0,-1):
# For -1 each time beacuse each loop an elemnt will be set in position.
for k in range(n):
# Check with the rest of the unset elements if they are greater than one another if so, switch
... | true |
c608d17aeb079332cf51be22647352ce2abc5085 | titanlien/workshop | /task04/convert.py | 1,167 | 4.15625 | 4 | #!/usr/bin/env python3
import argparse
"""https://www.rapidtables.com/convert/number/how-number-to-roman-numerals.html"""
ROMAN_NUMERALS = [
(1000, 'M'),
(900, 'CM'),
(500, 'D'),
(400, 'CD'),
(100, 'C'),
(90, 'XC'),
(50, 'L'),
(40, 'XL'),
(10, 'X'),
(9, 'IX'),
(5, 'V'),
... | true |
06b8339073dff3c0e3207154c9a1277f63202956 | davidygp/Project_Euler | /python/prob4.py | 893 | 4.34375 | 4 | """
Problem 4:
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.
"""
def find_max_palin_product() -> int:
"""
Find the largest palindrome made from the... | true |
dd37b3f9e28b6c26000a9c94f1883c647708b3ae | razvitesting/Automation-Testing | /mylist.py | 206 | 4.125 | 4 | mylist = []
mylist.append(1)
mylist.append(2)
mylist.append(3)
print(mylist[0]) # prints 1
print(mylist[1]) # prints 2
print(mylist[2]) # prints 3
# prints out 1,2,3
for x in mylist:
print(x) | true |
044be8776e8a959acbac43836290556e632b3e99 | milindukey/Python | /Beginners/control loop.py | 1,022 | 4.375 | 4 | largestNumber = -99999999
counter = 0
number = int(input("Enter a number or type -1 to end program: "))
while number != -1:
if number == -1:
continue
counter += 1
if number > largestNumber:
largestNumber = number
number = int(input("Enter a number or type -1 to end program: "))
if co... | true |
4b41f7f1a744e6820d77049da3443faadacaa9a6 | Abinaya3198/shivanya | /f4.py | 211 | 4.34375 | 4 | al = input("enter the character : ")
if((al >= 'a' and al <= 'z') or (al >= 'A' and al <= 'Z')):
print("The Given Character ", ch, "is an Alphabet")
elif(al == '?'):
print("no")
else:
print("not an alphabet")
| true |
5fbc21600fc9ea53a5e16fa3a00389efecc8be91 | nitin-cherian/LifeLongLearning | /Web_Development_Python/RealPython/flask-blog/sql.py | 684 | 4.125 | 4 | # sql.py - Create a sqlite3 table and populate it with data
# import sqlite3 library
import sqlite3
# create a new database if the database already does not exist
with sqlite3.connect("blog.db") as connection:
# get a cursor object to execute sql commands
c = connection.cursor()
# create the table
... | true |
b70018a393d272324b542a0d6bc40ce0e1a5a23e | nitin-cherian/LifeLongLearning | /Python/Experiments/ITERATORS/Polyglot.Ninja/why_iterables.py | 494 | 4.75 | 5 | # why_iterables.py
print("""
Iterator behaves like an iterable in that it implements the __iter__ method. Then why do we need iterables?
When StopIteration is raised from an iterator, there is no way to iterator over the iterator again, because
iterator maintains the state and return self when iter is invoked on it. ... | true |
83b8306a533237034ce55d980ee49b44d9ba0f78 | nitin-cherian/LifeLongLearning | /Python/Experiments/ITERATORS/Polyglot.Ninja/iterators_should_be_iterable.py | 2,400 | 4.40625 | 4 | # iterators_should_be_iterable
print('''
According to the official doc:
*********
Iterators should implement the __iter__ method that returns the iterator object itself,
so every iterator is also iterable and may be used in most places where other iterables
are accepted.
*********
{code}
class HundredIterator:
... | true |
d0c3eee3504d0e0fb919e97c9396080bb70719b9 | indra-singh/Python | /prime_number.py | 350 | 4.125 | 4 | #Write a program to print if a number is a prime number *
n=int(input("Enter lower number :"))
m=int(input("Enter upper number :"))
print("Prime numbers between",n,"and",m,"are:")
for num in range(n,m+1):
if num > 1:
for i in range(2,num):
if (num % i) == 0:
break
els... | true |
4c7173d644078932261cf2f33aa568baf85671f1 | imaaduddin/TreeHouse-Data-Structures-And-Algorithms | /recursion.py | 297 | 4.125 | 4 | # def sum(numbers):
# total = 0
# for number in numbers:
# total+= number
# return total
# print(sum([1, 2, 3, 4, 5]))
# Recursive Function
def sum(numbers):
if not numbers:
return 0
remaining_sum = sum(numbers[1:])
return numbers[0] + remaining_sum
print(sum([1, 2, 7, 9]))
| true |
88891cba26521787b2d7eeecd1f2e558baf8f0fd | orhanyagizer/Python-Code-Challange | /count_of_wovels_constants.py | 549 | 4.3125 | 4 | #Write a Python code that counts how many vowels and constants a string has that a user entered.
vowel_list = []
constant_list = []
word = input("Please enter a word: ").lower()
for i in word:
if i in set("aeiou"):
vowel_list.append(i)
count_vowel = len(vowel_list)
else:
constant_list.append(... | true |
541d39fe2f6ef9cc7f86284554fc10a7fe0d7678 | JamesMcPeek/Python-100-Days | /Day 2.py | 342 | 4.125 | 4 | print("Welcome to the tip calculator!")
billTotal = float(input("What is the total bill? "))
percTip = int(input("What percentage tip would you like to give? "))
people = int(input("How many people will split the bill? "))
results = round((billTotal * (1 + (percTip / 100))) / people,2)
print("Each person should pay: " ... | true |
7419e55dcfacf0eab400524d1fd3cc1cbe5f48c6 | srajamohan1989/aquaman | /StringSlicer.py | 392 | 4.59375 | 5 | #Given a string of odd length greater 7, return a string made of the
# middle three chars of a given String
def strslicer(str):
if(len(str)<=7):
print("Enter string with length greater than 7")
else:
middleindex= int(len(str)/2)
print(text[middleindex-1:middleindex+2])
text=in... | true |
2d2c2f7ea670a516a2716d73a92d986b8498325e | joshl26/tstcs_challenge_solutions | /chapter14_ex1.py | 1,456 | 4.34375 | 4 | # This question actually does not make much sense
# because it is impossible to make a binary tree with no
# leaf nodes! My mistake!
class BinaryTree():
def __init__(self, value):
self.key = value
self.left_child = None
self.right_child = None
def insert_left(self, value):
if s... | true |
8053fdd5fed3a656f5e52ae6e66af9a62976500d | jnyryan/rsa-encryption | /p8_is_prime.py | 965 | 4.375 | 4 | #!/usr/bin/env python
"""
Implement the following routine:
Boolean fermat(Integer, Integer)
such that fermat(x,t) will use Fermat's algorithm to determine if x is prime.
REMEMBER
Fermat's theorm asserts that if n is prime and 1<=a<=n, then a**n-1 is congruent to 1(mod n)
"""
import p5_expm
import random
def i... | true |
efa2dcde8d6fddbcbea0ce5b0defa790986396ef | martinpeck/broken-python | /mathsquiz/mathsquiz-step3.py | 1,822 | 4.15625 | 4 | import random
# this function will print a welcome message to the user
def welcome_message():
print("Hello! I'm going to ask you 10 maths questions.")
print("Let's see how many you can get right!")
# this function will ask a maths question and return the points awarded (1 or 0)
def ask_question(first_number, ... | true |
b66bf8a200e19fe87eb82eaf0667bca53f7fc8c3 | sumitsrv121/parctice2 | /Excercise3.py | 227 | 4.1875 | 4 | def reverse_string(arr):
new_list = []
for x in arr:
new_list.append(x[::-1])
return new_list
fruits = ['apple','mango','orange','pears','guava','pomegranate','raspberry pie']
print(reverse_string(fruits)) | true |
12dda19350218d4ad3b9a4bbae13a72101bd44a5 | Chithra-Lekha/pythonprogramming | /co5/co5-1.py | 346 | 4.40625 | 4 | # Write a python program to read a file line by line and store it into a list.
l = list()
f = open("program1.txt", "w")
n = int(input("Enter the number of lines:"))
for i in range(n):
f.write(input("Enter some text:")+"\n")
f.close()
f = open("program1.txt", "r")
for i in f:
print(i)
l.append(i[... | true |
04aea542b7903d07b756e8a7287b720f8938a414 | Chithra-Lekha/pythonprogramming | /co2-8.py | 335 | 4.28125 | 4 | list=[]
n=int(input("enter the number of words in the list:"))
for i in range(n):
x=input("enter the word:")
list.append(x)
print(list)
length=len(list[0])
temp=list[0]
for i in list:
if len(i) > length:
length=len(i)
temp=i
print("the longest word is of length",... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.