blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
34570a16af836744f7cc65a04dd6a7ae0d570352 | Lyasinkovska/BeetRootPython | /lesson_23/task_1.py | 713 | 4.21875 | 4 | """
Write a program that reads in a sequence of characters and prints them in reverse order,
using your implementation of Stack.
"""
from collections import deque
def print_reversed_string(chars: str = '') -> None:
if not isinstance(chars, str):
try:
chars = str(chars)
except TypeError... | true |
8f9d8649dbcc2b6023c5d5d2d1bb2f88e834db8c | Haroldgm/Python | /HackerRank/find_string.py | 572 | 4.125 | 4 | # https://www.hackerrank.com/challenges/find-a-string/problem
def count_substring(string, sub_string):
occurrence_sub_string = 0
no_of_times_to_compare = (len(string) - len(sub_string)) + 1
for i in range(0,no_of_times_to_compare):
if string[i:i+len(sub_string)] == sub_string:
occurrenc... | true |
12945d5f192a2df2b02f4a794ff51d37aadd9462 | inayrus/Proteim | /Classes/Amino.py | 1,702 | 4.15625 | 4 | class Amino(object):
""" Representation of an amino acid """
def __init__(self, id, kind):
""" Initializes an amino acid """
self.id = id
self.kind = kind
self.conn = []
self.location = []
self.bond_strength = self.set_bond_strength(kind)
def get_id(self):
... | true |
4328a6f458454c203ff4a90bc7a55825fa12fec9 | vumeshkumarraju/class | /problemsheet4/code4.py | 296 | 4.28125 | 4 | #to print the string in a different manner
print("\n\t.......WELCOME TO THE PROGRAM.........")
string=input("Enter a string :- ")
if len(string)>=7:
new_string=string[0:7]+string[len(string)-2:]
print("The changed string is :- ",new_string)
else:
print("string size is not sufficient.")
| true |
219e9382db6d8d80c1d23306969ace34eafd55be | vumeshkumarraju/class | /problemsheet5/code6.py | 551 | 4.3125 | 4 | #to show all the disarium number in a given range
print("\n\t..........|| WELCOME TO THE PROGRAM ||.............")
print("we will print all the disarium numbers in your entered range.")
a=int(input("enter the starting range = "))
b=int(input("enter the ending range = "))
print("THE DISARIUM NUMBERS BETWEEN ",a," AND "... | true |
6ad62d8208bb94ad560d733913f6a0c9965339e5 | bhatiak2050/Learn-Python | /basic/strings.py | 1,214 | 4.46875 | 4 | name = "Sam"
age = 24
job = "Designer"
print("Name\t: %s\nAge\t: %s\nJob\t: %s" % (name, age, job))
name = "Hello World"
print(len(name)) #Length of the string
print(name.index('W')) #Index of character 'W'
print(name.count('o')) #No of occurances of 'o'
print(name[3:7]) ... | true |
d3a0cbcaa67ea7f7d83943642eeb893952c48542 | Blodhor/Random-Python-codes | /Recursion_fibonacci.py | 1,150 | 4.28125 | 4 | '''Using fibonacci sequence to show two forms of recursion'''
'''If you draw the recursion tree, you'll easly see how bad the recursion in fibo_lento is (exponential complexity).'''
def fibo_lento(n): #starts from 'n'
if n ==0 or n==1:
temp = 1
else:
temp = fibo_lento(n-2) + fibo_lento(n-1)
return temp
'''In ... | true |
9b17c90d3c22d835900cadfa9a160914fd82b07e | frapson/UniWorkPython | /week 8/practical 7/task 4.py | 1,352 | 4.40625 | 4 | def how_many_exact_letters(word, letter):
# if given parameter is NOT a string it throws an exception
if type(word) != str:
raise TypeError("must be str")
else:
# we count how many times given letter occurs
count = 0
for i in word:
if i == letter:
... | true |
55f78b8b833d27a7aca34ab5ccb36e589a9a2551 | jenjnif/arg-challenge | /new_arg_square.py | 984 | 4.40625 | 4 | # writing a python file to interpret arguments i.e from the command line
# including an argument that squares an int input
import sys
if len(sys.argv) == 1:
print('usage: ' + sys.argv[0] + ' [-h] square\n' +
sys.argv[0] + ': error: the following arguments' +
' are required: square')
if len(s... | true |
dd40c737c1b90730d02c91339b30a75bfb2582fe | emilykohler/ToolBox-WordFrequency | /frequency.py | 2,162 | 4.53125 | 5 | """ Analyzes the word frequencies in a book downloaded from
Project Gutenberg """
import string
def get_word_list(file_name):
"""
Reads the specified project Gutenberg book. Header comments,
punctuation, and whitespace are stripped away. The function
returns a list of the words used in the book as a list.
Al... | true |
064bfebba9e68c4ca5312ae1102f3d69b31f7d3c | perocha/first-python-test | /_07_tuples.py | 1,001 | 4.25 | 4 | '''
Typles examples
'''
mytuple = ("apple", "cherry", "banana") # parentesis
mylist = ["apple", "cherry", "banana"] # brackets
print ("\n ** Print list and tuple")
print (mytuple[0])
print (mytuple[1])
print (mytuple[2])
print (mylist[0])
print (mylist[1])
print (mylist[2])
# mytuple[1] = "strawberry" ----> ... | true |
d07268aeae245543473e6418a6c4ccc8e19e1bba | rneralla1/Data-Mining | /RNERALLA_DSC550_HYPERSPHERE_VOLUME.py | 755 | 4.4375 | 4 | # -*- coding: utf-8 -*-
"""
Hypersphere Volume: Plot the volume of a unit hypersphere as a function of dimension. Plot for d=1,⋯,50.
Author: Ravindra Neralla
"""
import matplotlib.pyplot as plt
from math import pi
from scipy.special import gamma
#Define list for volume
volume_arr=[]
#Define dimension fo... | true |
9a4e9be4b90a189e1a87c1ea4d31308c682a0ff8 | otecdima/UCU | /Lab4/18_number_of_capital_letters.py | 534 | 4.25 | 4 | def number_of_capital_letters(s):
"""
str -> str
Find and return number of capital letters in string. If argument isn't string
function should return None.
>>> number_of_capital_letters("ArithmeticError")
2
>>> number_of_occurence("EOFError")
4
>>> number_of_capital_letters(1)
... | true |
12ec6c739e5a056363f054b305452db3ab1d729c | kcjavier21/Python-Course | /Exceptions.py | 1,862 | 4.1875 | 4 | # === HANDLING EXCEPTIONS ===
# try:
# age = int(input("Age: "))
# except ValueError as ex:
# print("You didn't enter a valid age.")
# print(ex)
# print(type(ex))
# else:
# print("No exceptions were thrown.")
# === HANDLING DIFFERENT EXCEPTIONS ===
# try:
# age = int(input("Age: "))
# x... | true |
c94423ea3368816b3cfe8292b571842f9a939081 | MandyMeindersma/BFEX | /web/bfex/components/data_pipeline/tasks/task.py | 1,293 | 4.28125 | 4 | from abc import ABC, abstractmethod
class Task(ABC):
"""Task is a basic definition of a unit of work to be performed.
It is an abstract base class that cannot be instantiated on its own. Instead, implementations should be defined
and used.
"""
def __init__(self, task_name):
"""Creates a ... | true |
6c1e239ba07b038482b31cd635ebfeb1246b3f40 | cuet16/calculator | /Entry.py | 640 | 4.3125 | 4 | from tkinter import *
root = Tk()
e = Entry(root, width = 50, bg = "cyan")
e.pack()
e.get()
e.insert(0, "enter your name: ") # this puts a default text inside the box
def myClick():
myLabel = Label (root, text = "Hello " + e.get())
myLabel.pack()
myButton = Button(root, text = "Enter your name", padx = 50,... | true |
069f6a4f85e5eb3cc4c3943e049155aac0298a46 | tv-sandeep/PythonApplication | /changeCasing.py | 466 | 4.25 | 4 | InputStr = input("Enter input string: ")
if InputStr.islower():
print("Input string is lower case")
elif InputStr.isupper():
print("Input string is upper case")
else:
print("Input string is neither lower case nor upper case")
changeCasingTo = int(input("Enter value to convert to upper 1, to lower 2: "))
... | true |
661725e821b7ea2571d135c00bd53524777901f9 | ARJITVIJEY-GIT/Python_basics | /Swap_two_Variables.py | 725 | 4.40625 | 4 | #Swap 2 variables
a = 5
b = 6
temp = a #here we assigning a third variable temp to store the value of a so that it will print both a and b
a = b
b = temp
#after print(a) and print (b)
#output : 6
#output : 5
#other way, without using ... | true |
881388ec7ddf0fdf77b0a27eaa80035757c87ab3 | paulocoliveira/coding-challenges | /most_frequent.py | 1,544 | 4.34375 | 4 | #Most Frequently Occurring Item in an Array (Python)
#Find the most frequently occurring item in an array.
#Example: The most frequently occurring item in [1, 3, 1, 3, 2, 1] is 1.
#If you're given an empty array, you should return None.
#You can assume that there is always a single, unique value that appears most frequ... | true |
4aa80ea51fc1b646140bf22a2919931dcc17eee2 | DanielMorton/ratel-py | /ratel/util/counter.py | 2,744 | 4.125 | 4 |
class Counter:
"""Basic counter class. Increments by one on calls to `iterate`
:param _counter: The current value of the counter.
:type _counter: int
"""
def __init__(self):
"""Constructor method."""
self._counter = 0
@property
def counter(self):
"""Returns the cu... | true |
162683f50a04050b09ae96ddf8371897a2b41936 | Charvi04/Number_Guessing_Game | /NumberGuessingGame.py | 897 | 4.3125 | 4 | # This is a number guessing game in which you need to guess a number between 1 and 9. Lets see if you can the number in 5 moves.
# Importing random component here
import random
# Creating the variables here
player_name = input("Hello, What is your name ? ")
number_of_guesses = 5
number = random.randint(1, 9)
... | true |
232834a95dcabe1c29cce3a50e5c6c1f6b669e19 | vikas11009/basic- | /calculater.py | 353 | 4.21875 | 4 | print"claculater"
num1=input("enter 1st number for operation: ")
num2=input("enter 2nd number for operation:")
print"press a for addition, b for subtraction, c for multiplication, d for division"
x=raw_input("type of operation: ")
if x=="a":
c=num1+num2
elif x=="b":
c=num1-num2
elif x=="c":
c=num1*num2
el... | true |
ec8db0c8501aa3b08f308350c6bc1e0769eb65d6 | dukeofdisaster/CodeWars | /divisors.py | 1,568 | 4.125 | 4 | # divisors.py
#
# for this challenge we had to find the divisors
# of a given integer otherwise return a message saying that otherwise
# return a message saying that the number was prime.
#
# We recall that modulo (%) is frequently used in such
# operations so that will be part of our solution.
#
def divisors(integer)... | true |
df13f4b22ff001af81f10479a74adb834771e2ce | fatpav/day_2_homework | /my_functions.py | 2,205 | 4.59375 | 5 | # def command 'defines' a function
# The colon at the end indicates there will be code inside the function
# def greet():
# print("Hey there")
# greet()
# The function is 'called' with the function name and brackets
# I also left 2 blank spaces after the function to show the end
# the return command is used w... | true |
cc7705e956017bd3a1dc62c5cfe13bc683513862 | theSaintBelial/PythonJedi | /lets_remember/simple_progams/fibonacci.py | 381 | 4.3125 | 4 |
def fibonacci_search(index: int):
prev_elem = 1
cur_elem = 1
if index < 1:
return (-1)
if index < 2:
return (0)
if index < 4:
return (1)
for i in range(3, index):
tmp = cur_elem
cur_elem = cur_elem + prev_elem
prev_elem = tmp
return (cur_elem)
index = int(input("Enter the index of Fibonacci sequen... | true |
8af2e56eeb58ef9da44f6a2d48e81d608bb04942 | erpost/python-beginnings | /etc/while-for_else_uses.py | 690 | 4.25 | 4 | # for/else statements
fruits = ['banana', 'apple', 'orange', 'pear', 'tomato', 'grape']
print('You have...')
for f in fruits:
if f == 'tomato':
print('A tomato is not a fruit!') # (It actually is.)
break
print('A', f)
else:
print('A fine selection of fruits!')
###########################... | true |
5dd1dded5a555fc9350ba3cf841953d687f76eaf | AbhishekBhattacharya/BertelsmannUdacityDataScienceScholarship18 | /functions_lesson_26/generator.py | 966 | 4.25 | 4 | # square_number function returns a list of squared numbers
def square_numbers(nums):
result = []
for i in nums:
result.append(i * i)
return result
my_nums = square_numbers([1, 2, 3, 4, 5])
print(my_nums)
print('\n')
# generator
"""
generator don't hold the entire result in memory it yields on... | true |
6056589d8ddaea1f9c117e06eaf65652feccdb08 | Lnknaveen/python_basics | /if_statements.py | 645 | 4.21875 | 4 | is_hot = False
is_cold = False
if is_hot:
print("It's a hot day!")
print("Drink plenty of water")
elif is_cold:
print("It's a cold day!")
print("Wear warm cloths")
else:
print("It's a lovely day")
print("Enjoy your day!")
# ------ Logical
has_high_income = True
has_good_credit = True
if has_hig... | true |
2601027b85ac6ff139ab1f07a75f06419a6960c7 | sabmalik/ml-fun | /linear-regression/simple_linear_regression.py | 1,975 | 4.25 | 4 | # Load numpy, the charting library and scikit-learn the libraries
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
# Load the house area in an array and reshape it to an array of arrays
# that ML can understand. This is on the x-axis and we usually
# represent it wit... | true |
25602054911534a7fbce0940895340b58a5cc60d | xavierliang-XL/git-geek | /geekprogramming/test/gradeifelse.py | 219 | 4.125 | 4 | grade=input("whats ur grade?")
if grade.isnumeric():
grade=int(grade)
res="excellent"if grade >= 90 else "good"if grade >= 75 else "pass"if grade >= 60 else "fail"
print(res)
else:
print("invalid input") | true |
70cabde4fcb4dde29803f0579be9ebdcd7501e16 | xavierliang-XL/git-geek | /python08/python08/homework/listpractice06.py | 213 | 4.15625 | 4 | list=[1,1,2,3,4,4,5]
def getEle(list):
"""
the method is to remove the repeating times of elements
list:the list which contains elements
"""
list2=set(list)
return list2
print(getEle(list)) | true |
edeb7344a1eadcc50bc3e91948b4251bcd524f5d | xavierliang-XL/git-geek | /python08/python08/homework/listpractice04.py | 376 | 4.25 | 4 | list1=[[2,1],2,3,[2,4],5,1]
def insert_list(list1):
"""
this method is to replace the elements that have a list type
list1: the list you want to change
"""
for i in range(len(list1)):
if type(list1[i])==list:
list2=list1.pop(i)
for j in range(list2[0]):
list1.inser... | true |
e4d9939cc320f00870900b09064ae876ea05d57d | xavierliang-XL/git-geek | /python08/python08/list/ListDemo10.py | 323 | 4.34375 | 4 | # num_list = [4,2,7,10,5,8]
# #num_list.sort()
#
# num_list.sort(reverse=True)
# print(num_list)
name_list = ["ab","a","aa","abc","bc","ac"]
def sortList(name_list):
"""
this method is to sort the list from smallest to greatest
name_list:list
"""
name_list.sort()
return(name_list)#a,aa,ab,abc,ac... | true |
2d52096a361e060a3f55319ad810b4bed73246d1 | lalebdi/PythonAlgos | /Find_Bitonic_Peak.py | 1,340 | 4.21875 | 4 | """
Problem:
Given an array that is bitonically sorted,
an array that starts off with increasing terms and then concludes with decreasing terms.
In any such sequence, there is a "peak" element, that is, the element in the sequence that is the largest element.
find the peak element of a bitonic sequence.
"""
... | true |
2b6be1ee0a857b531dd191e8bdcf8efa83b3cd5c | liming2013/python-resourses | /basic/test_while.py | 398 | 4.125 | 4 | #!/usr/bin/python
count = 0
while (count < 9):
print 'The count is:', count
count = count + 1
print "Good bye!"
i = 1
while i < 10:
i += 1
if i%2 != 0:
continue
print i
i = 1
while 1:
print i
i += 1
if i > 10:
break
count = 0
while count < 5:
print count, " is ... | true |
9ffd568a2799bf486eac8a3ba7a68da2a8df0bf1 | MarlieI/Python-exercises | /counter_program.py | 785 | 4.1875 | 4 | # Challenge 1, chapter 4 python for the absolute beginner
# This program counts for the user.
# The user enters the starting number, ending number and the amount by which to count.
print("Welcome to the counting program.")
start = int(input("\nPlease choose the starting number: "))
end = int(input("Please choo... | true |
ed0eecd8379fc320034904206659b780e950355b | redoctopus/Sentiment-Analysis-Book-Reviews-2014 | /WordParsing.py | 1,728 | 4.15625 | 4 | ## Jocelyn Huang
## 09/10/2013
## Three Letter Words
import string
s = "this, I am a fan of is it's a string with words that have the one to not exactly three letter rule."
#s = "that isn't good not bad not great not horrible really I need a small word cool aint great though"
#
#-----------------<Removes punctuation>... | true |
47a26c44b5ef0ac125ab156c97d2ef2e28851901 | smbsimon/web-code-test | /board.py | 792 | 4.1875 | 4 | class Board():
def __init__(self):
"""Initialize board with three rows"""
self.board = [
["_", "_", "_"],
["_", "_", "_"],
["_", "_", "_"],
]
def draw_board(self):
"""Create a new instance of the board"""
print self.board
def is_... | true |
05207e42d7f890a1782b371b20b246fd0c9483d5 | dougal428/Daily-Python-Challenges | /Challenge 31.py | 1,439 | 4.15625 | 4 |
#This problem was asked by Google.
#The edit distance between two strings refers to the minimum number of character insertions, deletions,
#and substitutions required to change one string to the other. For example, the edit distance between “kitten” and “sitting”
#is three: substitute the “k” for “s”, substitute... | true |
fb0a104a0cbbc27608832d6713528ff7e041dbba | dougal428/Daily-Python-Challenges | /Challenge 9.py | 1,043 | 4.21875 | 4 | #This problem was asked by Airbnb.
#Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or (-).
#For example, [2, 4, 6, 8] should return 12, since we pick 4 and 8. [5, 1, 1, 5] should return 10, since we pick 5 and 5.
# import sus
import sys
#se... | true |
2cf1dfe7cec077497ba7b465dd0e9226079bc228 | ncfausti/python-algorithms | /Greedy.py | 424 | 4.1875 | 4 | """
Some functions that work use greedy algorithms.
1. Making change problem
"""
def smallest_change(x):
"""
1. Making change problem.
Given an input x, this function will return
the minimum number of coins required to make
that exact amount of change.
"""
pass
assert(smallest_change(5)... | true |
804ecc65375e9569b489c406f368364625a1fad6 | Harikishore4461/House-of-Python | /task4.py | 595 | 4.3125 | 4 | #Creating The List
my_list = list()
my_list.append(2)
my_list.append(4)
my_list.append(1)
my_list.append(5)
my_list.append(3)
# Remove the last element from the list
my_list.pop()
#Remove the specific element
my_list.remove(2)
#Max num from the list
maximum = max(my_list)
print(f"Maximum number from the list is {maxi... | true |
877e67db7ce6e117db8db97083e88943656ba4f0 | grbalmeida/hello-python | /programming-logic/conditional-structures/in.py | 355 | 4.28125 | 4 | name = 'Luiz Otavio'
if 'L' in name:
print('The letter L is contained in the name')
if 'u' in name:
print('The letter u is contained in the name')
if 'i' in name:
print('The letter i is contained in the name')
if 'z' in name:
print('The letter z is contained in the name')
if 'j' not in name:
print('The l... | true |
55f9e346c3f5f140842d9005eb452182ff179a0f | grbalmeida/hello-python | /programming-logic/lists/unpacking-lists.py | 354 | 4.125 | 4 | names = ['Luiz', 'John', 'Maria', 'Jorge', 'Luisa']
first_name, second_name, third_name, *other_names, last_of_the_list = names
print(first_name)
print(second_name)
print(third_name)
print(other_names)
print(last_of_the_list)
other_list = [1, 2, 3, 4, 5]
*top_of_list, penultimate, last = other_list
print(top_of_lis... | true |
e469124b6fadd4026601a77d547fd554134b2b43 | acctwdxab/162-project-4b | /box_sort.py | 1,825 | 4.625 | 5 | # Dan Wu
# 1/26/2021
# 4b - Write a Box class whose init method takes three parameters and uses them to initialize the private length,
# width and height data members of a Box. It should also have a method named volume that returns the volume of the Box.
# It should have get methods named get_length, get_width, and get... | true |
4521c275d315dadaf4451593e00114e6aa5c6c25 | groovycol/calculator-2 | /calculator.py | 2,102 | 4.15625 | 4 |
from arithmetic import *
def format_input():
""" Collects user's raw input and returns it as a list."""
original_input = raw_input("> ")
original_input = original_input.strip()
formatted_input = original_input.split(" ")
return formatted_input
def convert_tokens_to_int(user_input):
"""Conv... | true |
a27817309eb386f83427cbe61f893596062c7528 | TheTechTeen/CIS-110-Portfolio | /easter_calculator.py | 1,034 | 4.375 | 4 | # Easter Calculator
# Calculates the date of easter any year from 1900 to 2099
# Aiden Dow
# 11/2/2019 - Revised 12/21/2020
import datetime
def easterDate(year):
# Calculates the date of easter
a = year % 19
b = year % 4
c = year % 7
d = (19 * a + 24) % 30
e = (2 * b + 4 * c + 6 * d + 5) % 7
... | true |
3bbf1ad0a26d88e8fdf7463005bca4255be4dcae | jordantiu/Python_Lesson_2 | /Lesson_2_Program_3.py | 1,264 | 4.28125 | 4 | # Write a python program to count number of words and characters in a file for each line and then print the output.
# Input: a file includes two line
# Python Course
# Deep learning class
# Output:
# Python Course --- “word”: 2, “letter”: 12
# Deep Learning class --- “word”: 3, “letter”: 17
file_name = input... | true |
981fcdb04132df1b3f11517d84b31cbd4396e891 | JC6152018/CTI-110 | /P5HW2_GuessingGame_JessicaWashington.py | 1,488 | 4.375 | 4 | #This program will run a random number guessing game
#With the user until they guess correctly.
#July 6th, 2018
#CTI-110 P5HW2 - Random Number Guessing Game
#Jessica Washington
#Start the random module.
import random
#Create the game.
number = random.randint(1, 100)
#Ask the user to guess the number.
de... | true |
a72f4dbc5242039c314597670a11e51e841526c0 | JC6152018/CTI-110 | /P4HW3_Factorials_WashingtonJessica.py | 479 | 4.5 | 4 | #P4HW3 Factorial
#CTI 110
#Jessica Washington
#July 3rd, 2018
#This program will display the factorial of a number.
factorial = 1
#Collect info from user.
print ('Enter a nonnegative integer:')
#Input number.
num = int(input())
#Create the loop.
if num == 0 or num == 1:
print ('The factorial... | true |
0afb7be045b594af17d7c3122f52e41716482809 | altarim992/CS112-Spring2012 | /hw07/sort.py | 474 | 4.15625 | 4 | #!/usr/bin/env python
"""
Selection sort
This is my selection sort, it's not working right!!!
I used this:
http://en.wikipedia.org/wiki/Selection_sort
"""
from hwtools import input_nums
nums = input_nums()
print "Before sort:"
print nums
length = len(nums)
for x in range(length):
index = x
for i in rang... | true |
3bf5a525a25305abb8e265f89ed1179a1a61cd48 | manaschaturvedi/python-course-data | /Python problem solutions/guess_the_number.py | 863 | 4.4375 | 4 | '''
Implement the 'Guess the number' game in Python. You will first set a particular integer as the final answer,
and then ask the user to guess the number by taking his input. If the guess of the user is less than the final
answer, print 'Your guess was less than the answer' and take input from the user again. Simila... | true |
5a5e4c40d12342ef8e211ae539e0c8028cb2c92b | akaif95/Travis-The-Security-Robot- | /Travis.py | 1,286 | 4.25 | 4 | #This is a simple little program that checks to see if someone is in
#A list of known users. If you are in the list, kudos! If not, then
#Travis, the security program will ask you if you would like to be
#Added to the list
known_users = ["Andrew", "Billy", "Clarice", "Dumont", "Eugene", "Felix", "Greg", "Harold"]... | true |
ec3275be22b11afb8a9bb019a61990810889f5ae | xavishacodes/Data-Structures-and-Algorithms-using-python-infytq-part-1-and-2 | /List using Array/list using array exercise.py | 1,301 | 4.21875 | 4 | #lex_auth_012742471863279616506
# Problem Statement
# A teacher has given a project assignment to a class of 10 students.
# She wants to store the marks (out of 100 ) scored by each student. The marks scored are as mentioned below:
# 89,78,99,76,77,67,99,98,90
# Write a python program to store the marks in a list and... | true |
b5300aa6ca4c22613bb1c487948a1f7a936717e2 | xavishacodes/Data-Structures-and-Algorithms-using-python-infytq-part-1-and-2 | /List using Array/Assignments/list of strings assignment.py | 1,008 | 4.1875 | 4 | # Problem Statement
# Given two lists, both having String elements,
# write a python program using python lists to
# create a new string as per the rule given below:
# The first element in list1 should be merged with last element in list2,
# second element in list1 should be merged with second last
# element in li... | true |
4e335ae1c05ef211c16953d664d6f4253f1c8af5 | jparr721/DataStructures | /scratch/BinaryTree/binary_tree.py | 2,762 | 4.15625 | 4 | class Node(object):
def __init__(self, data=None, left_node=None, right_node=None):
self.data = data
self.left_node = left_node
self.right_node = right_node
class BinaryTree(object):
def __init__(self, root=None):
self.root = root
@property
def is_empty(self) -> bool:
... | true |
ff569ad5c66a12e5e77614ee4251d9a565ac20cf | Czuki/TicTacToe | /board.py | 515 | 4.125 | 4 | def show_board(board): # draws a board which is held in a list of lists
for i in range(3):
for j in range(3):
print(board[i][j],
end='') # empty 'end' argument in print statement to avoid printing new line when drawing rows
print('\n') # new line after full row is dr... | true |
e030677aff04d3578f3bd278b5e3a0e8b27e689e | nisheshthakuri/Python-Workshop | /JAN 19/Assignment/Conditional statement & Loop/Q7.py | 544 | 4.1875 | 4 | Q.Program to check the validity of password input by users.
import re
x= input("Input your password")
a= True
while a:
if (len(x)<6 or len(x)>12):
break
elif not re.search("[a-z]",x):
break
elif not re.search("[0-9]",x):
break
elif not re.search("[A-Z]",x):
... | true |
c6a9b210aaa397ec509ce0fd16e3b77ea2422352 | nisheshthakuri/Python-Workshop | /JAN 19/Assignment/Functions/Q4.py | 254 | 4.34375 | 4 | Q.Define a function is_even that will take a number x as input.If x is even, then return True.
Otherwise, return False.
Solution:
def is_even(x):
if x % 2 == 0:
return True
else:
return False
print(is_even(7))
print(is_even(8))
| true |
d24927d85984635ec9a5d690295420b57723cd34 | yogeshrnaik/programming-problems | /python/src/vanhack/currency/currency.py | 1,612 | 4.28125 | 4 | """
Overview
Create a class Currency with two methods, numWays(amount) and minChange(amount).
A Currency instance will be initialized with an array of denominations of coins.
The class will use its two methods to determine how many ways you can make change with the denominations
and what the minimum count of each coin ... | true |
b29adcbfbbb76a9451cba9c5df36584e5561d47f | krmkrl/sandbox | /python/lintcode/reverse_linked_list.py | 1,234 | 4.3125 | 4 | import unittest
#Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
class Solution:
"""
@param head: The first node of the linked list.
@return: You should return the head of the reversed linked list.
Rever... | true |
1355d39b39dd4721ee5e8a5afcd1ecb48dc449e1 | Gubudeng/Practice | /Function/minmax.py | 327 | 4.125 | 4 | def minmax(data):
"""Find the minimum and maximum values in the sequence of numbers."""
a = len(data)
max = data[0]
min = data[0]
for i in range(a):
if max < data[i]:
max = data[i]
if min > data[i]:
min = data[i]
return (min,max)
print (minmax([1,2,4,5,7,... | true |
9687061900da13120e8143eb6c81873cfdfb2966 | kartiks98/Python-Simple-Programs-in-EASIEST-way- | /Vowel-Constant.py | 323 | 4.21875 | 4 | x = input("Enter a character : ")
if len(x) > 1 and (("a" <= x <= "z") or ("A" <= x <= "Z")):
print("Please enter only one character")
elif x == "a" or x == "A" or x == "e" or x == "E" or x == "i" or x == "I" or x == "o" or x == "O"or x == "u" or x == "U":
print("It's a Vowel")
else:
print("It's a Consonant... | true |
a97ca871106234bc3d1f38e19f3e91e2fc2018f1 | popkdodge/cs-module-project-recursive-sorting | /src/sorting/sorting.py | 1,540 | 4.28125 | 4 | # TO-DO: complete the helper function below to merge 2 sorted arrays
def merge(arrA, arrB):
merged_arr = []
while (arrA and arrB):
if (arrA[0] <= arrB[0]):
item = arrA.pop(0)
merged_arr.append(item)
else:
item = arrB.pop(0)
merged_arr.append(item)... | true |
588e8371d9b95d4901aaab37f2e6fc5284d2384f | ry-blank/Module-6-Functions-Default-Values-Assignment | /validate_input_in_functions.py | 770 | 4.375 | 4 | """
Program: validate input in functions
Author: Ryan Blankenship
Last Date Modified: 10/3/2019
The purpose of this program is to accept user input
then validate if good or bad input.
"""
def score_input(test_name, test_score=0, invalid_message='Invalid test score, try again!'):
"""
:param test_n... | true |
cbddae81f73ca5cf2deab9256401dfca440047a9 | EliNovakova/pong-game | /paddle.py | 943 | 4.15625 | 4 | from turtle import Turtle
class Paddle(Turtle): # inherits from Turtle class
def __init__(self, position): # we have to type in a tuple (coordinates) when creating an object from this class
super().__init__() # calls super class' init
self.shape("square") # all turtles start off by 20x20
... | true |
6ec76f181adefbdf317c91337b24ee555388fe4b | boymennd/100-day | /Beginner (Day 1 - day 14)/day 8/prime_number_checker.py | 307 | 4.125 | 4 | def prime_number_checker(number):
prime = True
for a in range(2,number):
if number % a ==0:
prime = False
if prime:
print("Is prime number")
else:
print( "Is not prime number")
number_input = int(input("Number input:"))
prime_number_checker(number_input) | true |
21fdbb9b155e17d690cceb0b240a5c1615aae2f0 | hvl5451/HW4_New | /manager.py | 1,803 | 4.125 | 4 |
"""
Manager is inherited from Employee and has the option to edit the customer details.
Manager has the option to edit customer details like name, birthdate, phone number.
Manager can create account for customer and remove customer's account
"""
import datetime
from employee import Employee
from customer import Custom... | true |
dcefe03180a3cc0955015d3cc923a72142d81767 | xalvatorg/Print-heart-using-python-tranding | /heart.py | 596 | 4.25 | 4 | import turtle
wn = turtle.Screen()
wn.setup(width=400, height=400)
red = turtle.Turtle() #For Assigning "Red" as name of the turtle
def curve(): #For Method to draw curve
for i in range(200): #For To draw the curve step by step
red.right(1)
red.forward(1)
def heart(): #For Method to dra... | true |
6dead5b8a40345eea77ba37335724f2e06252121 | JagritiG/interview-questions-answers-python | /code/set_2_linkedlist/insert_in_sorted_linked_list.py | 1,161 | 4.5 | 4 | # Insert in a sorted linked list
# Example:
# Input: 1->2->4, val = 3
# Output: 1->2->3->4
# ======================================================================================
# Algorithm:
# TC:
# SC:
# ========================================================================================
class SllNode:
d... | true |
1a4c6a1d323824f8ab099b67c87d27527a93600e | JagritiG/interview-questions-answers-python | /code/set_19_string/49_group_anagrams.py | 964 | 4.34375 | 4 | # Group Anagrams
# Given an array of strings, group anagrams together.
# Example:
# Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
# Output:
# [
# ["ate","eat","tea"],
# ["nat","tan"],
# ["bat"]
# ]
# Note:
# All inputs will be in lowercase.
# The order of your output does not matter.
# ====================... | true |
50f4c12d3976b89a0ada6966fdfb900789b965d4 | JagritiG/interview-questions-answers-python | /code/set_1_array/217_contains_duplicate.py | 1,134 | 4.25 | 4 | # Contains Duplicate
# Given an array of integers, find if the array contains any duplicates.
# Your function should return true if any value appears at least twice in the array,
# and it should return false if every element is distinct.
# Example 1:
# Input: [1,2,3,1]
# Output: true
# Example 2:
# Input: [1,2,3,4]
#... | true |
612e3915b5b14e203f121292d786db95c23f1882 | JagritiG/interview-questions-answers-python | /code/set_1_array/442_find_all_duplicates_in_an_array.py | 1,550 | 4.1875 | 4 | # Find All Duplicates in an Array
# Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.
# Find all the elements that appear twice in this array.
# Could you do it without extra space and in O(n) runtime?
# Example:
# Input:
# [4,3,2,7,8,2,3,1]
# Output:
# [2... | true |
92d61573f163cc264a1c3357554348a137fda00e | JagritiG/interview-questions-answers-python | /code/set_1_array/287_find_the_duplicate_number.py | 1,532 | 4.25 | 4 | # Find the Duplicate Number
# Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive),
# prove that at least one duplicate number must exist. Assume that there is only one duplicate number,
# find the duplicate one.
# Example 1:
# Input: [1,3,4,2,2]
# Output: 2
# Example 2:
# I... | true |
869f94f1c65012d1807c0b608054956203b7f6ad | JagritiG/interview-questions-answers-python | /code/set_20_tree/104_maximum_depth_of_binary_tree.py | 1,550 | 4.25 | 4 | # Maximum Depth of Binary Tree
# Given a binary tree, find its maximum depth.
#
# The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
#
# Note: A leaf is a node with no children.
#
# Example:
#
# Given binary tree [3,9,20,null,null,15,7],
#
# 3
# / \... | true |
f6cbc564aa51e0029101a6069ab33ed5e3c9e82f | JagritiG/interview-questions-answers-python | /code/set_1_array/53_maximum_subarray.py | 761 | 4.15625 | 4 | # Maximum Subarray
# Given an integer array nums, find the contiguous subarray (containing at least one number)
# which has the largest sum and return its sum.
# Example:
# Input: [-2,1,-3,4,-1,2,1,-5,4],
# Output: 6
# Explanation: [4,-1,2,1] has the largest sum = 6.
# =================================================... | true |
999b9cd7fe2284a67b47d7781c8a9786ca31ed8b | JagritiG/interview-questions-answers-python | /code/set_19_string/3_longest_substring_without_repeating_characters.py | 1,334 | 4.1875 | 4 | # Longest Substring Without Repeating Characters
# Given a string, find the length of the longest substring without repeating characters.
# Example 1:
# Input: "abcabcbb"
# Output: 3
# Explanation: The answer is "abc", with the length of 3.
# Example 2:
# Input: "bbbbb"
# Output: 1
# Explanation: The answer is "b", w... | true |
ddf6a65a23dfa2621f3de44d4b6ac127fad4ee6d | elixxx/Nature-inspired-Algorithms | /problems/differential_evolution/test_demand.py | 754 | 4.1875 | 4 | import numpy as np
import matplotlib.pyplot as plt
price = np.linspace(-0.1, 1, 1000)
def demand(price, max_demand, max_price):
# if price is greater than max price, return 0
if price > max_price:
return 0
# if product is free return max_demand (ignore negative price)
if price <= 0:
... | true |
996abd8d88c25b9459612340705943a1d945aa2e | somnam/problems | /codility/06_max_product_of_three.py | 2,314 | 4.25 | 4 | """
A non-empty array A consisting of N integers is given. The product of triplet (P, Q, R) equates to A[P] * A[Q] * A[R] (0 ≤ P < Q < R < N).
For example, array A such that:
A[0] = -3
A[1] = 1
A[2] = 2
A[3] = -2
A[4] = 5
A[5] = 6
contains the following example triplets:
(0, 1, 2), product is −3 ... | true |
5665ddbfc9bb2f531b28604f50e59d1b78043fb9 | debolina-ca/my-projects | /Python Codes 2/Seat Type Count.py | 779 | 4.125 | 4 | # Seat Type Count
# initilize variables
seat_count = 0
soft_seats = 0
hard_seats = 0
num_seats = 4
# loops tallying seats using soft pads vs hard, until seats full or user "exits"
while True:
seat_type = input("Enter seat type \"soft\" or \"hard\" or enter \"exit\" to finish: ")
if seat_type.lower(... | true |
89d507f16dac984c6d0734d2e1f39b9437fa75e7 | debolina-ca/my-projects | /Python Codes 2/book_title.py | 308 | 4.4375 | 4 | # Get input for a book title, keep looping while input is Not in title format (title is every word capitalized)
title = ""
title = input("Enter a book title: ")
while title != title.title():
title = input("Enter a book title: ")
print("Correct, your format is right for the book title: ", title)
| true |
1aac9ad2635bef65862989cacaf1350f56567db3 | debolina-ca/my-projects | /Python Codes 2/function_quiz_item.py | 463 | 4.1875 | 4 | # Function: Quiz Item
question_1 = "What's the capital of Canada? "
question_2 = "Name the main city in Nova Scotia? "
question_3 = "Material from which animal is widely used to keep warm in Canada? "
solution_1 = "a"
solution_2 = "b"
solution_3 = "c"
def quiz_item(question, solution):
answer = input(questi... | true |
682c3df913011bf2854241957122c66dddd44f7c | debolina-ca/my-projects | /Python Codes 2/list_o_matic Function.py | 771 | 4.25 | 4 | # Program: list-o-matic Function: Module 2 Required Coding Activity
list1 = ["cat", "tiger", "cat", "lion"]
def list_o_matic(string, list):
if string == "":
return list.pop(), "popped from the list"
list.pop()
else:
if string in list:
list.remove(string)
... | true |
faf636a1b4bf9b32b8731989de0f2287be438d4f | debolina-ca/my-projects | /Python Codes 2/Practice Task 6 - Module 3.py | 563 | 4.46875 | 4 | # Task 6 - .sort() and sorted()
# sort the list element, so names are in alphabetical order and print elements
elements = ['Hydrogen', 'Helium', 'Lithium', 'Beryllium', 'Boron', 'Carbon', 'Nitrogen', 'Oxygen', 'Fluorine', \
'Neon', 'Sodium', 'Magnesium', 'Aluminum', 'Silicon', 'Phosphorus', 'Sulfur', 'Chlorine', 'A... | true |
8f47151baadc25eb97a18d1e6cfc84e44b7a2387 | debolina-ca/my-projects | /Python Codes 2/Practice Task 2 - Module 3.py | 1,057 | 4.1875 | 4 | # Task 2 - iteration with range(start) & range(start,stop)
# [ ] using range() print "hello" 4 times
for index in range(4):
print("hello")
# [ ] find spell_list length
# [ ] use range() to iterate each half of spell_list
# [ ] label & print the first and second halves
spell_list = ["Tuesday", "Wednesda... | true |
ab8675400ec11cdfdf796106d0853dc3eca0e8ea | debolina-ca/my-projects | /Python Codes 1/Date Object.py | 313 | 4.375 | 4 | # Date Object
from datetime import date
# assign a date
SomeDate = date(year = 2015, day = 28, month = 2)
print("Old date: ", SomeDate)
# modify year and day
# 2016 is a leap year, so we can set the date to Feb 29 2016
SomeDate = SomeDate.replace(year = 2016, day = 29)
print("New date: ", SomeDate)
| true |
f02824d2a22d8d125ae5136894d18606907e4229 | debolina-ca/my-projects | /Python Codes 1/Practice Task 2 - Coin Calculators.py | 1,327 | 4.25 | 4 | # COIN CALCULATORS - Practice Task 2 using Mathematical Operators
# Develop functions to count the number of coins in a certain dollar amount and then
# write a program that can calculate the change due to a customer in coins
# [ ] Complete the function `quarters_count` so it calculates and prints the number of qu... | true |
0a39b739f0c36bc40d30c44af10a082f8fb27edb | debolina-ca/my-projects | /Python Codes 2/Practice Task 3 - Module 3.py | 1,844 | 4.46875 | 4 | # Task 3 - iteration with range(start:stop:skip)
# [ ] create a list of odd numbers (odd_nums) from 1 to 25 using range(start,stop,skip)
# [ ] print odd_nums
# hint: odd numbers are 2 digits apart
odd_nums = []
for num in range(1, 26, 2):
odd_nums += [num]
print(odd_nums)
# [ ] create a Decending list of ... | true |
251b58c4e02742af40b60f0d255647fa8f93116b | Aml-Hassan-Abd-El-hamid/Think-python | /ex 12-2.py | 734 | 4.21875 | 4 | #Exercise 12.2 In this example, ties are broken by comparing words, so words with the same length
#appear in alphabetical order. For other applications you might want to break ties at random. Modify
#this example so that words with the same length appear in random order. Hint: see the random
#function in the random ... | true |
9ad7c6a202fdb49bc1122d7243d88fd0c5281ec5 | bpshearer19/week2-csci102-git-workshop | /prime.py | 526 | 4.1875 | 4 | ## Implement a program to print out the first 100 prime numbers
# Brett Shearer
# CSCI 102 - Section B
# Git Workshop Week 2
# Function for determining whether a number is prime
def is_prime(number):
for val in range (2, number - 1):
if number % val == 0:
return False
break
ret... | true |
2dc5d6d25551bcb56123e5f57cf606931b801143 | sid2425/Python- | /Test.py | 1,237 | 4.125 | 4 | #Numbers
# x=5
# print(type(x)) it returns <class 'int'>
#Floats
# x=5.5
# y=5.5
# print(x+y)
# String Indexing
# mystring='abcdefghijk'
# print(mystring)
# Reverse Indexing
# mystring='abcdefghijk'
# print(mystring[-2])
#Slicing
# mystring='abcdefghijk'
# print(mystring[::0]) ValueError: ... | true |
4f321982c50d995a433ad006a06a0ee8b1179276 | Nikolov-A/SoftUni | /PythonBasics/Exam-Exercises/Exam 09.06.19/E_Spaceship.py | 498 | 4.21875 | 4 | import math
width = float(input())
length = float(input())
height = float(input())
astronauts_height = float(input())
volume_rocket = width * length * height
volume_room = (astronauts_height + 0.40) * 2 * 2
enough_space_for = math.floor(volume_rocket / volume_room)
if enough_space_for < 3:
print("The spacecraft ... | true |
bae13d2d4754667b743c927accfdcf9dd9c5354f | reiko516/python-games | /rpsls/RPSLS.py | 1,613 | 4.28125 | 4 | # Rock-paper-scissors-lizard-Spock
# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
def name_to_number(name):
# convert name to number using if/elif/else
if n... | true |
17ba44dd6108c9e167d49487a1e0cd2188f4f7b5 | jvansch1/facebook_studying | /python/udemy_class/recursion/string_permutations.py | 853 | 4.21875 | 4 | def string_permutations(string):
# Base case. We want to return the string if the length is one
if len(string) == 1:
return string
output = []
# Iterate through each character.
# For each character, we want to then get the permutations of
# all other characters in the string
for i,... | true |
0ba3cd717161bbfb4a50882252da217f0bc0f26f | sabidhasan/compsci | /MIT6.0001/ps5/MIT60001_ps1.py | 2,944 | 4.25 | 4 | #################
# ps1a.py #
# House Hunting #
#################
PORTION_DOWN_PAYMENT = 0.25
def integer_input(msg):
while True:
try:
return int(input(msg))
except:
print("Value must be an integer number")
continue
total_cost = integer_input('What is the cost for the home? ')
po... | true |
3f45b31aeaf768247dd4101171ca1990c4b1407f | JuniorDugue/100daysofPython | /day001/quiz2.py | 425 | 4.125 | 4 | # create three variables 'mood' 'strength' and 'rank' and assign a string to 'mood', a float to 'strength', and an integer to 'rank'. The values you assign can be anything as long as they are the of the correct type
mood = 'im excited'
strength = 100.5
rank = 10
# assign numbers to 'x', 'y', and 'z'. Calculate the ... | true |
6e8ab833e33678f4d8abdda677abb3e50faf2970 | parthi82/python | /fibonnaci_series.py | 607 | 4.28125 | 4 | # fibonnaci series using looping technique
range = int(input('Enter length of the fibonnaci series to be printed : '))
if range < 2:
n = int(input('Enter a number greater than 2 : '))
a, b = 0, 1
count = 2
print 'Printing first %d numbers in the fibonnaci series.................' % range
print a
while count < rang... | true |
8b8952f7f89637da7ea1e1333ca9c41c708166e8 | rjimeno/thePythonBible | /for.py | 548 | 4.15625 | 4 | #!/usr/bin/env python3
"""
48. PROJECT 6: Baby Conversation Simulator
"""
def main():
"""
Asks for some input and prints the number of vowels and consonants in it.
"""
vowels = 0
consonants = 0
text = input("Which line of text would you like to analyze?\n")
for letter in text:
i... | true |
962515cff04e41a16ba6e272215a068fbfca7cd3 | rjimeno/thePythonBible | /compare.py | 411 | 4.25 | 4 | #!/usr/bin/env python3
NUM1 = 11
NUM2 = 13
if NUM1 > NUM2: # Replace CONDITION1 with a valid condition that makes this work
print("NUM1 is bigger than NUM2")
elif NUM1 == NUM2: # Replace CONDITION2 with a valid condition that make this work
print("NUM1 is equal to NUM2")
elif NUM2 > NUM1: # Replace C... | true |
297487943db5a4f0463c38236623a9e265082aa9 | q-mar/course_python | /datei-einlesen.py | 549 | 4.1875 | 4 | '''
'r' This is the default mode. It Opens file for reading.
'w' This Mode Opens file for writing.
If file does not exist, it creates a new file.
If file exists it truncates the file.
'a' Open file in append mode.
If file does not exist, it creates a new file.
'+' This will open a fil... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.