blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
d7317c89f49fdd717c8a251bab1576bdc9954716 | Katarzyna-Bak/Coding-exercises | /Multiplication table for number.py | 802 | 4.46875 | 4 | """
Your goal is to return multiplication table for number that is always an integer from 1 to 10.
For example, a multiplication table (string) for number == 5 looks like below:
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
10 * 5 = 50
P. S. You can... | true |
4cd58172be2558a2bf3e20e38817d39f0c7551f2 | Katarzyna-Bak/Coding-exercises | /Majority.py | 780 | 4.5625 | 5 | """
We have a List of booleans. Let's check if the majority of elements
are true.
Some cases worth mentioning: 1) an empty list should return false; 2)
if trues and falses have an equal amount, function should return false.
Input: A List of booleans.
Output: A Boolean.
Example:
is_majority([True, True, ... | true |
66df0d705d7c17cd804e3ca813e8764dd1fa1461 | Katarzyna-Bak/Coding-exercises | /Grasshopper - Terminal game move function.py | 491 | 4.15625 | 4 | """
Terminal game move function
In this game, the hero moves from left to right.
The player rolls the die and moves the number of
spaces indicated by the die two times.
Create a function for the terminal game that takes the
current position of the hero and the roll (1-6) and
return the new position.
Example... | true |
30e788b6aa05a95b1e2ff60316c673f40a87c915 | Katarzyna-Bak/Coding-exercises | /L1 Set Alarm.py | 761 | 4.28125 | 4 | """
Write a function named setAlarm which receives two parameters.
The first parameter, employed, is true whenever you are
employed and the second parameter, vacation is true whenever
you are on vacation.
The function should return true if you are employed and
not on vacation (because these are the circumstance... | true |
62e4fc0551e05077fa9973fb9f1b3e6084e2bc0f | Katarzyna-Bak/Coding-exercises | /Count of positives sum of negatives.py | 952 | 4.125 | 4 | """
Given an array of integers.
Return an array, where the first element is the count of
positives numbers and the second element is sum of negative
numbers.
If the input array is empty or null, return an empty array.
Example
For input [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13,
-14, -15], you should r... | true |
9e783f91b7cb733caab0c177293b3da8b7a41c76 | Katarzyna-Bak/Coding-exercises | /Days in the year.py | 1,198 | 4.40625 | 4 | """
A variation of determining leap years, assuming only
integers are used and years can be negative and positive.
Write a function which will return the days in the year
and the year entered in a string. For example 2000,
entered as an integer, will return as a string 2000
has 366 days
There are a few assum... | true |
f921bbe245fbf3cfe15671f2aeca902f5e82903c | Katarzyna-Bak/Coding-exercises | /First Word II.py | 1,037 | 4.46875 | 4 | """
You are given a string where you have to find its first word.
When solving a task pay attention to the following points:
There can be dots and commas in a string.
A string can start with a letter or, for example, a dot or space.
A word can contain an apostrophe and it's a part of a word.
The whole text ca... | true |
e7ac5307c1db801bcb856f70346cef9b5c1a1c60 | Katarzyna-Bak/Coding-exercises | /Triple Trouble.py | 767 | 4.21875 | 4 | """
Triple Trouble
Create a function that will return a string that
combines all of the letters of the three inputed
strings in groups. Taking the first letter of all
of the inputs and grouping them next to each other.
Do this for every letter, see example below!
E.g. Input: "aa", "bb" , "cc" => Output: "abcab... | true |
d80789651f5243b5db2f13859c49021ae7f9f1a1 | Katarzyna-Bak/Coding-exercises | /Is n divisible by x and y.py | 639 | 4.3125 | 4 | """
Create a function that checks if a number n is divisible
by two numbers x AND y. All inputs are positive, non-zero
digits.
Examples:
1) n = 3, x = 1, y = 3 => true because 3 is divisible
by 1 and 3
2) n = 12, x = 2, y = 6 => true because 12 is divisible
by 2 and 6
3) n = 100, x = 5, y = 3 => fals... | true |
121ff2983e49ba7f50cee2366dee25a2052e2691 | Katarzyna-Bak/Coding-exercises | /Is Even.py | 514 | 4.46875 | 4 | """
Check if the given number is even or not. Your function should return True if the number is even, and False if the number is odd.
Input: An int.
Output: A bool.
Example:
is_even(2) == True
is_even(5) == False
is_even(0) == True
How it’s used: (math is used everywhere)
Precondition: both given int... | true |
7a63aa0ea780d23783a3b2941577a461c62d60e8 | Katarzyna-Bak/Coding-exercises | /Find numbers which are divisible by given number.py | 598 | 4.40625 | 4 | """
Complete the function which takes two arguments and returns
all numbers which are divisible by the given divisor.
First argument is an array of numbers and the second is
the divisor.
Example
divisible_by([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]
"""
def divisible_by(numbers, divisor):
return [n for n in ... | true |
0c1b756b5c1992a1156f2ea12277680771dc1455 | Katarzyna-Bak/Coding-exercises | /Beginner - Reduce but Grow.py | 343 | 4.25 | 4 | """
Given a non-empty array of integers, return the result
of multiplying the values together in order.
Example:
[1, 2, 3, 4] => 1 * 2 * 3 * 4 = 24
"""
def grow(arr):
b = 1
for a in arr:
b = b*a
return b
print("Tests:")
print(grow([1, 2, 3]))
print(grow([4, 1, 1, 1, 4]))
print(gr... | true |
c5582c5662069dfdbb87b8cd5957b45786427e3c | Katarzyna-Bak/Coding-exercises | /Keep Hydrated!.py | 596 | 4.21875 | 4 | """
Nathan loves cycling.
Because Nathan knows it is important to stay hydrated, he drinks 0.5 litres of water per hour of cycling.
You get given the time in hours and you need to return the number of litres Nathan will drink, rounded to the smallest value.
For example:
time = 3 ----> litres = 1
time = 6.7-... | true |
3227c95714004341e4b61d6dd84453d3233957c1 | luislauriano/python-data-structures-and-algorithms | /src/data_structures/arrays/left_rotation.py | 497 | 4.59375 | 5 | """
A left rotation operation on an array of size 'n'
shifts each of the array's elements 1 unit to the left.
For example, if 2 left rotations are performed on array [1, 2, 3, 4, 5],
then the array would become [3, 4, 5, 1, 2].
Given an array of n integers and a number, 'd', perform 'd' left rotations on the array.
T... | true |
d0ef60a4b7a858f15afbc1fc0212af098818682b | andrewonyango/bioinformatics | /1-finding-hidden-messages-in-dna/week1/pattern_count.py | 485 | 4.3125 | 4 | def pattern_count(string, pattern):
"""
returns the number of occurences of *pattern* in *string*
string: the string to search on
pattern: the substring to look for in *string*
"""
count = 0
text_length = len(string)
pattern_length = len(pattern)
# compare only up to the last possi... | true |
83de70501c82f7fbbb843e5e4b05e9451a5b841d | ferminhg/training-python | /patterns/behavioral-design-patterns/template.py | 1,010 | 4.125 | 4 | # Define the skeleton of an algorithm in an operation, deferring some steps to subclasses.
# Template Method lets subclasses redefine certain steps of an algorithm without changing
# the algorithm's structure.
# Use when you have to define steps of the algorithm once and let subclasses
# to implement its behaviour.... | true |
c5cf7830c0a8ea665795a9cf738eadb4e72fd8c2 | prasannagiri2072/python-practice | /spreedsheet work3/Untitled-6.py | 741 | 4.21875 | 4 | # String characters balance Test
# We’ll say that a String s1 and s2 is balanced if all the chars in the string1 are there in s2. characters position doesn’t matter.
# For Example:
# stringBalanceCheck(yn, Pynative) = True
def flag_statment(s1,s2):
flag = True
for char in s1:
if char in s2:
... | true |
6414e75ab4378fe13a0e4f9d242466db693c20f6 | langigo/algorithm_python | /MergeSort.py | 1,437 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Idea of merge sort:
_Recursively split unsorted list into 2 sub-list, split until each sub-lists has only 1 memeber
_For each 2 sub-lists, join them together by comparing 2 first members of 2 sub-lists, and append to the result-list of the join
"""
#implementation: acceptance parameter i... | true |
bf3612377e123c1bf3e6584f81737584de1feaf4 | dsrizvi/algo-interview-prep | /old/general/findPivotPoint.py | 518 | 4.125 | 4 | def findPivot(array, left, right):
if left > right:
return -1
if left == right:
return left
mid = (left+right)/2
if array[mid-1] > array[mid]:
return array[mid]
if array[mid+1] < array[mid]:
return array[mid+1]
if array[mid] > array[right]:
return findPivot(array, mid+1, right)
else:
return findP... | true |
796ac8e33482626e4c5e72b0ff52e71864f79ba6 | abolfazl-sadeghian/text_to_morse_code | /main.py | 812 | 4.1875 | 4 | from morse_code_table import CODE
from art import logo
from playsound import playsound
# A text-based Python program to convert Strings into Morse Code.
print(logo)
text = input("Please enter a text to turn into morse code : \n").upper().split(' ')
morse_code = []
def word_to_morse_code(word: str):
for char i... | true |
b35aec7bf7a170c1893b162d4f90e9210b40cc66 | DevonLetendre/Distributions | /distribution.py | 2,297 | 4.1875 | 4 | from random import randrange
'''
The Distribution class models a distribution and provides methods
which allow a user to interact with the distribution.
'''
class Distribution:
def __init__(self):
self.dict = {}
self.eventspace = 0
self._L = []
self.flag = None
self.leftoff_at = 1
self.slider_begin = ... | true |
cf81870ed59589c1e6a9aebc3d3e64d200907446 | wlong799/conv-nets | /tensorflow-tutorials/tensorflow-mnist-basic.py | 2,292 | 4.46875 | 4 | """
Introduction to core machine learning concepts and how TensorFlow works, by
creating a simple softmax regression model with no hidden layers to classify
handwritten digits in the MNIST data set.
Achieves approximately 91% accuracy
Walkthrough found here:
https://www.tensorflow.org/get_started/mnist/beginners
Wil... | true |
633e42f4399c37a1d2d04690d668e8a790300414 | janat-t/titech_comp | /CS2/Project2_Sort/bubblesort.py | 619 | 4.15625 | 4 | from sort_core import swap
#
# BUBBLE SORT
#
# IN: arbitrary array
# OUT: array with all values sorted in increasing order
#
# METHOD:
# check online by yourself :)
def sort(array):
""" Non-destructive bubblesort sort.
array is unchanged; returns a sorted copy
"""
res = array.copy()
sort_in... | true |
e1f242ef1a9adb0d25ea6eec0f46f3cb64156b40 | janat-t/titech_comp | /CS1/Hw3_Caesar/caesar.py | 847 | 4.15625 | 4 | # Note that you can change the structure of the function.
# For example, you can change the type of loop.
def enc(k, m):
"""Encode the message m (aka plaintext)
with Caesar cipher and shift key k.
Change only lowercase characters,
Keep other characters.
Return the ciphertext.
"""
# Conv... | true |
4b86918f31a7031bfa8d2f43486d13103edcd33c | ege-erdogan/comp125-jam-session-02 | /23_11/vectors.py | 1,195 | 4.15625 | 4 | '''
COMP 125 - Programming Jam Session #2
November 23-24-25, 2020
Implement the following functions for vectors given as a list of size 3
* add_vector: input two vectors, returns resulting vector
* length_vector: input a vector, returns the magnitude of the vector
* dot_product: input two vectors, re... | true |
9aa4f2cdd6f615eca8948f8d0388771e056efb4f | nikitaty/CardsGame | /deck.py | 2,518 | 4.4375 | 4 | # Design a class deck of cards that can be used for different card game
# applications.
# What is the deck of cards: A "standard" deck of playing cards consists of 52 Cards
# in each of the 4 suits of Spades, Hearts, Diamonds, and Clubs. Each suit contains
# 13 cards: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, Kin... | true |
99ac92a32834d9648c9c46e8eb9175bfd84ddc6c | derrickweiruluo/OptimizedLeetcode-1 | /LeetcodeNew/python/LC_785.py | 2,579 | 4.1875 | 4 | """
Given an undirected graph, return true if and only if it is bipartite.
Recall that a graph is bipartite if we can split it's set of nodes into two independent subsets A and B such that every edge in the graph has one node in A and another node in B.
The graph is given in the following form: graph[i] is a list of ... | true |
767ec58084b63e8c2f87bb04781e2f4f6d4235ad | derrickweiruluo/OptimizedLeetcode-1 | /LeetcodeNew/python/LC_519.py | 1,082 | 4.25 | 4 | """
This is a sampling n elements without replacement problem. It is the same as the operation that random shuffe an array and then return the first n elements.
Here come the trick. When we random pick an element in the array we can store its new position in a hash table
instead of the array because n is extremely les... | true |
f6f30ced739de4689347377433543aff695540d4 | derrickweiruluo/OptimizedLeetcode-1 | /LeetcodeNew/python/LC_774.py | 1,685 | 4.125 | 4 | """
On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length.
Now, we add K more gas stations so that D, the maximum distance between adjacent gas stations, is minimized.
Return the smallest possible value of D.
Example:
Input: stations =... | true |
25e87d060d63f179dc61a8cfe10961e6faaa6377 | Margarita-Sergienko/codewars-python | /7 kyu/String doubles.py | 1,647 | 4.375 | 4 | # 7 kyu
# String doubles
# https://www.codewars.com/kata/5a145ab08ba9148dd6000094
# In this Kata, you will write a function doubles that will remove double string characters that are adjacent to each other.
# b) The 2 b's disappear because we are removing double characters that are adjacent.
# c) Of the 3 c's, we ... | true |
c9c360f3bf43b8cc36a3a4f7f31cf84e447d1783 | Margarita-Sergienko/codewars-python | /7 kyu/Unique string characters.py | 737 | 4.21875 | 4 | # 7 kyu
# Unique string characters
# https://www.codewars.com/kata/5a262cfb8f27f217f700000b
# In this Kata, you will be given two strings a and b and your task will be to return the characters that are not common in the two strings.
# For example:
# solve("xyab","xzca") = "ybzc"
# --The first string has 'yb' whic... | true |
ccf3b7008b39cad355a9c637a92fe4f3099beeaf | Margarita-Sergienko/codewars-python | /7 kyu/Responsible Drinking.py | 939 | 4.1875 | 4 | # 7 kyu
# Responsible Drinking
# https://www.codewars.com/kata/5aee86c5783bb432cd000018
# Welcome to the Codewars Bar!
# Codewars Bar recommends you drink 1 glass of water per standard drink so you're not hungover tomorrow morning.
# Your fellow coders have bought you several drinks tonight in the form of a string... | true |
e86a74dc2ce51d33be8dd3a126db31ea43c92787 | hamna314/iacc_python | /week2/passwordChecker.py | 1,828 | 4.34375 | 4 |
#Password strength checker : Create a function to accept a string and verify if it conforms to the following format
#between 8 to 12 characters long, atleast 1 upper case character,
#atleast 1 number and 1 special character which can be one of '@','#','$','#' ,'%','&'
#Create a function to verify if password length... | true |
dcfda91b7c058b6518e73e960e40af90654402e5 | hamna314/iacc_python | /week1/sum_of_items_in_list.py | 602 | 4.3125 | 4 | '''
Write a python program to sum all the items in a list
'''
#Create a new list with some random numbers
newList = [1,5,19,4,5,8]
#Create a new variable sum_of_List to hold the sum of the items in the list and assign it a value of 0.
sum_of_list = 0
#Create a for loop to iterate over the elements of the list
for it... | true |
228a04513d195e81f06420981ea0d46885d43cd9 | seenureddy/problems | /python-problems/largest_sub_array.py | 1,542 | 4.15625 | 4 | """
Largest sub-array problem
You have an array containing positive and negative numbers (no zeros). How will you find the sub-array with the largest sum.
Example: If the array is: 1, 4, -6, 8, 1, -4, 5, -3, 1, -1, 6, -5
The largest sub-array is: 8, 1, -4, 5, -3, 1, -1, 6
NOTE: You've to print the largest sub-array ... | true |
5d7daff83796a4cbe62e2962ddcfebbe1e8e002a | volodiny71299/04_assessment | /03_assessment.py | 525 | 4.21875 | 4 | # Component three, choose what game to play
game_multi_choice = "multi-choice"
game_other = "other"
error = "please enter 1 or 2"
keep_going = ""
while keep_going == "":
choose = input("Multi-choice(1) or other(2)? ").lower()
if choose == "1":
print()
print("you chose", game_multi_choice)
... | true |
f24e8fbfba3777295b8097710c72af625eee42a3 | prakashtanaji/DSAndAlgo | /dailycode/python/bintreecompletenodescount.py | 1,717 | 4.125 | 4 | # give a binary tree which is complete, find the number of nodes
import queue
def treeSz(root):
curr = root
sz = 1
while True :
if curr.left == None: break
curr = curr.left
sz +=1
return sz
class Node:
val = 0
left = None
right = None
def __init__(self, _val):
... | true |
96a9e48c298c359a2ca9bbf46248e6e89a857b6e | G8A4W0416/Module7 | /fun_with_collections/basic_list_exception.py | 688 | 4.375 | 4 | """
Program basic_list.py
Author: Greg Wilhelm
Last date modified: 03/04/2020
This is just a simple list builder taking in a integer entered by the user and creating a list by repeating the value
three times.
"""
def get_input():
user_input = int(input("Please enter a number: "))
return user_input
def m... | true |
cc50c7f0a4a88f49659214785ff3c422ecc7b250 | ethanmyers92/90COS_IQT_Labs | /Lab3D.py | 425 | 4.375 | 4 | #Lab3D
#Write a program that prompts a user to input an integer and calculates the factorial of that number using a while loop.
def factorial(n):
num = 1
while n >= 1:
num = num * n
n = n - 1
return num
count = 0
while count <= 100:
print factorial(count)
count += 1
else:
... | true |
76651f4059bbd69cbc52ceb1cb71fad5a0943b97 | ethanmyers92/90COS_IQT_Labs | /Lab 2H.py | 1,172 | 4.125 | 4 | #Lab 2H
print "Enter the grades for your four students into your gradebook! Enter grade first then name!"
student_dict = {raw_input("Enter first student's name: ") : int(raw_input("Enter first student's grade: "))}
student_dict[raw_input("Enter second student's name: ")] = int(raw_input("Enter second student's gra... | true |
7feeebca071b5069612d76429b5ef19df7eea6eb | coleMarieG/wcc | /Python/input.py | 597 | 4.15625 | 4 | # name = raw_input('What is your name? ')
# print('Hi ' + name)
# name = raw_input('What is your name?')
# age = raw_input('How old are you?')
# print(name + ' is ' + age + ' years old.')
# # raw_input value is always a string
# age = raw_input('How old are you?')
# dog_years = int(age) * 7
# print('You are ' + str(... | true |
5068eb26f4664e523efae0bc297df86978158cfd | mgarchik/P2_SP20 | /Problems/Sorting/05_sorting_problems.py | 2,673 | 4.1875 | 4 | '''
Sorting and Intro to Big Data Problems (22pts)
Import the data from NBAStats.py. The data is all in a single list called 'data'.
I pulled this data from the csv in the same folder and converted it into a list for you already.
For all answers, show your work
Use combinations of sorting, list comprehensions, filter... | true |
5acbd00c44698d654e64145585a619290e097eb1 | RyhanSunny/myPythonJourney | /Common _String_methods.py | 1,582 | 4.1875 | 4 | # A string variable
name = "michael jackson"
# character at index 0
print(name[0])
# character at index -1: first letter backwards
print(name[-1])
# length of string
print(len(name))
# # STRING[START:END:STEP] ex: name[0:10:2]
# Slicing
print(name[0:4]) # slice from index 0 til index 4 (including 0th excluding 4th)
... | true |
3ea4dabedc8f530e4ccbeaab24d898e964fbb379 | avoajaugochukwu/python_mooc | /my_work/stuff.py | 807 | 4.375 | 4 | balance = float(raw_input("Enter the outstanding balance on your credit car: "))
annualInterestRate = float(raw_input("Enter the annual credit card interest rate as a decimal: "))
monthlyPayment = 10
monthlyInterestRate = annualInterestRate/12
newbalance = balance - 10
while (newbalance > 0):
monthlyPayment +... | true |
b7f0cb150a1b4087e53e6aa443ff97efd4ed9cae | explodes/euler-python | /euler/lib/seq.py | 2,406 | 4.28125 | 4 | #!/usr/bin/env python
def bin_index(L, item, low=0, high=None):
"""
Perform a binary search on ordered sequence L
If the item is not found, return the index in which it should be inserted
O(lg n)
:param L: ordered sequence to scan
:param item: `item` to search for
:param low: lowest bound ... | true |
7d0896295fae62b13ccfbec05c9777feffd22b9b | explodes/euler-python | /euler/lib/maths.py | 1,956 | 4.21875 | 4 | #!/usr/bin/env python
import math
from euler.lib.gen import lrange
from euler.lib.seq import insert_in_order
def product(seq):
"""
Multiply each item in the list and return the value
"""
total_product = 1
for item in seq:
total_product *= item
return total_product
def divisors(n):
... | true |
e34a14df70505f795977b18c82875b8916ad7461 | ryantanch/PythonOOP-Practice | /oop.py | 2,593 | 4.1875 | 4 | ##################################################
# Python OOP tutorials by Corey Schafer
# Source: Youtube - Corey Schafer
# Practice Done by RyanTanCH 2019
# Ver Python 3.6
##################################################
class Employee:
#Class Variable
No_of_emps = 0;
raise_amount = 1.04
#constructor 1 ... | true |
77be6f889c59ba66824029fb4cf4088d8766905a | azrodriquez/MyPythonCourse | /CH06-functions/movie_info.py | 855 | 4.40625 | 4 | #Bonus material #1
def print_movie(movie, year):
print(f'The movie {movie} is from year {year}.')
movie = "The Matrix"
year = 1999
print(print_movie(movie, year))
# Bonus material #2
def movie_info(user_movie, user_movie_year):
print(f'The movie {user_movie} was released in {user_movie_year}.')
user_movie ... | true |
d6a977cc012b7963002de1826ce1ebef07b71a71 | balayanr/Daily-Interview-Pro | /problems/count_invalid_parenthesis.py | 444 | 4.28125 | 4 | """
This problem was recently asked by Uber:
You are given a string of parenthesis.
Return the minimum number of parenthesis that would need to be removed
in order to make the string valid. "Valid" means that each open parenthesis
has a matching closed parenthesis.
Example:
"()())()"
The following input should retu... | true |
12ebeaec5b2d9701642b19514aff4578a0e6dd51 | Akhileshbhagat1/All-prectice-of-python | /specialisedCOLLECTIONdataTYPES/namedTUPLE.py | 484 | 4.375 | 4 | # namedtuple() returns the tuple with named value for esch element in the tuple
# details = (name = 'akhilesh', age = '24', language = 'python')
from collections import namedtuple
a = namedtuple('courses', 'name, technology, age, address ')
s = a('akhilesh', 'python', '24', 'bhagaiya')
print(s)
# yo... | true |
ce0aaf7ab12e020f0ace539cb112b682effb5e29 | fosskers/alg-a-day | /day07-linked-list/linked_list.py | 2,189 | 4.21875 | 4 | # A linked list in Python.
# Pretty pointless due to the existence of built-in non-homogenious lists,
# but whatever.
class LinkedList():
'''A linked list. Hurray.'''
def __init__(self, initial_data):
self.root = Node(initial_data)
self.end = self.root
def __str__(self):
nodes = ... | true |
e5bcea62de995b020b566248b41937e390132211 | fosskers/alg-a-day | /day11-circular-bin-search/circ_bs.py | 810 | 4.1875 | 4 | # Circular Binary Search
def circ_bs(items, target):
'''Finds a value in a given list using a circular binary search.
Returns -1 if the value was not found.
'''
size = len(items)
lower = 0
upper = size - 1
result = -1 # Assume failure.
while lower <= upper:
mid = (upper + lower... | true |
2ba97990c6b589b4f53120eaa775d89d431b651f | nokap/exam1jacobkapasi | /donuts.py | 1,881 | 4.125 | 4 | grades = [62, 79, 82, 81, 92, 74, 84, 95, 85, 78, 88]
#This is an array that holds all of the grades of the class
ans = () #This is a variable that holds the answer
for avg in grades: #I am creating a for loop that holds the averages for the grades
if avg ==: #I am saying that if the average variable in grades... | true |
8af6b3625023ca12c94735679076a1fa2ac855b1 | JennyShalai/data-science-prep | /tuple-dictionary-set.py | 2,933 | 4.4375 | 4 | # Tuple, Dictionary and Set checkpoint
# Challenge 1:
# Write a script that prompts the user to input a series of numbers separated by
# commas. Your script will then take these inputted numbers and store them
# as a list of tuples, two at a time. Finally, your script will print that list
# of tuples to the user. If ... | true |
77ee2388db3dddcf57c75525c1115008592bc798 | DustyQ5/CTI110 | /P3T1_AreasOfRectangles_ChazzSawyer.py | 1,384 | 4.25 | 4 | # CTI-110
# P3T1 - Areas Of Rectangles
# Chazz Sawyer
# 9/25/2018
#Program welcomes user
#Progames ask for rectangle legnth and width. Then repeats.
#programs states the area of both rectangles
#programs announces which rectangle has a larger area or if
#they are equal
pri... | true |
3bf50aaf9347137d12099872cdefbdd467a7413f | Austin-deMora/ICS3U-Assignment6-Python-Pyramid_Volume | /pyramid_volume.py | 1,670 | 4.375 | 4 | #!/usr/bin/env python3
# Created by Austin de Mora
# Created in May 2021
# Program finds volume of a right rectangular pyramid
import math
def volume(length, width, height):
# Function calculates volume and returns it
# Process
volume = (length * width * height) / 3
return volume
def main():
... | true |
cd6166e3fb6320e8c646a485ba28e62bbcba4b32 | mistrydarshan99/Leetcode-3 | /interviews/lyft/lyft_ouptut_last_n_row_of_file.py | 1,184 | 4.5 | 4 | """
given a file or file_handler.
Implement a function that:
tail(file, n =10): #default n = 10
- give last 10 rows of line in the file
tail(file, n):
- give last n rows of lines in the file
Thought:
- since we need to read the file line by line:
- but we only want to last n rows of file
- so we wish to pop out / t... | true |
58a01495d07cc25e0be70c39686f4728b178ac0e | bigmantings69/01-Lucky-Unicorn | /HL_yes_no.py | 2,364 | 4.25 | 4 | import random
# instruction if user did not play the game before
def instructions():
print()
print("**** How to Play ****")
print()
print("For each game you will be asked to...")
print("- Enter a 'low' and 'high' number. "
"The computer will randomly generate a 'secret' number between ... | true |
59e469c28a514a750fc43b61de86f8df642b3114 | RoboneClub/Hab-Lab-Analysis | /temperature_plotter.py | 1,698 | 4.28125 | 4 | #Pandas is used to open csv files and convert to lists
import pandas as pd
#Used for making plots
import matplotlib.pyplot as plt
#Library used to do maths
import numpy as np
#Load data to pandas
data = pd.read_csv('data.csv')
#Give time from data
time = data['Time']
sesnor_temperature_values = data['Te... | true |
cc862467514be24cd815fce7b1fb50c316a505aa | YannMoskovitz/Python-crash-course- | /class user.py | 2,839 | 4.3125 | 4 | class User:
"""Class of user stores a tipical user info"""
def __init__(self, first_name, last_name, username, location, email, middle_name=''):
self.first_name = first_name
self.last_name = last_name
self.middle_name = middle_name
self.username = username
self.location ... | true |
2da0812f53c518622b80e008d9263109efe8eec3 | Fange-Wu/Getting-Lucky | /07_job_v1.py | 904 | 4.15625 | 4 | import random
for item in range (0,10) :
operation = random.randint(1,3)
num1 = random.randint(1,10)
num2 = random.randint(1,10)
if operation == 1:
question = int(input("What is " + str(num1) + "+" + str(num2) + ": "))
answer = num1 + num2
if question == answer:
pri... | true |
9b319fc716ba4ba97c1024cc5110a91d674e8305 | nbglink/ExamPythonBasics2018 | /CatWalk.py | 551 | 4.125 | 4 | minutes_walks_day = int(input())
count_walks_day = int(input())
calories_day = int(input())
summary_minutes_for_walk = minutes_walks_day * count_walks_day
summary_calories_burned = summary_minutes_for_walk * 5
half_of_taken_calories = calories_day - (50 * calories_day) / 100
if summary_calories_burned >= half_of_ta... | true |
a823d5c9b0f9417d6d95201a604d312377a627f3 | huytn1219/algorithm | /bestTimeToBuyandSellStock.py | 838 | 4.21875 | 4 | # You are given an array prices where prices[i] is the price of a given stock on the ith day.
# You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.
# Return the maximum profit you can achieve from this transaction. If you cannot ach... | true |
1f31b496ab6ab081bcf8543c62205b5a77f949e8 | Damnful/210CT | /Question10.py | 925 | 4.1875 | 4 | def find_maximum_subsequence(sequence):
subsequenceList = []
currentSubsequence = []
maximumSubsequence = []
last = 0
for integer in sequence:
if integer <= last:
# basically, if the next value continues the increasing subsequence
subsequenceList.append(current... | true |
dec4c475c48b85738c9103788dd20e811cb147cb | AmitabhK-je/PythonForEverybody | /Exercise_3/Exercise3.py | 697 | 4.1875 | 4 | """
Write a program to prompt for a score between 0.0 and
1.0. If the score is out of range, print an error message. If the score is
between 0.0 and 1.0, print a grade using the following table:
"""
try :
score = input('Enter score: ')
score = float(score)
if score >=0.0 and score <=1.0:
... | true |
9a0c57528493155d91051fd13c45fa42917932de | gulci-poz/py_basics | /13_for.py | 602 | 4.1875 | 4 | # string - sequence of characters
for letter in 'Python':
print(letter, end='*')
print()
for name in ['Wiki', 'Mela', 'Ema']:
print(name, end=' ')
print()
sum_of_prices = 0
prices = [1, 2, 3, 4, 5]
for price in prices:
sum_of_prices += price
print('Sum of prices:', sum_of_prices)
sum_of_numbers = 0
... | true |
6a30c2124bb7c57d935fdde5fcd82b2f732eea47 | t0etag/Python | /Python3/DemoProgs/comp_ifelse.py | 755 | 4.40625 | 4 | """Comprehension with If/Else
This program demonstrates the way if/else constructs can be
used within a comprehension. This particular example examines
each entry in a list containing numbers. For numbers >= 45,
one is added to the new number. Otherwise, five is added to
the new number. At some point in time... | true |
a00e865fcc8fbbdd21d1900765bf906fc7115c38 | t0etag/Python | /Python1/Labs/LastLabPy1/lab08b_func.py | 1,091 | 4.25 | 4 | """lab08b_func.py
This program reads a temperature from the keyboard. It then reads a
character that determines what type of conversion to perform. A 'c'
causes a fahrenheit-to-centigrade coversion while a 'f' causes the
opposite conversion. Separate functions provide the conversion as
well as print statement... | true |
4a1f75311937c0d224a507222c2e14f99e4f1d2e | t0etag/Python | /Python3/Labs/Lab12b.py | 1,648 | 4.375 | 4 | """Lab 12b - Comparisons
When you compare for equality, the default version of __eq__ is called
automatically and it will blindly compare two instances which will never be equal.
To override this result, implement one or more of the newer magic methods – in
our case __eq__. Use this magic method to compare the bala... | true |
977f3f5c4bd8b57b45f9cdc89684ad08ca55da47 | t0etag/Python | /py4e/banana_index.py | 410 | 4.28125 | 4 | """
Write a while loop that start at the last characeter in the string and works ins way backwards to the first
character in the string, printing each letter on a seperate line.
"""
fruit = "banana"
length = len(fruit)
#last = fruit[length - 1]
last = fruit[-1] # this works better
print(last)
index = len(f... | true |
177ca0bebfb911304e56d6e91a6f11c5fa03d8c4 | t0etag/Python | /Python3/DemoProgs/varyargs.py | 610 | 4.625 | 5 | """Variable Positional Arguments
This demo program has a function that takes a variable number of
parameters and shows how a collector assembles them all in a tuple.
By tradition, we use *args for positional parameters and **kwargs
for keyword parameters.
"""
def myfnc(*args):
print(len(args), type(args))
pri... | true |
dacc17ecb937360b01bb52bb4a8b7fcffc35bd9c | t0etag/Python | /Python2/Class Data/DemoProgs/sort_by_count.py | 836 | 4.34375 | 4 | """Sorting by Count
This program creates a dictionary containing counters. Then it
unloads the values and keys separately and zips the two together
with the count preceding the key. Then the sorted function is used
to sort each tuple in ascending order by count. Finally, the list
created by sorted is parsed i... | true |
5953c9e6ab5a9829732a62a2dc9a29331881b994 | t0etag/Python | /Python3/DemoProgs/counter.py | 1,898 | 4.25 | 4 | """Demo the Counter class
This program demonstrates some of the capabilities of the Counter class
"""
from collections import Counter
x = 'abracadabra'
ltrs = Counter(x)
print(ltrs) # This object is not act exactly the same as a dictionary
print('Unloaded:', ltrs.most_common()) # This method unloads the object the
#... | true |
57977064c1194ace521008e3f7f1cbeb1977d572 | t0etag/Python | /py4e/grades.py | 461 | 4.1875 | 4 | """
prompt for score between 0.0 and 1.0. If score is out of range, print error.
If in range, print grade.
"""
score = input("Enter score between 0.0 and 1.0:")
score = float(score)
if(score < 0.0 or score > 1.0):
print("Invalid score.")
elif(score >= 0.9):
print("Grade: A")
elif(score >= 0.8):
... | true |
3602d74c9e268d133efe4d19b05c15d677a93d66 | t0etag/Python | /Python2/Labs/Lab06cX.py | 2,381 | 4.15625 | 4 | """LAB 06c
In your data file is a program named servercheck.py. It reads two files
(servers and updates) and converts the contents into two sets. The
updates are not always correct. You will find all of the set
operations/methods in Python Notes. Using just these
operations/methods, your job is as follows:
1. Det... | true |
aaabf4c649303af4afddef6b3de08100f18c6f61 | TeenageMutantCoder/Calculator-with-GUI | /calculator-with-gui/Libraries/Menus/HelpMenu.py | 938 | 4.3125 | 4 | import tkinter as tk # GUI Library
from tkinter import messagebox # Allows a messagebox to be displayed on screen
class HelpMenu(tk.Menu):
''' Help submenu '''
def __init__(self, parent):
tk.Menu.__init__(self, parent)
self.parent = parent
self.window = self.parent.parent
... | true |
e6907c4ccb3d39ff820ee18f76bc5917d44a9bd5 | sandeepm96/cormen-algos | /Sai/kahn_topoSort.py | 1,404 | 4.25 | 4 | # A Python program to print topological sorting of a graph
# using indegrees
from collections import defaultdict
#Class to represent a graph
class Graph:
def __init__(self,vertices):
self.graph = defaultdict(list) #dictionary containing adjacency List
self.V = vertices #No. of vertices
# fun... | true |
d646e0c9dd330ad29c3376a5ee49c1f70c6348bd | GalihRakasiwhi/DCC-PythonBeginners | /Exercise/exercise.py | 1,039 | 4.15625 | 4 | numbers = []
strings = []
names = ["Anakin Skywalker", "Padme Amidala", "Han Selo", "Qui-Gon Jinn", "Luke Skywalker", "Obi-an Kenobii"]
#write
second_name = None
#print Number
numbers.append(1)
numbers.append(2)
numbers.append(3)
strings.append("Satu")
strings.append("Dua")
strings.append("Tiga")
#this code should ... | true |
168c37edec6a17d03f44ca047e5d0cd5dd30a7ab | Elza-MerilGucic/HW9 | /HW9.1/main.py | 413 | 4.34375 | 4 | print("Welcome to distance unit converter")
while True:
kilometers = float(input("Please enter number of kilometers: "))
miles = 0.621371 * kilometers
print(str(kilometers) + " kilometers equals " + str(miles) + " miles")
repeat = input("Do you want to do another conversion? (yes / no): ")
if repe... | true |
329f502e7bd2098dca7204d88b9ded699421d6f9 | ghezalsherdil/Web_Fundamentals | /Python/Python_assignments/type-list.py | 1,620 | 4.34375 | 4 | '''Assignment: Type List
Write a program that takes a list and prints a message for each element in the list, based on that element's data type.
Your program input will always be a list. For each item in the list, test its data type. If the item is a string, concatenate it onto a new string. If it is a number, add it ... | true |
9562b71e46986b31bf317471b5703f34215d4c5e | RahulRj09/pythonprograms | /primenumber.py | 225 | 4.125 | 4 | # this program check number is prime or not
prime = input("enter number is prime or not")
s = 0
for i in range(2,prime):
if prime % i == 0:
s +=1
if s == 0:
print "number is prime"
else:
print "nmuber not prime" | true |
e9767c9681860453593aa4843f997993b43a2e19 | hsfear/exercises | /python/100steps/hello-world/if_examples.py | 427 | 4.15625 | 4 | first = int(input("Enter the first number: "))
second = int(input("Enter the second number: "))
operation = input("Enter the operation [+-*/]: ")
if operation == '+':
result = first + second
elif operation == '*':
result = first * second
elif operation == '-':
result = first - second
elif operation == '/... | true |
646581b644ac8de68ab4d1736662e9d38e1bc398 | thapaliya123/Python-Practise-Questions | /data_types/problem_16.py | 226 | 4.15625 | 4 | """
Q.a Python program to sum all the items in a list.
"""
def sum_list_items(target_list):
sum=0
for item in target_list:
sum+=item
return sum
print("The sum of list is:", sum_list_items([1, 2, 3, 4, 5])) | true |
2e833a906a810bafa9185e337f175f29c8522241 | thapaliya123/Python-Practise-Questions | /functions/problem_17.py | 310 | 4.3125 | 4 | """
17.Write a Python program to find if a given string starts with a given character
using Lambda.
"""
string_with_given_char = lambda sample_string, sample_char: True if sample_string[0]==sample_char else False
sample_string="anish"
sample_char = "a"
print(string_with_given_char(sample_string, sample_char)) | true |
29c8946c0305a9dd70a66680c1c15f175afac969 | thapaliya123/Python-Practise-Questions | /functions/problem_12.py | 306 | 4.3125 | 4 | """
12. Write a Python program to create a function that takes one argument, and
that argument will be multiplied with an unknown given number.
"""
def multiply_with_unknown(sample_number):
return lambda x:sample_number*x
sample_number=10
result = multiply_with_unknown(sample_number)
print(result(3)) | true |
c1c2dabfe1305a88554e8b6264db862057343f96 | Jkoss172/ChatBotProject | /main.py | 1,635 | 4.125 | 4 | # Class Project - sprint01 - Base Code Design - 06/17/2021
# Here we put the import files
import random
# Here we declare global variables
program_over = True # sets the main loop to run
# Here we will define our classes and functions
class MainMenu: # This is the main menu
def intro():
... | true |
ea2e41ee0aabed72fcee1e7d0e130c03ead62658 | cwb4/Impractical_Python_Projects | /Chapter_4/permutations_practice.py | 1,465 | 4.28125 | 4 | """For a total number of columns, find all unique column arrangements.
Builds a list of lists containing all possible unique arrangements of
individual column numbers including negative values for route direction
(read up column vs. down).
Input:
-total number of columns
Returns:
-list of lists of unique column orde... | true |
b49e95e05c2c6f5749890eca608231291d12438d | piyushc0/Python | /src/String.py | 1,279 | 4.21875 | 4 | course = "Python's course for Beginners"
print(course)
message = '''
Hi Piyush,
Here is an example of 3 quotes
So you see it is fun in "Python"
- From Omni
'''
print(message)
name = "Piyush"
print(name[0]) # First Index
print(name[-1]) # Index from end
print(name[0:3]) # Index Range(excludes last index e.g- 3 i... | true |
189a85c447639974ff339b9919af9e35f4a17bcb | rohanwarange/TCS | /untitled0.py | 969 | 4.1875 | 4 | # -*- coding: utf-8 -*-
#"""
#Created on Fri Jul 2 08:11:58 2021
#
#@author: ROHAN
#"""
##Prime Numbers with a Twist
#Ques. Write a code to check whether no is prime or not. Condition use function check() to find whether entered no is positive or negative ,if negative then enter the no, And if yes pas no as a paramete... | true |
32f808f78d940ba922717ef7a68cc06605bbc337 | jaarmore/holbertonschool-higher_level_programming | /0x0B-python-input_output/2-read_lines.py | 619 | 4.375 | 4 | #!/usr/bin/python3
"""
Function that read a text file
"""
def read_lines(filename="", nb_lines=0):
"""
Function that reads n lines of a text file
Args:
filename: name of the file
nb_lines: number of lines to read
"""
tlines = 0
with open(filename, encoding='utf-8') as a_file:
... | true |
e7ffe55940e92ed673dfb059f5cba28859b47efd | jaarmore/holbertonschool-higher_level_programming | /0x0B-python-input_output/0-read_file.py | 291 | 4.25 | 4 | #!/usr/bin/python3
"""
Function that reads a text file encoding UTF-8
"""
def read_file(filename=""):
"""
Function that reads a text file
Args:
filename: name of the file
"""
with open(filename, encoding='utf-8') as a_file:
print(a_file.read(), end='')
| true |
214891106b0d01783bf4b01adbd6bde052e6f229 | xiyiwang/leetcode-challenge-solutions | /2021-03/2021-03-15-Codec.py | 1,297 | 4.15625 | 4 | """
LeetCode Challenge: Encode and Decode TinyURL (2021-03-15)
TinyURL is a URL shortening service where you enter a URL
such as https://leetcode.com/problems/design-tinyurl and it
returns a short URL such as http://tinyurl.com/4e9iAk.
Design the encode and decode methods for the TinyURL service.
There is no restr... | true |
fb6218fcf5ea020e46c07bd60b9dbce9a965231a | LEUNGUU/data-structure-algorithms-python | /Recursion/exercises/r401.py | 292 | 4.25 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# find the largest element in a list
def find_maximum(nums: list) -> int:
if len(nums) == 1:
return nums[0]
return max(nums[0], find_maximum(nums[1:]))
if __name__ == "__main__":
print(find_maximum([1, 2, 3, 6, 4, 3, 7]))
| true |
84673b1c1dbcc360060ff262baf293a341bbddb6 | stevedeNero/MIT_OCW_6.0001 | /ps1a.py | 1,354 | 4.21875 | 4 | ####################################
# Gather Salary Information
annual_salary = float(input("How much $ do you make a year?"))
portion_saved = float(input("How much can you set aside to save for down-payment?\n(Enter value in range of 0.0 to 1.0)"))
current_savings = 0.0
####################################
# ... | true |
974e35b53ed0318244f7f5afe881bc97a5ab5ad7 | mlitsey/Learning_Python | /IntroPY4DS/day3/austin-pw.py | 937 | 4.34375 | 4 | # Password entering exercise
# 01. Allow the user to enter a password that matches a secret password
# 02. Allow them to make 5 attempts
# 03. Let them know how many they have made
# 04. Display if password is correct or if max attempts has been reaced.
SECRET_PW = 'katana'
pw_in = ''
cur_attempts = 0
MAX_ATT... | true |
d72179aafd311b6c8edc4e63c8cf6d62786920de | Venkatesh0000/python | /week 4/week.4.2.py | 331 | 4.125 | 4 | string1=input('enter the first string')
string2=input('enter the second string')
if(len(string2)==len(string1)):
if(sorted(string1)== sorted(string2)):
print("The strings are anagrams.")
else:
print("The strings aren't anagrams.")
else:
print("process not ... | true |
ea3ab35f3898ef36af6e484bafae5a243dabdf29 | kameshkotwani/python_assignment | /Assignment_1/grade.py | 1,138 | 4.34375 | 4 | '''
Exercise 1 Test Score Grades Problem Statement
Reboot Academy
This solution is created in python 3.6.4
CAUTION: MAY NOT WORK IN OLDER VERSION
Solved by: Kamesh Kotwani
'''
print("Welcome to Test Score Grade System! This System will help you find out your grade!")
#To take input from user about his test score
s... | true |
3e82ff08a0730088a2f7e6a172bc7aef913a021d | kameshkotwani/python_assignment | /Assignment_1/primes.py | 867 | 4.15625 | 4 | '''
Python Assignment 1 : Reboot Academy
To print the prime numbers in given range
Created using Python 3.6.4
CAUTION: MAY NOT WORK IN OLDER
Solved by: Kamesh Kotwani
'''
print("***Welcome to prime series!***")
n = int(input("Please enter upto which number primes should be displayed : "))
#Making sure if the user... | true |
3d755a8f1806e3d400fba196f694c5c9b08af718 | BradyBallmann/program-arcade-games | /Lab 04 - Camel/main_program.py | 2,558 | 4.25 | 4 | import random
print("Welcome to Camel!")
print("You have stolen a camel to make your way across the great Mobie desert.")
print("The natives want their camel back and are chasing you down! Survive your")
print("desert trek and out run the natives.")
done = False
camel_thirst = 0
camel_tired = 0
miles_traveled = 0
dis... | true |
b6cc6853e89b552fcf879332a2cf2384b2675738 | mikelopez/experimental-labs | /algorithms/heapsort/Python/heapsort_verbose.py | 2,536 | 4.1875 | 4 | """
Heapsort implementation
Timing complexity Best/worse/average: O(n log n)
Each parent node is greater than its child
Given n as the index number in question, find the left/right children
using the following:
- left: 2n + 1
- right: 2n + 2
Check to see if an element is greater than its children.
If not, the val... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.