blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
eed8d54cb38af8b0bb62927b9dadfdf0aa69d378 | debargham14/bcse-lab | /Sem 4/Adv OOP/python_assignments_set1/sol10.py | 444 | 4.125 | 4 | import math
def check_square (x) :
"Function to check if the number is a odd square"
y = int (math.sqrt(x))
return y * y == x
# input the list of numbers
print ("Enter list of numbers: ", end = " ")
nums = list (map (int, input().split()))
# filter out the odd numbers
odd_nums = filter (lambda x: x%2 == 1, nums)
... | true |
669f4bbca09f2d6062be01a30fdfd0f7a0367394 | mckinleyfox/cmpt120fox | /pi.py | 487 | 4.15625 | 4 | #this program is used to approximate the value of pi
import math
def main():
print("n is the number of terms in the pi approximation.")
n = int(input("Enter a value of n: "))
approx = 0.0
signchange = 1.0
for i in range(1, n+1, 2):
approx = approx + signchange * 4.0/i # JA
signchange... | true |
0b1c100231c6dbe5d970655a92f4baed0cbe1221 | firoj1705/git_Python | /V2-4.py | 1,745 | 4.3125 | 4 |
'''
1. PRINT FUNCTION IN PYTHON:
print('hello', 'welcome')
print('to', 'python', 'class')
#here by default it will take space between two values and new line between two print function
print('hello', 'welcome', end=' ')
print('to', 'python', 'class')
# here we can change end as per our requirement, by addind end=' ... | true |
c5db4886b9e216f7da109bcfdd190a2267d7258b | BMHArchives/ProjectEuler | /Problem_1/Problem_1.py | 1,128 | 4.21875 | 4 | # Multiples of 3 and 5
#---------------------
#If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
#Find the sum of all the multiples of 3 or 5 below 1000.
numberCount = 1000 # Use this number to find all multiples under the numberCount
total... | true |
c219b35384dcc23574658cfcbae883f4223f8709 | LRG84/python_assignments | /average7.5.py | 538 | 4.28125 | 4 | # calculate average set of numbers
# Write a small python program that does the following:
# Calculates the average of a set of numbers.
# Ask the user how many numbers they would like to input.
# Display each number and the average of all the numbers as the output.
def calc_average ():
counter = int (input('How ... | true |
f179a86035e710a59300a467e2f3cd4e9f8f0b15 | tweatherford/COP1000-Homework | /Weatherford_Timothy_A3_Gross_Pay.py | 1,299 | 4.34375 | 4 | ##-----------------------------------------------------------
##Programmed by: Tim Weatherford
##Assignment 3 - Calculates a payroll report
##Created 11/10/16 - v1.0
##-----------------------------------------------------------
##Declare Variables##
grossPay = 0.00
overtimeHours = 0
overtimePay = 0
regularPay = 0
#Fo... | true |
046ecafc48914b85956a7badd6b8500232a57db4 | lathika12/PythonExampleProgrammes | /areaofcircle.py | 208 | 4.28125 | 4 | #Control Statements
#Program to calculate area of a circle.
import math
r=float(input('Enter radius: '))
area=math.pi*r**2
print('Area of circle = ', area)
print('Area of circle = {:0.2f}'.format(area)) | true |
362eb0297bbb144719be1c76dc4696c141b72017 | lathika12/PythonExampleProgrammes | /sumeven.py | 225 | 4.125 | 4 | #To find sum of even numbers
import sys
#Read CL args except the pgm name
args = sys.argv[1:]
print(args)
sum=0
#find sum of even args
for a in args:
x=int(a)
if x%2==0:
sum+=x
print("Sum of evens: " , sum) | true |
99ef2163869fda04dbe4f1c23b46e56c14af7a17 | TredonA/PalindromeChecker | /PalindromeChecker.py | 1,822 | 4.25 | 4 | from math import floor
# One definition program to check if an user-inputted word
# or phrase is a palindrome. Most of the program is fairly self-explanatory.
# First, check if the word/phrase in question only contains alphabetic
# characters. Then, based on if the word has an even or odd number of letters,
# begin co... | true |
a113879ec0112ff4c269fb2173ed845c29a3b5e5 | ravenclaw-10/Python_basics | /lists_prog/max_occur_elem.py | 708 | 4.25 | 4 | # Element with maximum occurence in a list=[2, 3, 8, 4, 7, 9, 8, 2, 6, 5, 1, 6, 1, 2, 3, 4, 6, 9, 1, 2] .
#Python program to check if the elements of a given list are unique or not.
n=int(input("Enter the no. of element in the list(size):"))
list1=[]
count=0
max=0
print("Enter the elements of the lists:")
for ... | true |
6094c69f6d4fa7a0bb59fc8da0eb7fb379832514 | Boukos/AlgorithmPractice | /recursion/rec_len.py | 328 | 4.1875 | 4 | def rec_len(L):
"""(nested list) -> int
Return the total number of non-list elements within nested list L.
For example, rec_len([1,'two',[[],[[3]]]]) == 3
"""
if not L:
return 0
elif isinstance(L[0],list):
return rec_len(L[0]) + rec_len(L[1:])
else:
return 1 + rec_len(L[1:])
print rec_len([1,'two',[[],... | true |
15f68fe0b019bb466d2d7bcfbd83c6baabf2efc4 | eyeCube/Softly-Into-the-Night-OLD | /searchFiles.py | 925 | 4.125 | 4 | #search a directory's files looking for a particular string
import os
#get str and directory
print('''Welcome. This script allows you to search a directory's
readable files for a particular string.''')
while(True):
print("Current directory:\n\n", os.path.dirname(__file__), sep="")
searchdir=input("... | true |
8097283ba70a2e1ee33c31217e4b9170a45f2dd1 | NagarajuSaripally/PythonCourse | /StatementsAndLoops/loops.py | 2,014 | 4.75 | 5 | '''
Loops: iterate through the dataypes that are iterable, iterable datatypes in python or in any language
string, lists, tuples, dictionaries
keywords to iterate through these iterables:
#for
syntax
for list_item in list_items:
print(list_item)
'''
# lists:
my_list_items = [1,2,3,4,5,6]
for my_list_item in my... | true |
30cf7566ca858b10b86bf6ffc72826de02134db2 | NagarajuSaripally/PythonCourse | /Methods/lambdaExpressionFiltersandMaps.py | 1,141 | 4.5 | 4 | '''
Lambda expressions are quick way of creating the anonymous functions:
'''
#function without lamda expression:
def square(num):
return num ** 2
print(square(5))
#converting it into lambda expression:
lambda num : num ** 2
#if we want we can assign this to variable like
square2 = lambda num : num ** 2. # we are... | true |
3f947479dbb78664c2f12fc93b926e26d16d2c34 | ankurkhetan2015/CS50-IntroToCS | /Week6/Python/mario.py | 832 | 4.15625 | 4 | from cs50 import get_int
def main():
while True:
print("Enter a positive number between 1 and 8 only.")
height = get_int("Height: ")
# checks for correct input condition
if height >= 1 and height <= 8:
break
# call the function to implement the pyramid structure
... | true |
49d3fbe78c86ab600767198110c6022be77fefe9 | SagarikaNagpal/Python-Practice | /QuesOnOops/F-9.py | 507 | 4.1875 | 4 | # : Write a function that has one character argument and displays that it’s a small letter, capital letter, a digit or a special symbol.
# 97-122 65-90 48-57 33-47
def ch(a):
if(a.isupper()):
print("u... | true |
43462ac259650bcea0c4433ff1d27d90bbc7a09e | SagarikaNagpal/Python-Practice | /QuesOnOops/C-4.py | 321 | 4.40625 | 4 | # input a multi word string and produce a string in which first letter of each word is capitalized.
# s = input()
# for x in s[:].split():
# s = s.replace(x, x.capitalize())
# print(s)
a1 = input("word1: ")
a2 = input("word2: ")
a3 = input("word3: ")
print(a1.capitalize(),""+a2.capitalize(),""+a3.capitalize()... | true |
c56fecfa02ec9637180348dd990cf646ad00f77f | SagarikaNagpal/Python-Practice | /QuesOnOops/B-78.py | 730 | 4.375 | 4 | # Write a menu driven program which has following options:
# 1. Factorial of a number.
# 2. Prime or Not
# 3. Odd or even
# 4. Exit.
n = int(input("n: "))
menu = int(input("menu is: "))
factorial = 1
if(menu==1):
for i in range(1,n+1):
factorial= factorial*i
print("factorial of ",n,"is",factorial)
el... | true |
7b8acefe0e74bdd25c9e90f869009c2e3a24a4fc | SagarikaNagpal/Python-Practice | /QuesOnOops/C-13.py | 213 | 4.40625 | 4 | # to input two strings and print which one is lengthier.
s1 = input("String1: ")
s2 = input("String2: ")
if(len(s1)>len(s2)):
print("String -",s1,"-is greater than-", s2,"-")
else:
print(s2,"is greater") | true |
a33e791b4fc099c4e607294004888f145071e6ff | SagarikaNagpal/Python-Practice | /QuesOnOops/A22.py | 254 | 4.34375 | 4 | #Question A22: WAP to input a number. If the number is even, print its square otherwise print its cube.
import math
a=int(input("num: "))
sq = int(math.pow(a,2))
cube =int (math.pow(a,3))
if a%2==0:
print("sq of a num is ",sq)
else:
print(cube) | true |
169945565fd5ffb9c590d7a38715b3a08a8280ff | SagarikaNagpal/Python-Practice | /QuesOnOops/A-10.py | 248 | 4.34375 | 4 | # to input the number the days from the user and convert it into years, weeks and days.
days = int(input("days: "))
year = days/365
days = days%365
week = days/7
days = days%7
day = days
print("year",year)
print("week",week)
print("day",day)
| true |
f8087e5bf4e1234b7dddf18f6cd7f3612b4563c4 | ElminaIusifova/week1-ElminaIusifova | /04-Swap-Variables**/04.py | 371 | 4.15625 | 4 | # # Write a Python program to swap two variables.
#
# Python: swapping two variables
#
# Swapping two variables refers to mutually exchanging the values of the variables. Generally, this is done with the data in memory.
#
#
# ### Sample Output:
# ```
# Before swap a = 30 and b = 20
# After swaping a = 20 and b = 30
# `... | true |
da4cf09617b4a09e36a1afa5ebcb28ae049331fe | ElminaIusifova/week1-ElminaIusifova | /01-QA-Automation-Testing-Program/01.py | 968 | 4.28125 | 4 | ## Create a program that asks the user to test the pages and automatically tests the pages.
# 1. Ask the user to enter the domain of the site. for example `example.com`
# 2. After entering the domain, ask the user to enter a link to the 5 pages to be tested.
# 3. Then display "5 pages tested on example.com".
# 4. Add e... | true |
563c9c6658a045bee7b35b510f706a1ae17039b8 | Dilan/projecteuler-net | /problem-057.py | 1,482 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# It is possible to show that the square root of two can be expressed as an infinite continued fraction.
# √ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213...
# By expanding this for the first four iterations, we get:
# 1 + 1/2 = 3/2 = 1.5
# 1 + 1/(2 + 1/2) = 7/5 = 1.4... | true |
3f2e1e7f00004e07ed45b0499bfcacb873d6ef92 | CodedQuen/python_begin1 | /simple_database.py | 809 | 4.34375 | 4 | # A simple database
people = {
'Alice': {
'phone': '2341',
'addr': 'Foo drive 23'
},
'Beth': {
'phone': '9102',
'addr': 'Bar street 42'
},
'Cecil': {
'phone': '3158',
'addr': 'Baz avenue 90'
}
}
# Descriptive lables for the phone... | true |
e84ea0ce2afb28b4bb2c13a0f8b44fbbb08788bc | aayanqazi/python-preparation | /A List in a Dictionary.py | 633 | 4.25 | 4 | from collections import OrderedDict
#List Of Dictionary
pizza = {
'crust':'thick',
'toppings': ['mashrooms', 'extra cheese']
}
print("You ordered a " + pizza['crust'] + "-crust pizza " +
"with the following toppings:")
for toppings in pizza['toppings']:
print ("\t"+toppings)
#Examples 2
favourite... | true |
05a1e4c378524ef50215bd2bd4065b9ab696b80d | Glitchier/Python-Programs-Beginner | /Day 2/tip_cal.py | 397 | 4.15625 | 4 | print("Welcome to tip calculator!")
total=float(input("Enter the total bill amount : $"))
per=int(input("How much percentage of bill you want to give ? (5%, 10%, 12%, 15%) : "))
people=int(input("How many people to split the bill : "))
bill_tip=total*(per/100)
split_amount=float((bill_tip+total)/people)
final... | true |
507fdcb28060f2b139b07853c170974939267b63 | Abhinav-Rajput/CodeWars__KataSolutions | /Python Solutions/Write_ Number_in_Expanded_Form.py | 611 | 4.34375 | 4 | # Write Number in Expanded Form
# You will be given a number and you will need to return it as a string in Expanded Form. For example:
# expanded_form(12) # Should return '10 + 2'
# expanded_form(42) # Should return '40 + 2'
# expanded_form(70304) # Should return '70000 + 300 + 4'
def expanded_form(num):
strNum... | true |
b8ca7993c15513e13817fa65f892ebd014ca5743 | Satona75/Python_Exercises | /Guessing_Game.py | 816 | 4.40625 | 4 | # Computer generates a random number and the user has to guess it.
# With each wrong guess the computer lets the user know if they are too low or too high
# Once the user guesses the number they win and they have the opportunity to play again
# Random Number generation
from random import randint
carry_on = "y"
while... | true |
c069374b1d2c822c9a71b4c7c95ac5e7e3ca945f | Satona75/Python_Exercises | /RPS-AI.py | 1,177 | 4.3125 | 4 | #This game plays Rock, Paper, Scissors against the computer.
print("Rock...")
print("Paper...")
print("Scissors...\n")
#Player is invited to choose first
player=input("Make your move: ").lower()
#Number is randomly generated between 0 and 2
import random
comp_int=random.randint(0, 2)
if comp_int == 0:
computer... | true |
474ae873c18391c8b7872994da02592b59be369c | Satona75/Python_Exercises | /RPS-AI-refined.py | 1,977 | 4.5 | 4 | #This game plays Rock, Paper, Scissors against the computer
computer_score = 0
player_score = 0
win_score = 2
print("Rock...")
print("Paper...")
print("Scissors...\n")
while computer_score < win_score and player_score < win_score:
print(f"Computer Score: {computer_score}, Your Score: {player_score}")
#P... | true |
19dbab140d55e0b7f892d66f08b9dc26ba5f4095 | timurridjanovic/javascript_interpreter | /udacity_problems/8.subsets.py | 937 | 4.125 | 4 | # Bonus Practice: Subsets
# This assignment is not graded and we encourage you to experiment. Learning is
# fun!
# Write a procedure that accepts a list as an argument. The procedure should
# print out all of the subsets of that list.
#iterative solution
def listSubsets(list, subsets=[[]]):
if len(list) == 0... | true |
c593ca80cbc671e86d12f8d2ffaf0829fdb024ea | jacobfdunlop/TUDublin-Masters-Qualifier | /10.py | 470 | 4.1875 | 4 | usernum1 = int(input("Please enter a number: "))
usernum2 = int(input("Please enter another number: "))
usernum3 = int(input("Please enter another number: "))
if usernum1 > usernum2 and usernum1 > usernum3:
print(usernum1, " is the largest number")
elif usernum2 > usernum1 and usernum2 > usernum3:
pri... | true |
267335a2b28e9bc77b99f0b288f5bbb6f5b4d763 | KelseySlavin/CIS104 | /Assignments/Lab1/H1P1.py | 524 | 4.15625 | 4 | first_name = input("What is your first name?: ")
last_name = input("What is your last name?: ")
age = int(input("What is your age?: "))
confidence=int(input("How confident are you in programming between 1-100%? "))
dog_age= age * 7
print("hello, " + first_name+ " " + last_name + " , nice to meet you! You might be " + s... | true |
87e0c4f5b7335390da9274aedad193cbdb99d5ce | Ghelpagunsan/classes | /lists.py | 2,473 | 4.15625 | 4 |
class manipulate:
def __init__(self, cars):
self.cars = cars
def add(self):
self.cars.append("Ford")
self.cars.sort()
return self.cars
def remove(self):
print("Before removing" + str(self.cars))
self.cars.remove("Honda")
return str("After removing" + str(self.cars))
def update(self, car):
car.u... | true |
3cac0579ed84aaeeb6cd68e8dba63fbfa5caefee | brentirwin/automate-the-boring-stuff | /ch7/regexStrip.py | 1,091 | 4.6875 | 5 | #! python3
# regexStrip.py
'''
Write a function that takes a string and does the same thing as the strip()
string method. If no other arguments are passed other than the string to strip,
then whitespace characters will be removed from the beginning and end of the
string. Otherwise, the characters specified in the seco... | true |
c86a09cf6d893b85a67cf094b8fcf3e1b1e22e9b | realdavidalad/python_algorithm_test_cases | /longest_word.py | 325 | 4.375 | 4 | # this code returns longest word in a phrase or sentence
def get_longest_word(sentence):
longest_word=""
for word in str(sentence).split(" "): longest_word=word if len(word) > len(longest_word) else longest_word
return longest_word
print get_longest_word("This is the begenning of algorithm")
... | true |
fa0c8bc224b3c091276166cd426bd5153edb0b73 | Lynkdev/Python-Projects | /shippingcharges.py | 508 | 4.34375 | 4 | #Jeff Masterson
#Chapter 3 #13
shipweight = int(input('Enter the weight of the product '))
if shipweight <= 2:
print('Your product is 2 pounds or less. Your cost is $1.50')
elif shipweight >= 2.1 and shipweight <= 6:
print('Your product is between 2 and 6 pounds. Your cost is $3.00')
elif shipweig... | true |
bec5623135d5387e7bb16e3f63d93522a2a6f69a | sbuffkin/python-toys | /stretched_search.py | 1,172 | 4.15625 | 4 | import sys
import re
#[^b]*[b][^o]*[o][^a]*[a][^t]*[t](.?)
#([^char]*[char])*(.?) <- general regex
#structure of regex, each character is [^(char)]*[(char)]
#this captures everything that isn't the character until you hit the character then moves to the next state
#you can create a "string" of these in regex to see i... | true |
b4c8c18405a914afecee69a0d7f55f57bca6aed5 | helen5haha/pylee | /game/CountandSay.py | 1,012 | 4.15625 | 4 | '''
The count-and-say sequence is the sequence of integers beginning as follows:
1, 11, 21, 1211, 111221, ...
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
Given an integer n, generate the nth sequence.
Note: The sequence of integers will be represented... | true |
5cffad649c630930892fb1bbe38c7c8b6c177b60 | Keerthanavikraman/Luminarpythonworks | /oop/polymorphism/demo.py | 1,028 | 4.28125 | 4 | ### polymorphism ...many forms
##method overloading...same method name and different number of arguments
##method overriding...same method name and same number of arguments
###method overloading example
# class Operators:
# def num(self,n1,n2):
# self.n1=n1
# self.n2=n2
# print(self.n1+se... | true |
820abce4f9d2ca4f8435512d9ad69873abb106b3 | Vani-start/python-learning | /while.py | 553 | 4.28125 | 4 | #while executes until condition becomes true
x=1
while x <= 10 :
print(x)
x=x+1
else:
print("when condition failes")
#While true:
# do something
#else:
# Condifion failed
#While / While Else loops - a while loop executes as long as an user-specified condition is evaluated as True; the "else" clause is opti... | true |
495429537628e1b51b144775abb34d060034ac20 | Vani-start/python-learning | /convertdatatype.py | 980 | 4.125 | 4 | #Convet one datatype into otehr
int1=5
float1=5.5
int2=str(int1)
print(type(int1))
print(type(int2))
str1="78"
str2=int(str1)
print(type(str1))
print(type(str2))
str3=float(str1)
print(type(str3))
###Covert tuple to list
tup1=(1,2,3)
list1=list(tup1)
print(list1)
print(tup1)
set1=set(list1)
print(set1)
#... | true |
876792dac3431422495d8b71eb97b5faf662f201 | risabhmishra/parking_management_system | /Models/Vehicle.py | 931 | 4.34375 | 4 | class Vehicle:
"""
Vehicle Class acts as a parent base class for all types of vehicles, for instance in our case it is Car Class.
It contains a constructor method to set the registration number of the vehicle to registration_number attribute
of the class and a get method to return the value stored in re... | true |
27e8ec33ff0f380bf54428032445ab8905d3164f | detjensrobert/cs325-group-projects | /ga1/assignment1.py | 2,273 | 4.40625 | 4 | """
This file contains the template for Assignment1. You should fill the
function <majority_party_size>. The function, recieves two inputs:
(1) n: the number of delegates in the room, and
(2) same_party(int, int): a function that can be used to check if two members are
in the same party.
... | true |
58e59338d5d1fc79374d0ce438582c4d73185949 | Neethu-Mohan/python-project | /projects/create_dictionary.py | 1,091 | 4.15625 | 4 | """
This program receives two lists of different lengths. The first contains keys, and the second contains values.
And the program creates a dictionary from these keys and values. If the key did not have enough values, the dictionary will have the value None. If
Values that did not have enough keys will be ignored.
... | true |
488675687a2660c01e9fd7d707bdf212f94abb62 | NM20XX/Python-Data-Visualization | /Simple_line_graph_squares.py | 576 | 4.34375 | 4 | #Plotting a simple line graph
#Python 3.7.0
#matplotlib is a tool, mathematical plotting library
#pyplot is a module
#pip install matplotlib
import matplotlib.pyplot as plt
input_values = [1,2,3,4,5]
squares = [1,4,9,16,25]
plt.plot(input_values, squares, linewidth = 5) #linewidth controls the thickness of the lin... | true |
9ed2d0f9f15fde3e123ea8f30c2ffa714db1460a | tristaaa/learnpy | /getRemainingBalance.py | 819 | 4.125 | 4 | #! /usr/bin/env python3
# -*- coding:utf-8 -*-
balance = 42
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
def getMonthlyBalance(balance, annualInterestRate, monthlyPaymentRate):
'''
return: the remaining balance at the end of the month
'''
minimalPayment = balance * monthlyPaymentRate
monthl... | true |
6df041ded350202d4e74f98a104fd3470e21683d | tristaaa/learnpy | /bisectionSearch_3.py | 910 | 4.46875 | 4 | #! /usr/bin/env python3
# -*- coding:utf-8 -*-
# use bisection search to guess the secret number
# the user thinks of an integer [0,100).
# The computer makes guesses, and you give it input
# - is its guess too high or too low?
# Using bisection search, the computer will guess the user's secret number
low = 0
high ... | true |
537ddca25824fd995727cbb026fecefa5bdcaf8b | wkomari/Lab_Python_04 | /data_structures.py | 1,383 | 4.40625 | 4 | #lab 04
# example 1a
groceries = ['bananas','strawberries','apples','bread']
groceries.append('champagne')
print groceries
# example1b
groceries = ['bananas','strawberries','apples','bread']
groceries.append('champagne') # add champagne to the list of groceries
groceries.remove('bread') # remove bread from the lis... | true |
5f168aeaf97ebb2100fafcbaef59928522f86d70 | sha-naya/Programming_exercises | /reverse_string_or_sentence.py | 484 | 4.15625 | 4 | test_string_sentence = 'how the **** do you reverse a string, innit?'
def string_reverser(string):
reversed_string = string[::-1]
return reversed_string
def sentence_reverser(sentence):
words_list = sentence.split()
reversed_list = words_list[::-1]
reversed_sentence = " ".join(reversed_list)
... | true |
18fae6895c6be30f0a3a87531a2fafe965a3c89f | pkdoshinji/miscellaneous-algorithms | /baser.py | 1,873 | 4.15625 | 4 | #!/usr/bin/env python3
'''
A module for converting a (positive) decimal number to its (base N) equivalent, where
extensions to bases eleven and greater are represented with the capital letters
of the Roman alphabet in the obvious way, i.e., A=10, B=11, C=12, etc. (Compare
the usual notation for the hexadecimal numbers.... | true |
358c68067412029677c59023d1f4b35af58c54ff | yuniktmr/String-Manipulation-Basic | /stringOperations_ytamraka.py | 1,473 | 4.34375 | 4 | #CSCI 450 Section 1
#Student Name: Yunik Tamrakar
#Student ID: 10602304
#Homework #7
#Program that uses oython function to perform word count, frequency and string replacement operation
#In keeping with the Honor Code of UM, I have neither given nor received assistance
#from anyone other than the instructor.
#--... | true |
bbcdeafd4fdc92f756f93a1a4f990418d295c643 | ijoshi90/Python | /Python/variables_examples.py | 602 | 4.375 | 4 | """
Author : Akshay Joshi
GitHub : https://github.com/ijoshi90
Created on 26-Sep-19 at 19:24
"""
class Car:
# Class variable
wheels = 2
def __init__(self):
# Instance Variable
self.mileage = 20
self.company = "BMW"
car1 = Car()
car2 = Car()
print ("Wheels : {}".format(Car.wheels)... | true |
e41d966e65b740a9e95368d7e5b9286fe587f2cb | donwb/whirlwind-python | /Generators.py | 537 | 4.28125 | 4 | print("List")
# List - collection of values
L = [n ** 2 for n in range(12)]
for val in L:
print(val, end=' ')
print("\n")
print("Generator...")
# Generator - recipie for creating a list of values
G = (n ** 2 for n in range(12))
#generator created here, not up there...
for val in G:
print(val, end=' ')
# Genera... | true |
d3dd23e8f5e164ca4378e7817f983fca0bf89e1b | DylanGuidry/PythonFunctions | /dictionaries.py | 1,098 | 4.375 | 4 | #Dictionaries are defined with {}
friend = {
#They have keys/ values pairs
"name": "Alan Turing",
"Cell": "1234567",
"birthday": "Sep. 5th"
}
#Empty dictionary
nothing = {}
#Values can be anything
suoerhero = {
"name": "Tony Stark",
"Number": 40,
"Avenger": True,
"Gear": [
"f... | true |
109aebf88bfac4cd1e7e097b085d3a3f909923fa | helinamesfin/guessing-game | /random game.py | 454 | 4.15625 | 4 | import random
number = random.randrange(1,11)
str_guess= input("What number do you think it is?")
guess= int(str_guess)
while guess != number:
if guess > number:
print("Not quite. Guess lower.")
elif guess < number:
print("Not quite. Guess higher.")
str_guess= input("W... | true |
11c57367b1f26d98d8ccab7ab1fc44fedfe7ca42 | IceMints/Python | /blackrock_ctf_07/Fishing.py | 1,503 | 4.25 | 4 | # Python3 Program to find
# best buying and selling days
# This function finds the buy sell
# schedule for maximum profit
def max_profit(price, fee):
profit = 0
n = len(price)
# Prices must be given for at least two days
if (n == 1):
return
# Traverse through given price array
... | true |
a1514c507909bd3d00953f7a8c7dd09223779ead | VEGANATO/Organizing-Sales-Data-Code-Academy | /script.py | 651 | 4.53125 | 5 | # Len's Slice: I work at Len’s Slice, a new pizza joint in the neighborhood. I am going to use my knowledge of Python lists to organize some of the sales data.
print("Sales Data")
# To keep track of the kinds of pizzas sold, a list is created called toppings that holds different toppings.
toppings = ["pepperoni", "pine... | true |
7df64998ce5965ba3fabcbd54cedc6751ca413c8 | gustavovalverde/intro-programming-nano | /Python/Work Session 5/Loop 4.py | 2,343 | 4.46875 | 4 | # We now would like to summarize this data and make it more visually
# appealing.
# We want to go through count_list and print a table that shows
# the number and its corresponding count.
# The output should look like this neatly formatted table:
"""
number | occurrence
0 | 1
1 | 2
2 | 3
3 | 2
... | true |
a9bed93ff1f778a466167b06cbc8afa902dabf9e | gustavovalverde/intro-programming-nano | /Python/Problem Solving/Calc_age_on_date.py | 2,173 | 4.21875 | 4 | # Given your birthday and the current date, calculate your age
# in days. Compensate for leap days. Assume that the birthday
# and current date are correct dates (and no time travel).
# Simply put, if you were born 1 Jan 2012 and todays date is
# 2 Jan 2012 you are 1 day old.
daysOfMonths = [31, 28, 31, 30, 31, 30, 31... | true |
1018f2da0c71c59aa9491bf5ab74ab734accb09d | adirickyk/course-python | /try_catch.py | 302 | 4.3125 | 4 | #create new exception
try:
Value = int(input("Type a number between 1 and 10 : "))
except ValueError:
print("You must type a number between 1 and 10")
else:
if(Value > 0) and (Value <= 10):
print("You typed value : ", Value)
else:
print("The value type is incorrect !")
| true |
e8368e5d17e8682b1f8d59ab9466995584747627 | castacu0/codewars_db | /15_7kyu_Jaden Casing Strings.py | 1,069 | 4.21875 | 4 | from string import capwords
"""
Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for some of his philosophy that he delivers via Twitter. When writing on Twitter, he is known for almost always capitalizing every word. For simplicity, you... | true |
9940f02410122ddc6d0a9394479576fa0fb1a4fb | marizmelo/udacity | /CS262/lesson3/mapdef.py | 267 | 4.125 | 4 | def mysquare(x): return x * x
print map( mysquare, [1, 2, 3, 4, 5])
print map( lambda(x): x * x, [1, 2, 3, 4, 5]) # this use of lambda is sometimes called anonymous function
print [len(x) for x in ["hello", "my", "friends"]]
print [x * x for x in [1, 2, 3, 4, 5]] | true |
1451fa9c04e5ce8636d023001c663fb6a988b0bf | wajishagul/wajiba | /Task4.py | 884 | 4.375 | 4 | print("*****Task 4- Variables and Datatype*****")
print("Excercise")
print("1. Create three variables (a,b,c) to same value of any integer & do the following")
a=b=c=100
print("i.Divide a by 10")
print(a,"/",10,"=",a/10)
print("ii.Multiply b by 50")
print(b,"*",50,"=",b*50)
print("iii.Add c by 60")
print(c,"+",50,"=",b... | true |
1b139816100f6157c1492c44eb552c096fb8b32f | verma-rahul/CodingPractice | /Medium/InOrderTraversalWithoutRecursion.py | 2,064 | 4.25 | 4 | # Q : Given a Tree, print it in order without Traversal
# Example: 1
# / \
# 2 3 => 4 2 5 1 3
# / \
# 4 5
import sys
import random
# To set static Seed
random.seed(1)
class Node():
"""
Node Struct
"""
def __init__(self,val=None):
self.val=val
... | true |
81eba7d41e0f8962458519751b02c21dc52c88a5 | Sreenidhi220/IOT_Class | /CE8OOPndPOP.py | 1,466 | 4.46875 | 4 | #Aum Amriteshwaryai Namah
#Class Exercise no. 8: OOP and POP illustration
# Suppose we want to model a bank account with support for 'deposit' and 'withdraw' operations.
# One way to do that is by Procedural Programming
# balance = 0
# def deposit(amount):
# global balance
# balance += amount
# ... | true |
c79f3df4eb01631e73363cd6e5e6546e15380b30 | edran/ProjectsForTeaching | /Classic Algorithms/sorting.py | 2,073 | 4.28125 | 4 | """
Implement two types of sorting algorithms: Merge sort
and bubble sort.
"""
def mergeMS(left, right):
"""
Merge two sorted lists in a sorted list
"""
llen = len(left)
rlen = len(right)
sumlist = []
while left != [] and right != []:
lstack = left[0]
while right... | true |
4b41489f518c4cbca1923440c3416cdfef345f88 | edran/ProjectsForTeaching | /Numbers/factprime.py | 657 | 4.28125 | 4 | """
Have the user enter a number and find all Prime Factors (if there
are any) and display them.
"""
import math
import sys
def isPrime(n):
for i in range(2,int(math.sqrt(n)) + 1): # premature optimization? AH!
if n % i == 0:
return False
return True
def primeFacts(n):
l = []
fo... | true |
1ab87bc5c2863c90dea96185241b0869f2259f30 | sonusbeat/intro_algorithms | /Recursion/group_exercise2.py | 489 | 4.375 | 4 | """ Group Exercise Triple steps """
def triple_steps(n):
"""
A child is running up a staircase with n steps and can hop
either 1 step, 2 steps, or 3 steps at a time.
Count how many possible ways the child can run up the stairs.
:param n: the number of stairs
:return: The number of possible way... | true |
ec45e6109ddd2f2f3b9984404f015b828f0ca4f1 | sonusbeat/intro_algorithms | /SearchingAlgorithms/2.binary_search.py | 1,037 | 4.28125 | 4 | """
Binary Search
- how you look up a word in a dictionary or a contact in phone book.
* Items have to be sorted!
"""
alist = [
"Australia", "Brazil", "Canada", "Denmark",
"Ecuador", "France", "Germany", "Honduras",
"Iran", "Japan", "Korea", "Latvia",
"Mexico", "Netherlands", "Oman", "Philippines",
... | true |
4bb0736d12da8757a76839f242d902fb08afc461 | vamsikrishna6668/python | /class2.py | 559 | 4.3125 | 4 | # w.a.p on class example by static method and static variables and take a local variable also print without a reference variable?
class student:
std_idno=101
std_name="ismail"
@staticmethod
def assign(b,c):
a=1000
print("The Local variable value:",a)
print("The static ... | true |
3a5908b10e1eb651085ac4dee75e344b8bb9cc83 | singzinc/PythonTut | /basic/tut2_string.py | 785 | 4.3125 | 4 |
# ====================== concat example 1 ===================
firstname = 'sing'
lastname = 'zinc '
print(firstname + ' ' + lastname)
print(firstname * 3)
print('sing' in firstname)
# ====================== concat example 2 ===================
foo = "seven"
print("She lives with " + foo + " small men")
# ======... | true |
590b4ee6898e35551b8059ef9256d307a8bcce59 | markvakarchuk/ISAT-252 | /Python/Rock, Paper, Scissors - Linear.py | 1,891 | 4.1875 | 4 | import time
import random
# defining all global variables
win_streak = 0 # counts how many times the user won
play_again = True # flag for if another round should be played
game_states = ["rock", "paper", "scissors"]
#printing the welcome message
print("Welcome to Rock, Paper, Scissors, lets play!")
time.slee... | true |
c3f3e836042df5e06d1f19b26fda1197726d2030 | mikofski/poly2D | /polyDer2D.py | 2,204 | 4.25 | 4 | import numpy as np
def polyDer2D(p, x, y, n, m):
"""
polyDer2D(p, x, y, n, m)
Evaluate derivatives of a 2-D polynomial using Horner's method.
Evaluates the derivatives of 2-D polynomial `p` at the points
specified by `x` and `y`, which must be the same dimensions. The
outputs `(fx, fy)` will ... | true |
4f6c341cb5903f526d9780af9d1aa2f8b2b87e35 | JakeBednard/CodeInterviewPractice | /6-1B_ManualIntToString.py | 444 | 4.125 | 4 | def int_to_string(value):
"""
Manually Convert String to Int
Assume only numeric chars in string
"""
is_negative = False
if value < 0:
is_negative = True
value *= -1
output = []
while value:
value, i = divmod(value, 10)
output.append((chr(i + ord('0'))))... | true |
7d26e6913a4b0024fa1082e5f3ea7c9ff0cbc50b | Azab007/Data-Structures-and-Algorithms-Specialization | /algorithms on strings/week2/suffix_array/suffix_array.py | 572 | 4.21875 | 4 | # python3
import sys
from collections import defaultdict
def build_suffix_array(text):
"""
Build suffix array of the string text and
return a list result of the same length as the text
such that the value result[i] is the index (0-based)
in text where the i-th lexicographically smallest
suffix of text sta... | true |
01aaf5aec0ca74fdfec8f95d7137979737c313a4 | JMH201810/Labs | /Python/p01320g.py | 1,342 | 4.5 | 4 | # g. Album:
# Write a function called make_album() that builds a dictionary describing
# a music album. The function should take in an artist name and an album
# title, and it should return a dictionary containing these two pieces of
# information. Use the function to make three dictionaries representing
# differe... | true |
64a30bf626d62b29ae78c9ac9435dc1ca5c929f3 | JMH201810/Labs | /Python/p01320L.py | 568 | 4.15625 | 4 | # l. Sandwiches:
# Write a function that accepts a list of items a person wants on a sandwich.
# The function should have one parameter that collects as many items as the
# function call provides, and it should print a summary of the sandwich that
# is being ordered.
# Call the function three times, using a di... | true |
ae64e924773c4243da27404de13e74ce2e973b56 | JMH201810/Labs | /Python/p01310j.py | 631 | 4.59375 | 5 | # Favorite Places:
# Make a dictionary called favorite_places.
# Think of three names to use as keys in the dictionary, and store one to
# three favorite places for each person.
# Loop through the dictionary, and print each person's name and their
# favorite places.
favorite_places = {'Alice':['Benton Harbor'... | true |
d6c1fa3d43547d59fa10a9e6d1e51e169dac8a18 | JMH201810/Labs | /Python/p01210i.py | 924 | 4.875 | 5 | # Pizzas: Think of at least three kinds of your favorite pizza. Store these pizza
# names in a list, and then use a for loop to print the name of each pizza.
pizzaTypes = ['Round', 'Edible', 'Vegetarian']
print("Pizza types:")
for type in pizzaTypes:
print(type)
# i. Modify your for loop to print a senten... | true |
e86600435612f88fbf67e3e805f0e21e6f0f51f8 | 23-Dharshini/priyadharshini | /count words.py | 253 | 4.3125 | 4 | string = input("enter the string:")
count = 0
words = 1
for i in string:
count = count+1
if (i==" "):
words = words+1
print("Number of character in the string:",count)
print("Number of words in the string:",words) | true |
1622d36817330cc707a1a4e4c4e52810065aa222 | Whatsupyuan/python_ws | /4.第四章-列表操作/iterator_044_test.py | 1,306 | 4.15625 | 4 | # 4-10
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print("The first three items in the list are" )
print(players[:3])
print()
# python3 四舍五入 问题
# 官方文档写了,round(number[, ndigits]) values are rounded to the closest multiple of 10 to the power minus ndigits;
# if two multiples are equally close, round... | true |
3d999ca8f12348a3cb229be5af0f9cdba4ccc0b2 | ArvindAROO/algorithms | /sleepsort.py | 1,052 | 4.125 | 4 | """
Sleepsort is probably the wierdest of all sorting functions
with time-complexity of O(max(input)+n) which is
quite different from almost all other sorting techniques.
If the number of inputs is small then the complexity
can be approximated to be O(max(input)) which is a constant
If the number of inputs is l... | true |
911d4753a01ab601346e3bc2f3b483a61d21c7ae | bspindler/python_sandbox | /classes.py | 1,180 | 4.3125 | 4 | # A class is like a blueprint for creating objects. An object has properties and methods (functions)
# associated with it. Almost everything in Python is an object
# Create Class
class User:
# constructor
def __init__(self, name, email, age):
self.name = name
self.email = email
self... | true |
c246c6a153b6bc176ed0e279a60d32f1b2100711 | ntkawasaki/complete-python-masterclass | /7: Lists, Ranges, and Tuples/tuples.py | 1,799 | 4.5625 | 5 | # tuples are immutable, can't be altered or appended to
# parenthesis are not necessary, only to resolve ambiguity
# returned in brackets
# t = "a", "b", "c"
# x = ("a", "b", "c") # using brackets is best practice
# print(t)
# print(x)
#
# print("a", "b", "c")
# print(("a", "b", "c")) # to print a tuple explicitly i... | true |
acf3384d648aa16c781ac82c61b8e3c275538bae | ntkawasaki/complete-python-masterclass | /10: Input and Output/shelve_example.py | 1,638 | 4.25 | 4 | # like a dictionary stored in a file, uses keys and values
# persistent dictionary
# values pickled when saved, don't use untrusted sources
import shelve
# open a shelf like its a file
# with shelve.open("shelf_test") as fruit: # makes a shelf_test.db file
# fruit["orange"] = "a sweet, orange fruit"
# fruit[... | true |
fcd60015393e712316586a32f75462eff2f4543f | ntkawasaki/complete-python-masterclass | /11: Modules and Functions/Functions/more_functions.py | 2,460 | 4.125 | 4 | # more functions!
# function can use variables from main program
# main program cannot use local variables in a function
import math
try:
import tkinter
except ImportError: # python 2
import Tkinter as tkinter
def parabola(page, size):
"""
Returns parabola or y = x^2 from param x.
:param page:
... | true |
4ccdd7851dc2177d6a35e72cb57069685d75f72c | echo001/Python | /python_for_everybody/exer9.1.py | 706 | 4.21875 | 4 | #Exercise 1 Write a program that reads the words in words.txt and stores them as
# keys in a dictionary. It doesn’t matter what the values are. Then you
# can use the in operator as a fast way to check whether a string is
# in the dictionary.
fname = input('Enter a file na... | true |
19e74e3bc318021556ceec645597199996cfba98 | echo001/Python | /python_for_everybody/exer10.11.3.py | 1,251 | 4.40625 | 4 | #Exercise 3 Write a program that reads a file and prints the letters in
# decreasing order of frequency. Your program should convert all the
# input to lower case and only count the letters a-z. Your program
# should not count spaces, digits, punctuation, or anything other ... | true |
3168d9379b4ff8064b60ed5e6db65d504c91f5a0 | marcluettecke/programming_challenges | /python_scripts/rot13_translation.py | 482 | 4.125 | 4 | """
Function to shift every letter by 13 positions in the alphabet. Clever use of maketrans and translate.
"""
trans = str.maketrans('ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz',
'NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm')
def rot13(message):
"""
Translation by rot... | true |
ae038beb027640e3af191d24c6c3abbb172e398e | mihaidobri/DataCamp | /SupervisedLearningWithScikitLearn/Classification/02_TrainTestSplit_FitPredictAccuracy.py | 777 | 4.125 | 4 | '''
After creating arrays for the features and target variable, you will split them into training and test sets,
fit a k-NN classifier to the training data, and then compute its accuracy using the .score() method.
'''
# Import necessary modules
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_sele... | true |
92d2b840f03db425aaaedf22ad57d0b291bb79e6 | devmadhuu/Python | /assignment_01/odd_in_a_range.py | 505 | 4.375 | 4 | ## Program to print Odd number within a given range.
start = input ('Enter start number of range:')
end = input ('Enter end number of range:')
if start.isdigit() and end.isdigit():
start = int(start)
end = int(end)
if end > start:
for num in range(start, end):
if num % 2 != 0:
... | true |
66c8afbcdd793b3817993abfb904b4ec0111f666 | devmadhuu/Python | /assignment_01/factorial.py | 410 | 4.4375 | 4 | ## Python program to find the factorial of a number.
userinput = input ('Enter number to find the factorial:')
if userinput.isdigit() or userinput.find('-') >= 0:
userinput = int(userinput)
factorial = 1
for num in range (1, userinput + 1):
factorial*=num
print('Factorial of {a} is {factorial}'.... | true |
6d030f79eb3df2a3572eaadb0757401d3a330326 | amark02/ICS4U-Classwork | /Quiz2/evaluation.py | 2,636 | 4.25 | 4 | from typing import Dict, List
def average(a: float, b: float, c:float) -> float:
"""Returns the average of 3 numbers.
Args:
a: A decimal number
b: A decimal number
c: A decimal number
Returns:
The average of the 3 numbers as a float
"""
return (a + b + c)/3
def c... | true |
5b632636066e777092b375219a7a6cd571619157 | amark02/ICS4U-Classwork | /Classes/01_store_data.py | 271 | 4.1875 | 4 |
class Person:
pass
p = Person()
p.name = "Jeff"
p.eye_color = "Blue"
p2 = Person()
print(p)
print(p.name)
print(p.eye_color)
"""
print(p2.name)
gives an error since the object has no attribute of name
since you gave the other person an attribute on the fly
""" | true |
23ee2c8360e32e0334a31da848043cf6187cd636 | cosinekitty/astronomy | /demo/python/gravity.py | 1,137 | 4.125 | 4 | #!/usr/bin/env python3
import sys
from astronomy import ObserverGravity
UsageText = r'''
USAGE:
gravity.py latitude height
Calculates the gravitational acceleration experienced
by an observer on the surface of the Earth at the specified
latitude (degrees north of the equator) and height
(met... | true |
e79076cd45b6280c2046283d9a349620af0f8d70 | joshinihal/dsa | /trees/tree_implementation_using_oop.py | 1,428 | 4.21875 | 4 | # Nodes and References Implementation of a Tree
# defining a class:
# python3 : class BinaryTree()
# older than python 3: class BinaryTree(object)
class BinaryTree():
def __init__(self,rootObj):
# root value is also called key
self.key = rootObj
self.leftChild = None
self.righ... | true |
74725fc2d2c7d06cec7bc468aa078f59e6aa21e7 | AGriggs1/Labwork-Fall-2017 | /hello.py | 858 | 4.125 | 4 | # Intro to Programming
# Author: Anthony Griggs
# Date: 9/1/17
##################################
# dprint
# enables or disables debug printing
# Simple function used by many, many programmers, I take no credit for it WHATSOEVER
# to enable, simply set bDebugStatements to true!
##NOTE TO SELF: in Python, first letter ... | true |
73a9544105ca7eae0d7997aa2e0a4b74bf8723b7 | SanamKhatri/school | /teacher_delete.py | 1,234 | 4.1875 | 4 | import teacher_database
from Teacher import Teacher
def delete_teacher():
delete_menu="""
1.By Name
2.By Addeess
3.By Subject
"""
print(delete_menu)
delete_choice=int(input("Enter the delete choice"))
if delete_choice==1:
delete_name=input("Enter the name of the... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.