blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
409b11e470d507ef3320c5788e4a46a5dae2639e | joe-bethke/daily-coding-problems | /DCP-6-20190220.py | 2,912 | 4.25 | 4 | """
This problem was asked by Google.
An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev fields,
it holds a field named both, which is an XOR of the next node and the previous node. Implement an XOR linked list;
it has an add(element) which adds the element ... | true |
dfa59e95e4430f99377a20191dacb99b50f22be3 | joe-bethke/daily-coding-problems | /DCP-27-20190313.py | 1,009 | 4.1875 | 4 | """
This problem was asked by Facebook.
Given a string of round, curly, and square open and closing brackets,
return whether the brackets are balanced (well-formed).
For example, given the string "([])[]({})", you should return true.
Given the string "([)]" or "((()", you should return false.
"""
openers = ("(... | true |
8a0aea7768a2f4dd29d14dfd3d5eec634778ff2c | jbregli/edward_tuto | /gp_classification.py | 2,903 | 4.3125 | 4 | """
EDWARD TUTORIAL: Gaussian process classification
------------------------------------------------
In supervised learning, the task is to infer hidden structure from labeled data,
comprised of training examples $\{(x_n, y_n)\}$.
Classification means the output y takes discrete values.
A Gaussian process is a power... | true |
4199ce2ac053cc5c42e02c8672ac350f5e90d553 | PlumpMath/designPatterns-431 | /prototype/app.py | 1,031 | 4.125 | 4 | #!/usr/bin/python
'''
Prototype pattern.
This creational pattern is similar to an Abstract Factory. The difference is that we do not subclass the Factory,
instead initialize the factorty with objects (the prototypes), and then the factory will clone these objects whenever we ask for a new instance.
The magic 'cloning... | true |
8842d653ca5dfb7fe9d557773e11de745c429b2d | margonjo/variables | /assignment_improvement_exercise.py | 420 | 4.1875 | 4 | #john bain
#variable improvement exercise
#05-09-12
import math
circle_radius = int (input("please enter the radius of the circle: "))
circumfrence = 2* math.pi * circle_radius
final_circumfrence = round(circumfrence,2)
area = math.pi * circle_radius**2
final_area = round(area,2)
print("The circumference of this c... | true |
c0f96908a518fdaddc400049452d16e2b51aa579 | Ilhamw/practicals | /prac_02/ascii_table.py | 453 | 4.25 | 4 | LOWER_BOUND = 33
UPPER_BOUND = 127
character = str(input("Enter a character: "))
print("The ASCII code for {} is {}".format(character, ord(character)))
order = int(input("Enter a number between {} and {}: ".format(LOWER_BOUND, UPPER_BOUND)))
while order < LOWER_BOUND or order > UPPER_BOUND:
order = int(input("Ent... | true |
f1f065347901f3ab8ff3fd885742e7de75fe2b44 | bastolatanuja/lab1 | /lab exercise/question2.py | 398 | 4.15625 | 4 | #write a program that reads the length of the base and the height of the right angled triangle aqnd print the area.
# every number is given on a separate line.
base= int(input('enter the first number'))
height= int(input('enter the second number'))
area= 1/2*(base*height)
#the float division//rounds the result down to ... | true |
2a40f93222078f2c393b8341a85763501ab57ad9 | t3miLo/lc101 | /Unit_1/assignments/analyze_text.py | 1,508 | 4.28125 | 4 | # Write a function analyze_text that receives a string as input.
# Your function should count the number of alphabetic characters
# (a through z, or A through Z) in the text and also keep track of
# how many are the letter 'e' (upper or lowercase).
# Your function should return an analysis of the text in the
# form of... | true |
ad0f14962ab78b9fc41634ddc257bb38b4f14190 | Sankarshan-Mudkavi/Project-Euler | /11-20/Problem-14.py | 1,127 | 4.125 | 4 | """The following iterative sequence is defined for the set of positive integers:
n β n/2 (n is even)
n β 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 β 40 β 20 β 10 β 5 β 16 β 8 β 4 β 2 β 1
It can be seen that this sequence (starting at 13 and finishing at 1) co... | true |
37e3daa4b47ca72f956b5e70595409b99840c880 | kmboese/the-coders-apprentice | /ch13-Dictionaries/stringToDict.py | 652 | 4.125 | 4 | # Converts a comma-separated list of words in a string
# to a dict, with the strings as keys and their
# frequency as a value
text = "apple,durian,banana,durian,apple,cherry,cherry,mango,"+\
"apple,apple,cherry,durian,banana,apple,apple,apple,"+\
"apple,banana,apple"
textDict = {} # dict that holds strings/frequency... | true |
ce8a7a2f4c285dba67a8b43c996d53bf9d133125 | jabuzaid/Python-Challenge---Py-Me-Up-Charlie | /PyBank.py | 2,117 | 4.1875 | 4 | import os
import csv
# Initializing the variable
total_sales_change = 0
greatest_increase = 0
greatest_decrease = 0
# setting up the path of the diretly
file_path = os.path.join('budget_data.csv')
# readindg the rows of the csv file
with open(file_path) as file_handler:
data_lines = csv.reader(file_handler,d... | true |
109fa5c7bb6c4ca98dbe0da4cb4b05fd6b278428 | mmantoniomil94/D4000 | /Cipher.py | 1,489 | 4.3125 | 4 | # Write your methods here after you've created your tests
#A python program to illustrate Caesar Cipher Technique
def login():
user = raw_input("Username: ")
passw = raw_input("Password: ")
f = open("users.txt", "r")
for line in f.readlines():
us, pw = line.strip().split("|")
if (u... | true |
22b4129e4db8c0dd4a4f4b03cd264da540817669 | CodingDojoDallas/python_march_2017 | /jessica_hart/assignments/Basics/string_n_list.py | 1,190 | 4.34375 | 4 | # Print the position of the first instance of the word "monkey"
# Then create a new string where the word "monkey" is replaced with the word "alligator"
str = "If monkeys like bananas, then I must be a monkey!"
print "Index of the first monkey:", str.find("monkey")
new_str = str.replace("monkey", "alligator", 1)
print ... | true |
a7124975646f3fe613bf9575eb1b772056d9dc62 | CodingDojoDallas/python_march_2017 | /jessica_hart/assignments/OOP/animal_class.py | 1,484 | 4.1875 | 4 | class Animal(object):
def __init__(self, name): # Initialize an animal with set health and give name
self.name = name
self.health = 100
def walk(self): # Walking and running drains the animal's health
self.health -= 1
return self
... | true |
61020f395f53b981ec59bb83f3dda2f489182c0a | CodingDojoDallas/python_march_2017 | /jessica_hart/assignments/Basics/coin_toss.py | 665 | 4.15625 | 4 | import random
# Function that simulates tossing a coin a number of times, counting the heads/tails
def coin_toss(reps):
print "Starting the program..."
head_count = 0
tail_count = 0
for count in range(reps):
odds = random.randrange(1, 3) # Random number that's either 1 or 2
if odd... | true |
937b0c965007b3cfbe9d7cb352fb1164f6ef674e | CodingDojoDallas/python_march_2017 | /emmanuel_ogbeide/ASSIGNMENTS/fwf.py | 814 | 4.15625 | 4 | def odd_even():
for count in range (1, 2001):
if count % 2 == 0:
print "Number is " + str(count) + ". This is an even number."
else:
print "Number is " + str(count) + ". This is an odd number."
odd_even()
#Above block checks for oddity of functions
def multiply(a, n):
f... | true |
fcb7036ea15b970d83a5271ffd086306e5119685 | mayurilahane/Python_Practise | /class.py | 1,204 | 4.375 | 4 | # #to delete the object:
# x = "hello"
# print(x) #before deleting object
# del x
# print(x) #after deleting object
class People(object):
def __init__(self, name):
self.name = name
def details(self):
return self.name
class Student(People):
def __init__(self, name, marks):
People.__... | true |
98a83bf5c5bff7844ff705a58d90770bb21ff349 | srinath3101/ibm-yaml-training | /methodsexercise.py | 1,228 | 4.25 | 4 | """
Methods Exercise
Create a method, which takes the state and gross income as the arguments and rereturns the net income after deducting tax based on the state.
Assume Federal Tax: 10%
Assume State tax on your wish.
You don't have to do for all the states, just take 3-4 to solve the purpose of the exercise.
"... | true |
89455d9d17bf3d7b2485edda53e73d9767248469 | srinath3101/ibm-yaml-training | /classdemo2.py | 267 | 4.21875 | 4 | """
Object Oriented Programming
Create your own object
"""
class Car(object):
def __init__(self,make,model='550i'):
self.make=make
self.model=model
c1=Car('bmw')
print(c1.make)
print(c1.model)
c2=Car('benz')
print(c2.make)
print(c2.model)
| true |
40da6ac4d395b6114675ac38d16e8098b4ad6281 | WDLawless1/Python | /pythagoras.py | 432 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 11 07:31:52 2020
@author: user
"""
import math
a = float(input("Please enter the length of the opposite side (in meters): "))
b = float(input("Please enter the length of the adjacent side (in meters): "))
c = math.sqrt(a**2 + b**2)
alpha = math.degrees(math.at... | true |
3e5da2edeee9428bfb9cc80f6415a30865dddb10 | shreyansh225/InfyTQ-Foundation-Courses-Assignment-Answers | /Programming Fundamentals using Python/Day 4/T-strings.py | 1,365 | 4.28125 | 4 | #Creating a string
pancard_number="AABGT6715H"
#Length of the string
print("Length of the PAN card number:", len(pancard_number))
#Concatenating two strings
name1 ="PAN "
name2="card"
name=name1+name2
print(name)
print("Iterating the string using range()")
for index in range(0,len(pancard_number)):
print(pancard... | true |
8cc85a8bd62a281b48ce4aebfb39e9b1a27335b1 | berubejd/PyBites | /278/minmax.py | 790 | 4.46875 | 4 | #!/usr/bin/env python3.8
"""
Bite 278. Major and minor numbers β
You are given a list of integers. Write code to find the majority and minorty numbers in that list.
Definition: a majority number is the one appearing most frequently, a minority number appears least frequently.
Here is a simple example how it should wo... | true |
7f3dde74d2ffe06bb423482b7c05e61b01bebce8 | berubejd/PyBites | /119/xmas.py | 593 | 4.25 | 4 | #!/usr/bin/env python3.8
def generate_xmas_tree(rows=10):
"""Generate a xmas tree of stars (*) for given rows (default 10).
Each row has row_number*2-1 stars, simple example: for rows=3 the
output would be like this (ignore docstring's indentation):
*
***
*****"""
... | true |
33f6282fe2f7dd28ffb268aeba4b20572f028552 | YOlandaMcNeill/cti110 | /M3HW2_BodyMassIndex_YolandaMcNeill.py | 556 | 4.5 | 4 | # This program will calculate a person's BMI and determine if their weight is opimal, underweight, or over weight.
# 6.14.2017
# CTI-110 M3HW1 - Body Mass Index
# YOlanda McNeill
#
#Get user's height.
height = int(input('Enter your height in inches: '))
#Get user's weight.
weight = int(input('Enter your wei... | true |
131b07bdb8ab94d2d138e11b39891acbf766be1d | zacharyaanglin/python-practice | /python-practice/project-euler/problem_nine/main.py | 1,000 | 4.28125 | 4 | """https://projecteuler.net/problem=9
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
from functools import reduce
import math
from ... | true |
4a5aa878a7d9d7c826806bc8ad08a5fea6743f54 | rofernan42/Bootcamp_Python | /day00/ex03/count.py | 642 | 4.34375 | 4 | def text_analyzer(text=""):
"\nThis function counts the number of upper characters, lower characters, punctuation and spaces in a given text."
while (len(text) == 0):
text = input("What is the text to analyse?\n")
print("The text contains " + "%s" % len(text) + " characters:")
print("- " + "%s" ... | true |
ebee8b24709719a3f831f2c361475d2426276f12 | tajimiitju/python_course | /long_class3/marks_tajim.py | 1,089 | 4.15625 | 4 | # coding: utf-8
# In[4]:
#Assignment 1 by tajim
# 3. Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer.
# Calculate TOTAL percentage(Not Each subject) and grade according to following:
# Percentage >= 90% : Grade A
# Percentage >= 80% : Grade B
# Percentage >= 70%... | true |
7d1bbd1d9e764570b537c8f531f73e3db06222ca | dk81/python_math | /arithmeticSeries.py | 1,422 | 4.25 | 4 | # Arithmetic Sequence & Series Functions
# Formula:
# Arithmetic Sequence Formula: end = start + (n - 1)d
# end - start = (n - 1)d
# (end - start) / d = n - 1
# (end - start) / d + 1 = n
def find_term_n(start, n, diff):
if start % 1 != 0:
print("Please choose an integer.")
elif n % 1 != 0 and ... | true |
d3c8944d172df2b52c866c29ad276162389857f0 | Anoopcb/First_variables_1 | /test_one_variables.py | 2,152 | 4.53125 | 5 | #print() function
## first project, how to print in print function
print("Hello world")
print('Hello world')
#string:- collection of character inside "Double quotes"
#or 'single quotes'
# you can use 'single quotes' insides "double quotes" and
#double quotes "" inside single quotes '' but you can not use
#do... | true |
aea1599b5709e0d5c0c45b7c910bf898db701aad | housewing/Data-Structure | /LinkedList/LinkedList.py | 2,091 | 4.125 | 4 | class Node:
def __init__(self, value):
self.data = value
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
def size(self):
current = self.head
count = 0
while current is not None:
count += 1
... | true |
188234f214487f3ed30de2515971e58b099cb6ce | print-Hell/Python-stuff | /Guessing game.py | 1,614 | 4.125 | 4 |
import random
secret_number = (random.randint(0,10))
count = 0
greetings = print(f'Hey Welcome To My Guessing Game Which I Made On Python. You Will Have 3 Guesses And Each Time You Guess I Will Tell You If You Are Close To The Number Or Not.')
print('The secret numbers range is from 1-10')
First_guess ... | true |
f377f51b11c09e8d01e8d6b86f36d5af29fbc7c2 | emmaliden/thePythonWorkbook | /E44.py | 460 | 4.375 | 4 |
month = raw_input("Enter a month of the year (the complete name): ")
day = input("Enter the day of the month: ")
holiday = "No holiday"
if month == "January" and day == 1:
holiday = "New years's day"
if month == "July" and day == 1:
holiday = "Canada day"
if month == "December" and day == 25:
holiday = "Christ... | true |
7cf0243f31c62097919d7fa56a32c0eceea90b2c | emmaliden/thePythonWorkbook | /E66.py | 902 | 4.28125 | 4 |
# Create a grade to points dictionary
gradeToPoints = {'A+':4.0, 'A':4.0, 'A-':3.7, 'B+':3.3, 'B':3.0, 'B-':2.7,
'C+':2.3, 'C':2.0, 'C-':1.7, 'D+':1.3, 'D':1.0, 'F':0}
print(gradeToPoints['A'])
grade = str(input("Input a valid letter grade: "))
grade = grade.upper()
while grade not in gradeToPoints:
print... | true |
8e484d6f171811be50a3b88b3ae08b47ec59bcf6 | emmaliden/thePythonWorkbook | /E39.py | 791 | 4.34375 | 4 |
jackhammer = 130
gas_lawnmower = 106
alarm_clock = 70
quiet_room = 40
decibel = input("What is the decibel level?: ")
if decibel<quiet_room:
print("That's quieter than a quiet room")
elif decibel==quiet_room:
print("That's like a quiet room")
elif decibel<alarm_clock:
print("That's somewhere between a quiet ... | true |
8bf385b881b38c597f1995fc1544f2d4346d3123 | emmaliden/thePythonWorkbook | /E50.py | 753 | 4.34375 | 4 |
# Find the real roots of a quadratic equation
print("A quadratic equation has the form f(x) = ax2 + bx + c, where a, b and c are constants")
print("This program will give you the real roots of your equation")
a = int(input("a: "))
b = int(input("b: "))
c = int(input("c: "))
discriminant = b**2 - 4 * a * c
if disc... | true |
c4d0337daec2b0accdcb4a69d085600ae884718f | raunakkunwar/college-projects | /TkinterGUIProject/Creating_Text_Field.py | 2,831 | 4.21875 | 4 | from tkinter import *
#text widget is not a theme widget of ttk module. So, we don't have to import the ttk module.
root = Tk()
text = Text(root, height = 10, width = 40) #Height and width are defined in characters
text.pack()
text.config(wrap = 'word') #Make each line on the box to wrap after a complete word
... | true |
7d1b724dfd5cb6f52b0c4a035048167f0c475c54 | sutariadeep/datastrcutures_python | /LinkedList/deleting_element_value.py | 1,881 | 4.34375 | 4 | # Python program to delete a node in a linked list
# with a given value
# Node class
class Node:
# Constructor to initialize the node object
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
# Constructor to initialize head
def __init__(self):
sel... | true |
8eee7394059e17e653e83ed3f5581300e104a15c | cowleyk/sort_lists | /sort_lists.py | 1,509 | 4.21875 | 4 | import sys
def mergeSort(formattedLists):
first = formattedLists[0]
second = formattedLists[1]
# first and second are already sorted
# need to perform merge sort and turn each item into an integer
# initialize counting variables and final list
i = 0
j = 0
sorted = []
# typical merge sort approa... | true |
9bfbacd404884eb996501c9c3ce36a8ac912e313 | dishashetty5/Python-for-Everybody-Variables-expressions-and-statements | /chap2 5.py | 264 | 4.25 | 4 | """ Write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit, and print out the
converted temperature"""
celsius=input("enter the degree in celsius")
h=float(celsius)
f=(h*9/5)+32
print("degree in fhrenheit",f)
| true |
f15d96b02094f24ed598aaaa6a1aea1c88eac198 | andrewt18/course | /Python/Lesson_1/GuessNumber.py | 590 | 4.25 | 4 | import random
print('Try to guess the system number.')
count = 0
systemNumber = random.randint(1,100)
while systemNumber != "":
mynumber = int(input("Enter a number: "))
count += 1
if (mynumber < 1) or (mynumber > 100):
print('Please enter a number from 1 to 100: ')
continue
if mynumber < systemNumber:
pri... | true |
1d585ae933bd9a283c1cae1c40347e44f2733655 | mukund7296/Python-Brushup | /01 Data types.py | 1,338 | 4.15625 | 4 | # diffrent types of data types.
# python have default string.
# if you want " between then sue 'wrap with single quote'
# if you want ' between then use "wrap your string here"
print('Mukund Biradar')
print("Mukund's Biradar Laptops's")
print('Mukund"s" Biradar Laptops')
print('Mukund\'s Biradar Laptops')
#... | true |
5cd1586c0e6874f2e43090915d9a7715e10b2a73 | pyMurphy/hacker-olympics-2019 | /Ryan/anagram.py | 206 | 4.15625 | 4 | def anagram(words):
word1,word2=words.strip().split()
if sorted(word1)==sorted(word2):
print('The words are anagrams')
else:
print('The words are not anagrams')
anagram(input()) | true |
2b993c8e8beebcff4186986d900d4bc691220085 | taism-ap/hw-3-3-python-list-problems-IsaacJudeBos | /python_list_find_number.py | 1,298 | 4.125 | 4 | #This is the stuff from list_setup.py
# import the randint function from the random module
from random import randint
# create a function to generate a list of "size" random integers
# up to a maximum of "largest"
def random_list(largest,size):
# create an empty list
l = []
# add a random number to ... | true |
cabea165a389adb76279499a69d9f3d361825a6e | chaositect/pandas | /dataframe_apply_map_and_vector_functions.py | 1,927 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 19 17:32:48 2021
@author: Grant Isaacs
"""
#IMPORT LIBRARIES------------------------------------------------------------->
import pandas as pd
import numpy as np
#LOAD DATA-------------------------------------------------------------------->
dataset = np.round(np.ran... | true |
13d1a5da5e3127187d9f7c85065eb4cca933200d | yuchench/sc101-projects | /stanCode_Projects/hangman_game/rocket.py | 1,726 | 4.28125 | 4 | """
File: rocket.py
Name: Jennifer Chueh
-----------------------
This program should implement a console program
that draws ASCII art - a rocket.
The size of rocket is determined by a constant
defined as SIZE at top of the file.
Output format should match what is shown in the sample
run in the Assignment 2 Han... | true |
da3146f0e7228765ea44b9ca1e64b08121e48ba3 | VagrantXD/Stajirovka | /7kyu/herosRoot.py | 2,096 | 4.59375 | 5 | #!/bin/python3
import math
#One of the first algorithm used for approximating the integer square root of a positive integer n is known as "Hero's method", named after the first-century Greek mathematician Hero of Alexandria who gave the first description of the method. Hero's method can be obtained from Newton's meth... | true |
a08575c9aac62218cf30fd6d3ce7f20f5e366f2f | VagrantXD/Stajirovka | /7kyu/maximumProduct.py | 1,238 | 4.40625 | 4 | #!/bin/python3
#Task
#Given an array of integers , Find the maximum product obtained from multiplying 2 adjacent numbers in the array.
#
#Notes
#Array/list size is at least 2 .
#
#Array/list numbers could be a mixture of positives , ngatives also zeros .
#
#Input >> Output Examples
#adjacent_elements_product([1,2,3]) ... | true |
deffdf32ba128db0d671d254d01b99b41156ee66 | VagrantXD/Stajirovka | /6kyu/threeAddedChar.py | 1,276 | 4.28125 | 4 | #!/bin/python3
#Given two strings, the first being a random string and the second being the same as the first, but with three added characters somewhere in the string (three same characters),
#
#Write a function that returns the added character
#
#E.g
#string1 = "hello"
#string2 = "aaahello"
#
#// => 'a'
#The above is... | true |
edcbb6196c4849ddb5efb2058dbd3d64bb85f2a9 | VagrantXD/Stajirovka | /7kyu/specialNumber.py | 1,455 | 4.46875 | 4 | #!/bin/python3
#Definition
#A number is a Special Number if itβs digits only consist 0, 1, 2, 3, 4 or 5
#
#Task
#Given a number determine if it special number or not .
#
#Warm-up (Highly recommended)
#Playing With Numbers Series
#Notes
#The number passed will be positive (N > 0) .
#
#All single-digit numbers with in ... | true |
1b386bde52a76aa53fe557ea491c71c3e7c2fb2a | SanmatiM/class_problems | /cls_prb3.py | 264 | 4.1875 | 4 | class element:
def elenotrep(n):
n=int(input("enter number of elements in list"))
for i in range(n):
lst1.extend(input("Enter input numbers"))
for num in lst1:
if num not in lst2:
lst2.append(num)
print(lst2)
lst1=[]
lst2=[]
element.elenotrep(3) | true |
65dc7a3f7bb29d1e1187a7010bb51c7ec26c6285 | KidCodeIt/Projects | /Python/Lesson-Three/Using_Variables.py | 825 | 4.4375 | 4 | #using variables in if-else statements
#The different relational and logic operations
# <, <=, >, >=, ==, !=
num1 = 2;
num2 = 3;
#Less than
if num1 < num2:
print "if: num1 is less than num2"
else:
print "This won't be printed"
#Less than or equal to
if num1 <= num2:
print "if: num1 is less than or equal to num2"... | true |
62a693bb17e53756d200a033dbdde1f845174b72 | VictorTruong93/list_exercises_python | /madlibs.py | 578 | 4.1875 | 4 | # # request user to complete a sentence
# print("Please fill complete this statement.")
# print("(Name) enjoys eating (food)")
# # ask user to name character
# character_name=input("What is your name? ")
# # ask user to specify character's favorite food
# character_food=input("What does "+character_name.capitalize()+" ... | true |
d8564359bfe77459d7cad265911cb5ead91e4c39 | ArunRamachandran/ThinkPython-Solutions | /Chapter3/3-4.py | 1,360 | 4.15625 | 4 | # A fn. object is a value you can assign to a variable or pass as an argument
# 'do_twice' is a fn that take a fn objct as an argument and calls it twice
#
def print_spam():
print "spam"
def do_twice(f):
f()
f()
do_twice(print_spam)
# 2.Modify do_twice so that it takes two arguments, a fn objct and a value,
# and... | true |
c54105965152a54322c6b16fc10f08b861304b6a | ndragon798/cse231 | /Spring 2017/labs/Labs/Lab09/lab09_pre-lab_A.py | 744 | 4.25 | 4 |
def display( y ):
x = 2
print( "\nIn display, x:", x )
print( "\nIn display, y:", y )
# Here we print out the actual namespace
# locals is the generic name of the current namepace
# it is a "dictionarly", a data type we will study soon.
# We use 'for' to iterate through ... | true |
06aa9ec917f0403f67c7c5b31f7fb4e0a0cd4fea | BK-Bagchi/52-Programming-Problems-and-Solutions-with-Python | /Prblm39.py | 247 | 4.375 | 4 | def myFunction(string):
return string[::-1]
string= input("Enter your string: ")
length= len(string)
track=0
r_string= myFunction(string)
if string== r_string:
print("Yes! It is palindrome")
else:
print("Sorry! It is not palindrome") | true |
7544207aecd82808003919ebf1a94f31b184b63b | TahirMia/RusheyProjects | /Lists and iterations Task2.py | 266 | 4.125 | 4 | names=[]
print("Please enter 10 names")
for i in range (0,9):
name = input("Enter the next name: ")
names.append(name)
print(names)
grades=[]
for g in range(0,3):
grade_one=input("Enter the grade: ")
grades.append(grade_one)
print(grades)
| true |
fe3195ace5bee163beea3e6bad214b114b45191e | TahirMia/RusheyProjects | /Car Journey Exercise/Car Jouney Exercise program.py | 414 | 4.28125 | 4 | from decimal import *
#Car Journey Exercise
length=Decimal(input("What is the length of your journey(Miles)? "))
##print(length)#+"Miles")
miles=Decimal(input("What is the Miles Per Litre of your car? "))
###print(miles)#+" Miles")
petrol=Decimal(input("What is the cost of 1 litre of fuel for your car? "))
###... | true |
5d5a2e07a56182ca80a6239e179627b7557677e5 | sudo-julia/utility_calculator | /utility_calculator/misc.py | 2,361 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""utilities that would clutter the main file"""
import re
import sys
from typing import Pattern, Tuple, Union
def choose(prompt: str, options: Tuple) -> str:
"""Returns a value that matches a given option from options
Args:
prompt (str): The prompt to display to the user
... | true |
8ebc916533ca720733e65138a35212b0a1e436bc | davesheils/ProgrammingScriptingExercises2018 | /exercise6.py | 734 | 4.15625 | 4 | # Please complete the following exercise this week. Write a Python script containing a function called factorial()
# that takes a single input/argument which is a positive integer and returns its factorial.
# The factorial of a number is that number multiplied by all of the positive numbers less than it.
# For examp... | true |
8b0c6d075d7a3e30d5b522cfbb038ecfc1f57592 | jessieengstrom/hackbright-challenges | /rev-string-recursively/reverse.py | 711 | 4.40625 | 4 | """Reverse a string using recursion.
For example::
>>> rev_string("")
''
>>> rev_string("a")
'a'
>>> rev_string("porcupine")
'enipucrop'
"""
def rev_string(astring):
"""Return reverse of string using recursion.
You may NOT use the reversed() function!
"""
return rev(astri... | true |
670d3b9fa2f5c01e5eab564fd4673e4eadad6aaf | vishalkumarmg1/PreCourse_2 | /Exercise_2.py | 776 | 4.15625 | 4 | # Python program for implementation of Quicksort Sort
# give you explanation for the approach
def partition(arr,low,high):
divider = low
pivot = high
for i in range(low, high):
if arr[i]<arr[pivot]:
arr[i], arr[divider] = arr[divider], arr[i]
divider+=1
arr[... | true |
0c2d4cb3120adc97754be9e56d9658824f836be4 | ipiyushbhoi/Data-Structures-and-Algorithm-Problems | /advanced_recursion/string_permutations.py | 742 | 4.125 | 4 | '''
Given a string S, find and return all the possible permutations of the input string.
Note 1 : The order of permutations is not important.
Note 2 : If original string contains duplicate characters, permutations will also be duplicates.
Input Format :
String S
Output Format :
All permutations (in different lines)
Sa... | true |
e8ad5c3a208bba93462c2a4c01442cad1156e239 | RahulGusai/data-structures | /python/binaryTrees/completeBTree_Set1.py | 1,475 | 4.15625 | 4 | #! /usr/bin/python3
# Linked List node
class ListNode:
# Constructor to create a new node
def __init__(self, data):
self.data = data
self.next = None
# Binary Tree Node structure
class BinaryTreeNode:
# Constructor to create a new node
def __init__(self, data... | true |
c353f685b57b14f533c3e7acc13cb4614d8e90d2 | Constracted/Quadratic-Equation-Solver | /main.py | 717 | 4.28125 | 4 | # This program will calculate the roots of a quadratic equation.
def root_one(a, b, c):
"""This function returns the first root of a quadratic equation."""
return (-b + (b ** 2 - (4 * a * c)) ** 0.5) / (2 * a)
def root_two(a, b, c):
"""This function returns the second root of a quadratic equation."""
... | true |
011d51ac45defe61a5ca8bc2994429f282aaa01c | MartynaKlos/codewars | /top_3_words.py | 1,759 | 4.40625 | 4 | # Write a function that, given a string of text (possibly with punctuation and line-breaks), returns an array of the top-3 most occurring words, in descending order of the number of occurrences.
# Assumptions:
#
# A word is a string of letters (A to Z) optionally containing one or more apostrophes (') in ASCII. (No... | true |
fc92e34f107f17f3a609f874e6741865deebaca1 | nguyenmanhtrung/trungza1 | /nguyenmanhtrung_44617_ca18a1a-cp4/nguyenmanhtrung_44617_ca18a1a/project1/project_09_page_132.py | 912 | 4.21875 | 4 | """
Author: Nguyα»
n Manh Trung
Date: 24/09/2021
Problem:Write a script named numberlines.py. This script creates a program listing from a
source program. This script should prompt the user for the names of two files. The
input filename could be the name of the script itself, but be careful to use a different
outpu... | true |
28c19c69d1454176ed834d386a1083a1526454e6 | nguyenmanhtrung/trungza1 | /Nguyenmanhtrung_44617_cp7/Nguyenmanhtrung_44617/Exercises/page_218_exercise_06.py | 509 | 4.53125 | 5 | """
Author: nguyα»
n manh trung
Date: 16/10/2021
Problem: The Turtle class includes a method named circle. Import the Turtle class, run help(Turtle.circle),
and study the documentation. Then use this method to draw a filled circle and a half moon.
Solution:
....
"""
import turtle
# Initializing the turtle
... | true |
7d1f79f08afcbf423ef06aa1264afbf610d6dd08 | nguyenmanhtrung/trungza1 | /nguyenmanhtrung_44617_ca18a1a-cp4/nguyenmanhtrung_44617_ca18a1a/excercise/page_118_exercise_01.py | 599 | 4.375 | 4 | """
Author: Nguyα»
n Manh Trung
Date: 24/09/2021
Problem:
Assume that the variable data refers to the string "Python rules!". Use a string
method from Table 4-2 to perform the following tasks:
a. Obtain a list of the words in the string.
b. Convert the string to uppercase.
c. Locate the position of the string "ru... | true |
840f14e9c48726caaf7793f6e94dfd207c84100b | nguyenmanhtrung/trungza1 | /Nguyenmanhtrung_44617_cp7/Nguyenmanhtrung_44617/Exercises/page_237_exercise_05.py | 605 | 4.3125 | 4 | """
Author: nguyα»
n manh trung
Date: 16/10/2021
Problem:How would a column-major traversal of a grid work? Write a code segment that prints the positions
visited by a column-major traversal of a 2-by-3 grid.
Solution:
A nested loop structure to traverse a grid consists of two loops, an outer one and an inner o... | true |
32ff46f1bd054b7a46fc079e9e8ee4ddd68d235e | nguyenmanhtrung/trungza1 | /nguyenmanhtrung_44617_cp5/nguyenmanhtrung_44617_cp5/Projects/page_165_project_08.py | 766 | 4.15625 | 4 | """
Author:Nguyα»
n MαΊ‘nh Trung
Date: 11/10/2021
Problem:
A file concordance tracks the unique words in a file and their frequencies. Write
a program that displays a concordance for a file. The program should output the
unique words and their frequencies in alphabetical order. Variations are to track
... | true |
2230e5a682d642073894a5f5be96bfc840b2928e | seelander09/PythonWork | /Scores/scoresGrades.py | 815 | 4.25 | 4 | # # Write a function that generates ten scores between 60 and 100.
# Each time a score is generated, your function should display what
# the grade is for a particular score. Here is the grade table:
# #
# Score: 60 - 69; Grade - D
# Score: 70 - 79; Grade - C
# Score: 80 - 89; Grade - B
# Score: 90 - 100; Grade - A
impo... | true |
edf53b758cde452219a1de64c8efe63bf5ffdb16 | 2023PHOENIX/Hackerrank-Python | /String_split_and_join.py | 332 | 4.28125 | 4 | S = input()
"""
In Python, a string can be split on a delimiter.
Example:
>>> a = "this is a string"
>>> a = a.split(" ") # a is converted to a list of strings.
>>> print a
['this', 'is', 'a', 'string']
Joining a string is simple:
>>> a = "-".join(a)
>>> print a
this-is-a-string """
S = S.split(" ")
Z = "-".join(... | true |
e3cf726e6657a1a578317dbf474ce06a340a287d | Shubhampy-code/Data_Structure_Codes | /Array_Codes/SmallestNum_largestNum_num.py | 480 | 4.125 | 4 | #find largest and smallest number in the array.
from array import*
my_array = array("i",[56562,2222,563,2,65555,926,347,32,659,6181,9722,4533,1244,505,7566,9577,88])
i=0
largest_num = my_array[i]
small_num = my_array[i]
while i < len(my_array):
if my_array[i]>=largest_num:
largest_num = my_array[i]
eli... | true |
d3e48d569191df1bced6213e15647091350e509f | Shubhampy-code/Data_Structure_Codes | /Array_Codes/Count_odd_even_element.py | 415 | 4.1875 | 4 | # how many odd and how many even number present in array.
from array import*
my_array = array('i',[4,5,6,7,8,9,3,3,3,3,3,3,3,1,2])
i=0
found = 0
odd=0
even = 0
while i < len(my_array):
if ((my_array[i])%2==0):
even = even + 1
elif ((my_array[i])%2 != 0):
odd = odd + 1
i=i+1
print("Odd numbe... | true |
2bdebc1bd62f82252b5ed68cd7f1f1b1f80d01b7 | Elena-May/MIT-Problem-Sets | /ps4/ps4a.py | 2,366 | 4.28125 | 4 | # Problem Set 4A
# Name: <your name here>
# Collaborators:
# Time Spent: x:xx
import random
def get_permutations(sequence):
'''
Enumerate all permutations of a given string
sequence (string): an arbitrary string to permute. Assume that it is a
non-empty string.
You MUST use recurs... | true |
aef2a8bc567764bc3b9ea89990d75e76e27d3cf7 | hsharma267/python_programs-with-w3school | /Pythn_NumPy/numpy_data_type.py | 1,115 | 4.28125 | 4 | # Data Types in NumPy
import numpy as np
print("<-- Data Types in Numpy -->")
"""
1.) i-> integer 2.) b-> boolean 3.) u-> unsigned integer
4.) f-> float 5.) c-> complex float 6.) m-> timedelta
7.) M-> datetime 8.) O-> Object 9.) S-> String
10.) U-> un... | true |
d0c615256540f0c7294066e4ebc8f1956710057b | hsharma267/python_programs-with-w3school | /Pythn_ tutorial/py_fileHandling.py | 2,079 | 4.40625 | 4 | # File Handling
"""
# Python File Open
# File handling is an important part of any web application.
# Python has several function for creating,reading,updating,and deleting files.
# File Handling
# There are several different methods(modes) for opening a file:-
# 1. "r" - Default value. Open a file for reading,erro... | true |
bf0ed3a6ac93ed4748afd401cbc8aca715f499ac | AMao7/Project_Mr_Miyagi | /Mr_Miyagi.py | 663 | 4.15625 | 4 | while True:
question = (input("what is your question sir ")).strip().lower()
print("questions are wise, but for now. Wax on, and Wax off!")
if "sensei" not in question:
print("You are smart, but not wise, address me as sensei please")
elif "block" or "blocking:" in question:
print("Re... | true |
55ef09f37beb7dffabe79a811837a8c0a042a4de | ComeOnTaBlazes/Programming-Scripting | /wk5weekday.py | 353 | 4.28125 | 4 | # James Hannon
# Create program to confirm if today is a weekday
# Import datetime
import datetime
x= datetime.datetime.now().weekday()
#test of if formula
#x = 5
#print (x)
# Weekday values in tuple list
Wkday = range (0, 5)
#x = datetime.datetime.now().weekday()
if x in Wkday:
print ("Today is a weekday")... | true |
4b79c179840e0dcebdb70592acfc383a3cae03ba | JarrodPW/cp1404practicals | /prac_01/loops.py | 825 | 4.53125 | 5 | # 3. Display all of the odd numbers between 1 and 20 with a space between each one
for i in range(1, 21, 2):
print(i, end=' ')
print()
# a) Display a count from 0 to 100 in 10s with a space between each one
for i in range(0, 101, 10):
print(i, end=' ')
print()
# b) Display a count down from 20 to 1 with a spa... | true |
5e994a2d80337153a660e00aaded081737907002 | ilante/programming_immanuela_englander | /simple_exercises/lanesexercises/py_lists_and_loops/4.addlist_from_2.py | 352 | 4.21875 | 4 | # 4. use the function addlist from point 3 to sum the numbers from point 2
x='23|64|354|-123'
y=x.split("|")
print(y)
number_list =[] # need to append int transformed stringnum
for i in y:
number_list.append(int(i))
print(number_list)
def addlist(Liste):
sum=0
for el in Liste:
sum += el
return ... | true |
3eb59906b65d759a145c8503e3be187ae8f80b5a | ilante/programming_immanuela_englander | /simple_exercises/lanesexercises/py_if_and_files/4-11_more_liststuff.py | 1,040 | 4.21875 | 4 | # 4. put the values 5,2,7,8,1,-3 in a list, in this order
li=[5,2,7,8,1,-3]
# 5. print the first and the third value in the list
print('question 5')
print(li[0], li[2])
# 6. print the double of all the values in the list
print('question 6:')
doubleli=[]
for el in li:
dob = el*2
doubleli.append(dob)
print(doub... | true |
253ee4b4fe35698ff0e94e0f4820db33167c3a08 | linkeshkanna/ProblemSolving | /EDUREKA/Course.3/Case.Study.2.Programs/target.Right.Customers.For.A.Banking.Marketing.Campaign.py | 2,297 | 4.125 | 4 | """
A Bank runs marketing campaign to offer loans to clients
Loan is offered to only clients with particular professions
List of successful campaigns (with client data) is given in attached dataset
You have to come up with program which reads the file and builds a set of unique profession list
Get input from User for ... | true |
93daf1a021a125b2d2568d299e94779795c3b7a8 | jonahnorton/reference | /recipes/function.py | 635 | 4.125 | 4 |
# create my own function and call it
# https://www.tutorialspoint.com/python/python_functions.htm
# ==================================================
# simple function call
def myfunction(x, y):
z = x + y
return z
myvalue = myfunction(3, 4)
print(myvalue)
myvalue = myfunction(5, 3)
print(myvalue)
print("... | true |
96aa3e910490ce0fb063ef1ad3faa3eb94ff8787 | matyh/MITx_6.00.1x | /Week2/Problem2.py | 1,820 | 4.53125 | 5 | # Now write a program that calculates the minimum fixed monthly payment needed
# in order pay off a credit card balance within 12 months. By a fixed monthly
# payment, we mean a single number which does not change each month, but
# instead is a constant amount that will be paid each month.
#
# In this problem, we will ... | true |
da3a76cfa02b4e807711be21ab4052bb88d8dabc | Shankhanil/CodePractice | /Project Euler/prob14.py | 1,184 | 4.15625 | 4 | """
The following iterative sequence is defined for the set of positive integers:
n β n/2 (n is even)
n β 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 β 40 β 20 β 10 β 5 β 16 β 8 β 4 β 2 β 1
It can be seen that this sequence (starting at 13 and finishing at 1) c... | true |
237757575f46ccadcff1469e1b4398260299d081 | Shankhanil/CodePractice | /Project Euler/prob9.py | 512 | 4.21875 | 4 | """
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc
"""
import math as m
if __name__ == "__main__":
N = 1000
for i in r... | true |
763b465c86db6fd897bd46f07364a9d9b8d75bb0 | MaxSpanier/Small-Projects | /Reverse_String/reverse_string.py | 947 | 4.25 | 4 | import sys
class ReverseString():
def __init__(self, string):
self.string = string
def GUI(self):
self.string = input("Please enter a string:\n")
def reverse(self, given_string):
return given_string[::-1]
def play_again(self):
choice = str(input("---------------------... | true |
894927d48c2c671786b6ad1ee8ac1e854059feaa | MohammedBhatti/code1 | /dogpractice.py | 611 | 4.15625 | 4 | dogs = ("beagle", "collie", "healer", "pug")
dogs_characteristics = {}
list_of_characteristics = [1, 25, 'ball']
# Loop through the list and print each value out
for dog in dogs:
if dog == "healer":
print(dog)
# Create the dict object
dogs_characteristics["breed"] = dog
dogs_characteristics[... | true |
d3dc0d902f8120e90c4b85b87ef67c31b0709736 | devendra631997/python_code_practice | /graph/graph.py | 1,540 | 4.25 | 4 | # 1 2 8
# 2 3 15
# 5 6 6
# 4 2 7
# 7 5 30
# 1 5 10
# 3 5
# 2 7
# 1 6
# Add a vertex to the dictionary
def add_vertex(v):
global graph
global vertices_no
if v in graph:
print("Vertex ", v, " already exists.")
else:
vertices_no = vertices_no + 1
graph[v] = []
# Add an edge between vertex v1 and v2 w... | true |
b701b7cbcf31f704ec7d3cea7ab5a7f9092e542f | harshitksrivastava/Python3Practice | /DynamicPrograms/factorial.py | 904 | 4.34375 | 4 | # factorial using recursion without Dynamic Programming
# def fact(number):
# if number == 0:
# return 1
# else:
# return number * fact(number - 1)
# =====================================================================================================================
# factorial using recursio... | true |
9da4d5948208d4e7453bf288bfcf173c4d88beed | AM-ssfs/py_unit_five | /multiplication.py | 556 | 4.21875 | 4 | def multiplication_table(number):
"""
Ex. multiplication_table(6) returns "6 12 18 24 30 36 42 48 54 60 66 72 "
:param number: An integer
:return: A string of 12 values representing the mulitiplication table of the parameter number.
"""
table = ""
for x in range(1, 13):
table = table... | true |
887631e111b25443c7d554ebabf65b5e4cbb7e77 | eloghin/Python-courses | /PythonZTM/100 Python exercises/42.Day11-filter-map-lambda-list.py | 517 | 4.125 | 4 | # Write a program which can map() and filter() to make a list whose elements
# are square of even number in [1,2,3,4,5,6,7,8,9,10].
def map_func(l):
l = filter(lambda x: x%2==1, l)
m = map(lambda x:x*x, l)
return list(m)
print(map_func([1,2,3,4,5,6,7,8,9,10]))
******* SOL 2 *******
def even(x):
return x%2... | true |
66d361ff9b192cd686c4457bc1136c993f48e9b4 | eloghin/Python-courses | /HackerRank/interview-prep-kit-alternating-characters.py | 1,195 | 4.125 | 4 | """
You are given a string containing characters A and B only.
Your task is to change it into a string such that there are
no matching adjacent characters. To do this, you are allowed to delete zero or more characters in the string.
Your task is to find the minimum number of required deletions.
https... | true |
bbb2aa394383ae52f42b842cdd19ab2d1cf46b30 | eloghin/Python-courses | /PythonZTM/100 Python exercises/22. Day08-word-frequency-calculator.py | 436 | 4.1875 | 4 | """
Write a program to compute the frequency of the words from the input. The output should output after sorting the key alphanumerically.
"""
string = 'New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3.'
words = string.split()
word_count = {}
for word in words:
if word in word_co... | true |
cfea624a44abf9270a0c69817d417779a2d91973 | eloghin/Python-courses | /ThinkPython/12.5.CompareTuples.py | 816 | 4.25 | 4 | """
Play hangman in max 10 steps
"""
"""
Exercise 2
In this example, ties are broken by comparing words, so words with the same length appear
in reverse 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.... | true |
a974ff163d113eebcc41271208d3610d7f00fd76 | eloghin/Python-courses | /PythonZTM/100 Python exercises/39.Day11-filter-print-tuple.py | 509 | 4.1875 | 4 |
"""
Write a program to generate and print another tuple whose values are
even numbers in the given tuple (1,2,3,4,5,6,7,8,9,10).
"""
def create_tuple(t):
t2 = tuple((i for i in t if i%2==1))
print(t2)
create_tuple((1,2,3,4,5,6,7,8,9))
******* SOL 2 *******
tpl = (1,2,3,4,5,6,7,8,9,10)
tpl1 = tuple(filter(la... | true |
10166a92e26316e1182a17528bfa73e88f4364e4 | eloghin/Python-courses | /LeetCode/contains_duplicate.py | 703 | 4.1875 | 4 | # Given an array of integers that is already sorted in ascending order, find two numbers such that
# they add up to a specific target number.
# 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 ... | true |
3ac0db2e66847721aad13697fad5ec3bc54353fb | eloghin/Python-courses | /HackerRank/string_Ceasar_cipher.py | 1,605 | 4.59375 | 5 | """Julius Caesar protected his confidential information by encrypting it using a cipher. Caesar's cipher shifts each letter by a number of letters. If the shift takes you past the end of the alphabet, just rotate back to the front of the alphabet. In the case of a rotation by 3, w, x, y and z would map to z, a, b and c... | true |
c8a7f351613de02685ee86346e6ee5ad75f01835 | eloghin/Python-courses | /ThinkPython/12.4.SumAll.py | 443 | 4.46875 | 4 | """
Play hangman in max 10 steps
"""
"""
Exercise 1
Many of the built-in functions use variable-length argument tuples. For example, max and min can take
any number of arguments:
>>> max(1,2,3)
3
But sum does not.
>>> sum(1,2,3)
TypeError: sum expected at most 2 arguments, got 3
Write a function called sumall ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.