blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
ec327f48426bedaf3bad862a9a0ebe5e6afb366b | sleibrock/form-creator | /fcl/RectData.py | 1,483 | 4.125 | 4 | #!/usr/bin/python
#-*- coding: utf-8 -*-
__author__ = 'Steven'
class Rect(object):
"""
Class to store rectangle information
Stores (x,y,w,h), the type of Rect, the ID of the rect, and now the value of the rect
"""
def __init__(self, x, y, w, h, idtag="", typerect="text", value=""):
self.x,... | true |
7ddbf394320fe3b4babc65bba39858c47eaa0482 | Luquicas5852/Small-projects | /easy/PascalTriangle.py | 392 | 4.15625 | 4 | """
This will generate Pascal's triangle.
"""
#Define a factorial using recursion
def f(n):
if n == 0:
return 1
else:
return n*f(n - 1)
rows = int(input('Enter with the amount of rows that you want to generate: '))
row = ""
for i in range(rows):
for j in range(i + 1):
num = f(i)/(f... | true |
3dc184b82e04ea5d263e6668832e574e3543b985 | dionboonstra/RecommendationsResit | /resitRPI.py | 2,627 | 4.4375 | 4 | # import csv in order to be able to read/import csv files into directory
import csv
#Load data using the reader function in python, therefrom create a list including all the information present in the userreviews csv file
file = csv.reader(open("/Users/dionboonstra/Downloads/userReviews all three parts.csv", encoding=... | true |
5cf2041655940707401f2869a256f14be25d00bc | 17e23052/Lesson-10 | /main.py | 1,463 | 4.34375 | 4 | price = 0
print("Welcome to the Pizza cost calculator!")
print("Please enter any of the options shown to you with correct spelling,")
print("otherwise this program will not work properly.")
print("Would you like a thin or thick crust?")
crust = input().lower()
if crust == "thin":
price = price + 8
elif crust == "thic... | true |
ee090bb4302155b486dbfe50f7f500206cf68e30 | shubhangi2803/More-questions-of-python | /Data Types - List/Q 7,8,9.py | 726 | 4.3125 | 4 | # 7. Write a Python program to remove duplicates from a list.
# 8. Write a Python program to check a list is empty or not.
# 9. Write a Python program to clone or copy a list.
li_one=list(map(int,input("Enter list elements separated by lists : ").split()))
li_two=[]
print("List 1 : ")
print(li_one)
print("List 2 : ")
... | true |
044e09d766cc7a3eac7f85577d937ddc3ac5205a | shubhangi2803/More-questions-of-python | /Lambda functions/Q 6.py | 304 | 4.21875 | 4 | # 6. Write a Python program to square and cube every number in a given list of integers using Lambda.
li=list(map(int,input("Enter list of numbers : ").split()))
p=list(map(lambda x: x*x, li))
q=list(map(lambda y: y*y*y, li))
print("List of squares : {}".format(p))
print("List of cubes : {}".format(q))
| true |
9f9a285d1187ac3b7ff6e85c4b6aaec22c4a21ca | vray22/Coursework | /cs153/Assignment2.py | 1,183 | 4.3125 | 4 | #Name: Victor Lozoya
#Date:2/9/17
#Assignment2
#create string to avoid typing it twice
str = "Twinkle, twinkle, little star,\n"
#use print statements for each line to avoid confusion
print(str)
print("\t How I wonder what you are! \n")
print("\t\t Up above the world so high, \n")
print("\t\t Like a diamond... | true |
80b8af95d4df47a9449331f58b3244ef031c6c25 | njberejan/TIY-Projects | /multiples_exercise.py | 577 | 4.21875 | 4 | list_of_numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def multiple_of_3_or_5(list_of_numbers):
multiples_of_3_or_5_list = []
total = 0
for number in list_of_numbers:
if number % 3 == 0:
multiples_of_3_or_5_list.append(number)
elif number % 5 == 0:
multiples_of_3_or_5_li... | true |
5674214283bf08513493920731e534bf1ee84316 | VolatileMatter/GHP_Files | /sorts.py | 774 | 4.125 | 4 | import random
def in_order(a_list):
last_item = None
for item in a_list:
if not last_item:
last_item = item
if item < last_item:
return False
last_item = item
return True
#Insertion Sort
def insertionSort(alist):
for index in range(1,len(alist)):
currentvalue = alist[index]
position = index
whi... | true |
4758c61d8a45c42db805d1ce5dcf6cc7c56fbde4 | goosebones/spellotron | /string_modify.py | 1,556 | 4.15625 | 4 | """
author: Gunther Kroth gdk6217@rit.edu
file: string_modify.py
assignment: CS1 Project
purpose: minipulate words that are being analyzed
"""
def punctuation_strip(word):
""" strips punctuation from the front and back of a word
returns a tuple of word, front, back
:param word: word to strip pun... | true |
59407725886e12ac88af7d5a5be9b765f40890b5 | diksha12p/DSA_Practice_Problems | /Palindrome Number.py | 1,014 | 4.125 | 4 | """
LC 9. Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
Example 1:
Input: 121
Output: true
Example 2:
Input: -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is... | true |
1ff85b27640580d2df9b5bad1a023d37d0a507e8 | diksha12p/DSA_Practice_Problems | /Letter Combinations of a Phone Number.py | 1,068 | 4.1875 | 4 | """
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could
represent.
A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any
letters.
Example:
Input: "23"
Output: ["ad", "ae", "af", "bd", "be", "bf... | true |
678696e563fd889705b32dfdffc578f5b575415c | diksha12p/DSA_Practice_Problems | /Binary Tree Right Side View.py | 1,666 | 4.28125 | 4 | """
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see
ordered from top to bottom.
Example:
Input: [1,2,3,null,5,null,4]
Output: [1, 3, 4]
Explanation:
1 <---
/ \
2 3 <---
\ \
5 4 <---
"""
from typing import... | true |
9cd96360b3da0bb90a3f98d9486cb9137714b0a3 | lcongdon/tiny_python_projects | /07_gashlycrumb/addressbook.py | 1,069 | 4.125 | 4 | #!/usr/bin/env python3
"""
Author : Lee A. Congdon <lee@lcongdon.com>
Date : 2021-07-14
Purpose: Tiny Python Exercises: addressbook
"""
import argparse
import json
def get_args():
"""Parse arguments"""
parser = argparse.ArgumentParser(
description="Print line(s) from file specified by parameters",... | true |
53f80b39a9af33f5d1cde67c3ad9848e534dca74 | joshuasewhee/practice_python | /OddOrEven.py | 460 | 4.21875 | 4 | # Joshua Sew-Hee
# 6/14/18
# Odd Or Even
number = int(input("Enter a number to check: "))
check = int(input("Enter a number to divide: "))
if (number % 2 == 0):
print("%d is even." %number)
elif (number % 2 != 0):
print("%d is odd." %number)
if (number % 4 == 0):
print("%d is a multiple of 4." % number)
... | true |
e1b80889e822b256ac44f915be4d3d3d414bd042 | Neanra/EPAM-Python-hometasks | /xhlhdehh-python_online_task_4_exercise_1/task_4_ex_1.py | 486 | 4.1875 | 4 | """04 Task 1.1
Implement a function which receives a string and replaces all " symbols with ' and vise versa. The
function should return modified string.
Usage of any replacing string functions is prohibited.
"""
def swap_quotes(string: str) -> str:
str_list = []
for char in string:
if char == "'":
... | true |
98418b93761efe90361044257d2ccb8821814a84 | smohapatra1/scripting | /python/practice/start_again/2023/08122023/daily_tempratures.py | 1,293 | 4.28125 | 4 | # 739. Daily Temperatures
# Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.
... | true |
b6e7a07afee721eaf42e989702f4e783ec895e52 | smohapatra1/scripting | /python/practice/start_again/2021/04242021/Day9_1_Grading_Program.py | 1,547 | 4.46875 | 4 | #Grading Program
#Instructions
#You have access to a database of student_scores in the format of a dictionary. The keys in student_scores are the names of the students and the values are their exam scores.
#Write a program that converts their scores to grades. By the end of your program, you should have a new dictiona... | true |
bcff2a824797cb88f04d621f495d065e21061c2b | smohapatra1/scripting | /python/practice/start_again/2021/01312021/Arithmetic_Progression_Series.py | 1,113 | 4.1875 | 4 | #Python Program to find Sum of Arithmetic Progression Series
#Write a Python Program to find the Sum of Arithmetic Progression Series (A.P. Series) with a practical example.
#Arithmetic Series is a sequence of terms in which the next item obtained by adding a common difference to the previous item.
# Or A.P. series is... | true |
7e01c666f5165874a1c7a19b71006f19781ef8bd | smohapatra1/scripting | /python/practice/start_again/2021/04192021/Day5.4-Fizbuzz_Exercise.py | 893 | 4.53125 | 5 | # Fizzbuzz exercise
#FizzBuzz
#Instructions
#You are going to write a program that automatically prints the solution to the FizzBuzz game.
#Your program should print each number from 1 to 100 in turn.
#When the number is divisible by 3 then instead of printing the number it should print "Fizz".
#`When the number is ... | true |
557e3ada7a2d31cacb69c92e24adcd9cabc203b8 | smohapatra1/scripting | /python/practice/start_again/2021/02032021/sum_of_odd_even.py | 533 | 4.375 | 4 | #Python Program to Calculate Sum of Odd Numbers
#Write a Python Program to Calculate Sum of Odd Numbers from 1 to N using While Loop, and For Loop with an example.
# Sum of even numbers as well
def main():
n = int(input("Enter the N numbers you want : "))
even = 0
odd = 0
for i in range (1, n+1):
... | true |
afaab750d64902af88baf0e0f775bbf9e7e8e3b0 | smohapatra1/scripting | /python/practice/start_again/2023/07202023/topk_frequent_elements.py | 986 | 4.1875 | 4 | # 347. Top K Frequent Elements
# Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.
#Ref https://interviewing.io/questions/top-k-frequent-elements
# Example 1:
# Input: nums = [1,1,1,2,2,3], k = 2
# Output: [1,2]
# Approach :-
# Accept the... | true |
70102efaa0cb459776deb46145e3ea97dd87d796 | smohapatra1/scripting | /python/practice/start_again/2021/04252021/Day9.2_Calculator.py | 926 | 4.25 | 4 | #Design a calculator
def add (n1, n2):
return n1 + n2
def sub (n1, n2):
return n1 - n2
def mul (n1, n2):
return n1 * n2
def div (n1, n2):
return n1 / n2
operations = {
"+" : add,
"-" : sub,
"*" : mul,
"/" : div,
}
def calculator():
num1=float(input("Enter the first number : "))
... | true |
2a223dffa17d46d91db72e500c1a87f93f3a9f04 | smohapatra1/scripting | /python/practice/start_again/2023/07182023/valid_anagram.py | 1,311 | 4.3125 | 4 | # #Given two strings s and t, return true if t is an anagram of s, and false otherwise.
# An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
# Example 1:
# Input: s = "anagram", t = "nagaram"
# Output: true
# Example ... | true |
cd9f44ea5f2845dcbd9d2483658a21b34ec17773 | smohapatra1/scripting | /python/practice/start_again/2023/07192023/two_sum.py | 1,032 | 4.21875 | 4 | #Two Sum :-
# Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
# You may assume that each input would have exactly one solution, and you may not use the same element twice.
# You can return the answer in any order.
# Steps
# Define the arr... | true |
68ce09d3a1a0f6ab6630400048a6298dab9f0e3f | smohapatra1/scripting | /python/practice/start_again/2022/01232022/Odd_even.py | 253 | 4.375 | 4 | #Ask an user to enter a number. Find out if this number is Odd or Even
def odd_even(n):
if n > 0:
if n %2 == 0 :
print (f'{n} is even')
else:
print (f'{n} is odd')
odd_even (int(input("Enter the number : "))) | true |
6a5481244b5254a8fb1b1a2c529021559e5b7e42 | smohapatra1/scripting | /python/practice/start_again/2020/11232020/return_unique_way2.py | 364 | 4.15625 | 4 | #Write a Python function that takes a list and returns a new list with unique elements of the first list.
#Sample List : [1,1,1,1,2,2,3,3,3,3,4,5]
#Unique List : [1, 2, 3, 4, 5]
def uniq(x):
uNumber = []
for nums in x:
#print (nums)
if nums not in uNumber:
uNumber.append(nums)
pri... | true |
276855e33856f3c06ffb785c92368e084a2cbcdd | smohapatra1/scripting | /python/practice/day28/while_loop_factorial.py | 464 | 4.3125 | 4 | #/usr/bin/python
#Write a program using while loop, which asks the user to type a positive integer, n, and then prints the factorial of n. A factorial is defined as the product of all the numbers from 1 to n (1 and n inclusive). For example factorial of 4 is equal to 24. (because 1*2*3*4=24)
a = int(input("Enter a numb... | true |
24e90f48c6eb41aef70079751e3637e3bfae7a9a | smohapatra1/scripting | /python/practice/day54/inverted_pyramid.py | 243 | 4.375 | 4 | #Example 3: Program to print inverted half pyramid using an asterisk (star)
def triag(x):
for i in range(x,0,-1):
for j in range(1, i - 1):
print("*", end=" ")
print("\r")
triag(int(input("Enter a value : ")))
| true |
7908fb2010308508274fe772a706bdb847b8c547 | smohapatra1/scripting | /python/practice/day57/merge_k_sorted_list.py | 625 | 4.15625 | 4 | '''
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
Example:
Input:
[
1->4->5,
1->3->4,
2->6
]
Output: 1->1->2->3->4->4->5->6
'''
class Solution:
def k_list(self, lists):
res =[]
for i in range(len(k_list)) :
item=lists[i]
... | true |
a8e64901300abcb4c2605b7631d0e6580bc44723 | smohapatra1/scripting | /python/practice/start_again/2020/10212020/print_format.py | 558 | 4.1875 | 4 | #Use print Format
string="Hello"
print('Hello {} {}' .format('Samar' ,' , How are you?'))
# Another format of replacing indexes/formats
print('Hello {1} {0}' .format('Samar' ,' , How are you?'))
#Using key value pairs
print ('Hello {a} {b}'.format(a='Samar,', b='How are you?'))
result = 100/777
print ('Your result ... | true |
6a2dd722f1b305bbf17ac97b270637cb14187954 | smohapatra1/scripting | /python/practice/start_again/2020/12022020/bank_withdrawal.py | 1,221 | 4.1875 | 4 | #For this challenge, create a bank account class that has two attributes:
#owner
#balance
#and two methods:
#deposit
#withdraw
#As an added requirement, withdrawals may not exceed the available balance.
class bank():
def __init__(self,owner,balance):
self.owner = owner
self.balance = balance
... | true |
e7ac2a2569c2a6f6fedbcf050a7c47324aab22f0 | smohapatra1/scripting | /python/practice/start_again/2021/05192021/Day19.3_Turtle_Race.py | 1,068 | 4.125 | 4 | from turtle import Turtle, Screen
import random
screen = Screen()
screen.setup(width=500, height=400)
user_bet= screen.textinput(title="Make your bet", prompt="While turtle will win")
color = ["red", "orange", "blue", "purple", "yellow", "green"]
y_position = [-70, -40, -10, 20, 50, 80 ]
all_turtle = []
for turtle_ind... | true |
9bc20c7bd49c75ad4fa1f7f14bdaf53b067c2765 | smohapatra1/scripting | /python/practice/day22/4.if_else_elsif.py | 454 | 4.34375 | 4 | #!/usr/bin/python
#Write a program which asks the user to type an integer.
#If the number is 2 then the program should print "two",
#If the number is 3 then the program should print "three",
#If the number is 5 then the program should print "five",
#Otherwise it should print "other".
a = int(raw_input("Enter an inte... | true |
9e3497c111907de60e9c65126ccb0392bb226cb8 | smohapatra1/scripting | /python/practice/start_again/2023/07282023/valid_palindrome.py | 1,570 | 4.21875 | 4 | # 125. Valid Palindrome
# A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward.
# Alphanumeric characters include letters and numbers.
# Given a string s, return true if it is a palindrome, or fa... | true |
9824a4b453375626bcb9f8aa7b44a1918bb9aefc | smohapatra1/scripting | /python/practice/start_again/2021/01282021/multiplication_table.py | 522 | 4.34375 | 4 | #Python Program to Print Multiplication Table
#Write a Python Program to Print Multiplication Table using For Loop and While Loop with an example.
#https://www.tutorialgateway.org/python-program-to-print-multiplication-table/
def main():
a = int(input("Enter the first number: "))
b = int(input("Enter the second... | true |
20c8b64f6be8db91cba68f554d3e3ae05419dd91 | smohapatra1/scripting | /python/practice/start_again/2020/11192020/exercise1_volume_sphere.py | 246 | 4.59375 | 5 | #Write a function that computes the volume of a sphere given its radius.
#Volume = 4/3 * pi * r**2
from math import pi
def volume(x):
v = ( (4/3) * pi * (x**3))
print ("The volume is {}".format(v))
volume(input("Enter the the radius : ")) | true |
46498d3f88a2b0fc51b346c66a97e5fda3a0062e | smohapatra1/scripting | /python/practice/start_again/2022/01112022/function_strip_and_lower.py | 377 | 4.125 | 4 | #Define a fucntion strip and lower
#This function should remove space at the begining and at the end of the string
# this it will convert the string into lower case
import string
import os
def strip_lower(a):
remove_space=a.strip()
print (f'{remove_space}')
lower_text=remove_space.lower()
#return lower_... | true |
dabf1a922d38efaf401cf0965010f9cf573ea5e6 | smohapatra1/scripting | /python/practice/start_again/2022/01232022/Seasonal_dress.py | 595 | 4.3125 | 4 | # Define a function that decides what to wear, according to the month and number of the day.
# It should ask for month and day number
# Seasons and Garments :
# Sprint - Shirt
# Summer : T-Shirt
# Autumn : Sweater
# Winter : Coat
def what_to_wear (m, d ):
if m == "March" and d < 15 or d > 20:
print (... | true |
abafe23702ae19b7226190cf0d257696b2b37246 | smohapatra1/scripting | /python/practice/start_again/2023/07202023/group_anagrams.py | 1,268 | 4.375 | 4 | # Given an array of strings strs, group the anagrams together. You can return the answer in any order.
# An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
# Example 1:
# Input: strs = ["eat","tea","tan","ate","nat",... | true |
6dde775a5d0c80f11e01a71098f64c47bc20d618 | smohapatra1/scripting | /python/practice/start_again/2022/09112022/Reverse_array.py | 334 | 4.21875 | 4 | #Reverse array
def reversearray(array):
n=len(array)
lowindex=0
highindex=n-1
while highindex > lowindex:
array[lowindex], array[highindex] = array[highindex], array[lowindex]
lowindex+=1
highindex-=1
if __name__ == '__main__':
array=[1,2,3,4,5]
reversearray(array)
... | true |
f87568f78e5811a171fd3a48a693fbabad90f562 | smohapatra1/scripting | /python/practice/day8/loop_until_your_age.py | 243 | 4.34375 | 4 | #!/usr/bin/python
#Create a loop that prints out either even numbers, or odd numbers all the way up till your age. Ex: 2,4,6,....,14
age = int(raw_input("Enter your age: "))
for i in range(0,age, 2):
print ("%d is a even number") % i
| true |
16dd759bfb679b455f370364a9113c3d1bdc3979 | cristearadu/CodeWars--Python | /valid parentheses.py | 966 | 4.25 | 4 | #Write a function called that takes a string of parentheses, and determines if the order of the parentheses is valid. The function
#should return true if the string is valid, and false if it's invalid.
#0 <= input.length <= 100
def valid_parentheses(string):
if not string:
return True
ret_va... | true |
d22ddd5a6b3f4bd42aefe3384054ceea2fef38db | OMAsphyxiate/python-intro | /dictionaries.py | 1,084 | 4.9375 | 5 | # Dictionaries allow you to pair data together using key:value setup
# For example, a phone book would have a name(key):phone number (value)
# dict[key] --> value
# Stored using {}
phone_book1 = {'qazi':'123-456-7890', 'bob':'222-222-2222', 'cat':'333-333-3333'}
# This can be created this way to make the code more rea... | true |
55d6cf63e7d64239137d5156afbeae90b661c6e5 | whuang67/algorithm_dataStructure | /Part6_Search_Sort/SequentialSearch.py | 1,278 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 03 20:40:39 2018
@author: whuang67
"""
###### Sequential Search ######
def search(arr, item, sort=False):
## Unordered
def seq_search(arr, item):
pos = 0
found = False
while pos < len(arr) and not found:
pri... | true |
e3e3d68b5af0809f5bd6adc8d191a50158b63535 | drfoland/test-repo | /week_3/weekly-exercises/insertionSort.py | 662 | 4.1875 | 4 | ### This is my own insertionSort code completed as an eLearning exercise.
"""
main() function is used to demonstrate the sort() function
using a randomly generated list.
"""
def main():
### List Initialization
from numpy import random
LENGTH = 6
list = []
for num in range(LENGTH):
list.append(random.randin... | true |
39e1e460c3ddf9293efa189a46e30f58c3222481 | Fili95160/Final1.PCBS | /exp.py | 2,903 | 4.125 | 4 | """A series of trials where a Circle is presented and the participant must press a key as quickly as possible.
"""
import random
from expyriment import design, control, misc, stimuli
########## ******************* PART 1.Experiment settings ******************* ####################
NTRIALS = 5
ITI = 1000 # inter t... | true |
881b990daf1d7e913a1d67e1001b3b861dfa706e | douzhenjun/python_work | /random_walk.py | 1,083 | 4.28125 | 4 | #coding: utf-8
from random import choice
class RandomWalk():
'''a class which generate random walking data'''
def __init__(self, num_points=20):
'''initial the attribute of random walking'''
self.num_points = num_points
#random walking origins from (0,0)
self.x_values = [0]
self.y_values = [0]
de... | true |
8e09b0b74fcfd1c9fab28dfc8cc0104feee6dea6 | justinminsk/Python_Files | /Intro_To_Python/X_Junk_From_Before_Midterm/SuperFloatPow.py | 338 | 4.125 | 4 | def SuperFloatPow(num, num2, num3) :
"""(number, number, number) -> float
Takes three numbers inculding float and the first number is taken to the
second numbers power then divided by the third and the answer is the remainder
>>>SuperFloatPow(4.5, 6.4, 8.9)
7.344729065655461
"""
return((... | true |
6555a2c4680eff23807d266a903c229bc506abe6 | justinminsk/Python_Files | /Intro_To_Python/HW11/rewrite.py | 1,505 | 4.3125 | 4 | import os.path
def rewrite(writefile):
while os.path.isfile(writefile): # sees if the file exsits
overwrite = input('The file exists. Do you want to overwrite it (1), give it a new name (2), or cancel(3).')
# menu
if overwrite == '1':
print('I will overwrite the ' + writefile ... | true |
8914809ff2f8fa02fc8368e032fd3faaa2c4aa8f | justinminsk/Python_Files | /Intro_To_Python/HW15/find_min_max.py | 689 | 4.1875 | 4 | def find_min_max(values):
"""(list of numbers) -> NoneType
Print the minimum and maximum value from values.
"""
min = values[0] # start at the first number
max = values[0] # start at the first number
for value in values:
if value > max:
max = value
if value < min:
... | true |
8e80963193c11d414b5d73adbacb1cf3b952b6f6 | mshellik/python-beginner | /working_with_variable_inputs.py | 503 | 4.34375 | 4 | #this is to understand the variables with input and how we can define them and use them
YourFirstName=input("Please enter Your First Name: ") # Input will always take variable as string
YourLastName=input("Please enter your Last Name: ")
print(f'Your First Name is {YourFirstName} and the Last Name is {YourLastName}'... | true |
0aeffedd3cf8073d2e6bdd291ec17485d5e3aefd | kai-ca/Kai-Python-works | /LAB08/dicelab/dice.py | 1,442 | 4.15625 | 4 | """ Dice rolls. We roll dice. One die or a
pair of dice. The dice usually have six
sides
numbered 1 thru 6, but we also allow
dice with any nsides. See the test files
for details.
Copyright (c)2015 Ulf Wostner
<wostner@cyberprof.com>. All rights
reserved. """
import random
def roll(nsides=6):
"""Ro... | true |
b0d5a5d7747c0071fab9d13962963dbca0b44157 | kai-ca/Kai-Python-works | /LAB09/datastructlab/queuemodule.py | 1,198 | 4.5 | 4 | """We implement a Queue data structure.
Queue is a FIFO = First In First Out data structure, like people in line at a ticket office.
We create a class named Queue.
Then we can make instances of that class.
>>> myqueue = Queue()
>>> isinstance(myqueue, Queue)
True
>>> myqueue.push('Alice')
>>> myqueue.push('Eve')
... | true |
e72216a516cffe0cd78432f118de9d5fb6441a47 | kai-ca/Kai-Python-works | /LAB09/datastructlab/stackmodule.py | 1,658 | 4.21875 | 4 | """We implement a Stack data structure.
Stack is a LIFO = Last In First Out data
structure, like a atack of plates. The last
plate you put on the stack is the first plate
that will be removed.
Tip: Print out all the test files in the tests
directory and then get to work on the metods,
one by one.
Use your Stack... | true |
0da353feebc2597c645b088385db28f6f023235e | ramakrishna1994/SEM2 | /NS/Assg1/d_5_Decryption_Procedure_code.py | 2,803 | 4.28125 | 4 | '''
Author : Saradhi Ramakrishna
Roll No : 2017H1030081H
M.E Computer Science , BITS PILANI HYDERABAD CAMPUS
Description : Takes Cipher text as input and gives the Plain text as output
Input - 1.Key
2.Cipher Text
Output - Decrypted Plain Text
S... | true |
761cfb3ca383146a744b8919598e46cfe7216cba | Gongzi-Zhang/Code | /Python/iterator.py | 850 | 4.625 | 5 | '''
Iterable is a sequence of data, one can iterate over using a loop.
An iterator is an object adhering to the iterator portocol.
Basically this means that it has a "next" method, which, when called
returns the next item in the sequence, and when there's nothing to
return, raise the StopIteration exception.
'''
'''
Wh... | true |
0aaa40fdb013ee3cc2b10000709f9fcc7241c476 | vrrohan/Topcoder | /easy/day11/srm740/getaccepted.py | 2,810 | 4.4375 | 4 | """
Problem Statement for GetAccepted
Problem Statement
For this task we have created a simple automated system. It was supposed to ask you a question by giving you a String question.
You would have returned a String with the answer, and that would be all. Here is the entire conversation the way we planned it:
"Do ... | true |
2fe7c4f1acffb9dbd5a1e8b005adbdb871bace1f | MoisesSanchez2020/CS-101-PYTHON | /cs-python/w02/team02_2.py | 1,352 | 4.40625 | 4 | """
File: teach02_stretch_sample.py
Author: Brother Burton
Purpose: Practice formatting strings.
This program also contains a way to implement the stretch challenges.
"""
print("Please enter the following information:")
print()
# Ask for the basic information
first = input("First name: ")
last = input("Last name: ... | true |
34abc2ab48a1065cb7f0055b1b0489654a406ed0 | MoisesSanchez2020/CS-101-PYTHON | /w04/team04.py | 2,862 | 4.28125 | 4 | """
File: teach04_sample.py
Author: Brother Burton
Purpose: Calculate the speed of a falling object using the formula:
v(t) = sqrt(mg/c) * (1 - exp((-sqrt(mgc)/m)*t))
"""
import math
# while you don't _have to_, it's considered good practice to import libraries
# at the top of your program, so that others know exac... | true |
b0bcfd87202ae144fbf263229c4fe94efebb6072 | MoisesSanchez2020/CS-101-PYTHON | /w10/checkpoint.py | 917 | 4.3125 | 4 | # Create line break between the terminal and the program.
print()
# Explain use of program to user.
print('Please enter the items of the shopping list (type: quit to finish):')
print()
# Create empty shopping list.
shop_list = []
# Define empty variable for loop.
item = None
# Populate shop_list with user input:
wh... | true |
e2a8d0f69d84f49228e816676adc8c6506905696 | vpdeepak/PirpleAssignments | /AdvancedLoops/main.py | 1,104 | 4.28125 | 4 | """
This is the solution for the Homework #6: Advanced Loops
"""
print("Assignment on Advanced Loops")
def DrawBoard(rows, columns):
result = False
if(rows < 70 and columns < 235):
result = True
for row in range(rows):
if(row % 2 == 0):
for column in range(columns... | true |
6948f7fae7e5042b299b5953d967a2159c9ed999 | damani-14/supplementary-materials | /Python_Exercises/Chapter03/CH03_05.py | 543 | 4.15625 | 4 | # program to calculate the order costs for the "Konditorei Coffee Shop"
# cost = 10.50/lb + shipping
# shipping = 0.86/lb + 1.50 fixed overhead cost
import math
def main():
print("")
print("This program will calculate the total cost (10.50/lb) for your coffee plus shipping (0.86/lb + 1.50 fixed).")
print... | true |
2bd6df777921168b3b76c52becaad87f6fe7ab70 | damani-14/supplementary-materials | /Python_Exercises/Chapter03/CH03_17.py | 958 | 4.3125 | 4 | # bespoke algorithm for calculating the square root of n using the "guess-and-check" approach
# Newton's method of estimating the square root, where:
# sqrt = (guess + (x/guess))/2
# guess(init) = x/2
import math
def main():
print("")
print("This program will estimate the square root of a value 'x' using 'n'"... | true |
c8ce4ca5959e673f92c28944bb53d3058329f4c5 | damani-14/supplementary-materials | /Python_Exercises/Chapter03/CH03_06.py | 555 | 4.21875 | 4 | # program which calculates the slope of a line given x,y coordinates of two user provided points
import math
def main():
print("")
print("This program will calculate ths slope of a non-vertical line between two points.")
print("")
x1,y1 = eval(input("Enter the coordinates of POINT 1 separated by a co... | true |
ec940e4973e310100d24207050f870e66b0543b1 | damani-14/supplementary-materials | /Python_Exercises/Chapter05/CH05_01.py | 800 | 4.53125 | 5 | # CH05_01: Use the built in string formatting methods to re-write the provided date converting program p. 147
#-----------------------------------------------------------------------------------------------------------------------
# dateconvert2.py
# Converts day month and year numbers into two date formats
def mai... | true |
22a1797bf0d139c56371968d6ba26eb7f176ed81 | damani-14/supplementary-materials | /Python_Exercises/Chapter08/CH08_01.py | 400 | 4.25 | 4 | # CH08_01: Wite a program that computes and outputs the nth Fibonacci number where n is a user defined value
#----------------------------------------------------------------------------------------------------------------------
def main():
a, b = 1,1
n = eval(input("Enter the length of the Fibonacci sequence... | true |
37c43ced0891ada8ca9d7b2d01df59b9ba96113c | JacksonJ01/List-Operations | /Operations.py | 2,338 | 4.28125 | 4 | # Jackson J.
# 2/10/20
# List Operations with numbers
from ListMethodsFile import *
print("Hello user, today we're going to do some tricks with Lists"
"\nFor that I'm going to need your help"
"\nOne number at a time please")
# This loop will get all five values needed for the methods in the other file t... | true |
2a54f5959a20c597b8250b63a2e3852066193204 | tstennett/Year9DesignCS4-PythonTS | /StringExample.py | 984 | 4.5 | 4 | #This file will go through the basics of string manipulation
#Strings are collections of characters
#Strings are enclosed in "" or ''
#"Paul"
#"Paul is cool"
#"Paul is cool!"
#Two things we need to talk about when we think of strings
#index - always starts at 0
#length
#example
# 0123 012345
#"Paul" ... | true |
cae88fdf277cf60c97b82bac80aea1729728ffdd | juanchuletas/Python_dev | /objects.py | 825 | 4.21875 | 4 | #!/usr/bin/python
# In python everything is an object
# a variable is a reference to an object
# each object has an identity or an ID
x = 1
print(type(x))
print(id(x))
#####################
# class 'int'
# 139113568
####################
# number, string, tuple -> inmutable
# list, dictionary -> mutable
x = 1
y = 1
... | true |
056aa02e58696d83b7e75f8cadad3339e09096ed | goodGopher/HWforTensorPython | /DZ4to11032021/prog4_deliting_elements.py | 823 | 4.125 | 4 | """Removing duplicate elements in list.
Functions:
list_reading(my_list):
Allows to read list from keyboard.
remove_copies(m_list):
Removing duplicate elements in list.
main():
Organize entering and clearing of list.
"""
import checks
def remove_copies(m_list):
"""Removing du... | true |
64b15b4ed5ed67df6e7f912891491dbc6576230c | adiiitiii/IF-else | /alphabet digit or special char???.py | 233 | 4.125 | 4 | ch=input("enter any character")
if ch>"a" and ch<"z" or ch>"A" and ch<"Z" :
print("the character is an alphabet")
elif ch[0].isdigit():
print("the character is a digit")
else:
print("the character is a special character") | true |
a84e87ca3ec6379c4c7582862ed4ff48f4cbee24 | 121710308016/asignment4 | /10_balanced_brackets.py | 2,396 | 4.15625 | 4 | """
You're given a string s consisting solely of "(" and ")".
Return whether the parentheses are balanced.
Constraints
Example 1
Input
s = "()"
Output
True
Example 2
Input
s = "()()"
Output
True
Example 3
Input
s = ")("
Output
False
Example 4
Input
s = ""
Output
True
Exampl... | true |
746a47a541ca0da03832a24b02ef340be66659ec | src053/PythonComputerScience | /chap3/ladderAngle.py | 891 | 4.5 | 4 | # This program will determine the length of the ladder required to
# reach a height on a house when you have that height and the angle of the ladder
import math
def main():
# Program description
print("This program will find the height a ladder will need to be when given two inputs")
print("1) The height of the ho... | true |
326c7997a605b2a681185f98f76b309ae2548e58 | src053/PythonComputerScience | /chap5/avFile.py | 602 | 4.28125 | 4 | #program that will count the number of words in a sentence from within a file
def main():
#get the name of file
fname = input("Please enter the name of the file: ")
#open the file
infile = open(fname, "r")
#read in file
read = infile.read()
#split the sentence into a list
split = read.split()
#count the l... | true |
e200b43b7d728635cf1581cf5eb4fcde4729bff6 | src053/PythonComputerScience | /chap3/slope.py | 985 | 4.3125 | 4 | # This program will calculate the slope of to points on a graph
# User will be required to input for var's x1, x2, y1, y2
import math
def slope(x1, x2, y1, y2):
return round((y2 - y1)/(x2 - x1)) #Calculate and return the slope
def distance(x1, x2, y1, y2):
return round(math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))... | true |
90873ee519d41e877adbe3037d7fcd9b5e0b7e96 | src053/PythonComputerScience | /chap3/easter.py | 467 | 4.125 | 4 | # This program will take the year a user inputs and output the value of easter
def main():
print("This program will figure out the epact for any given year")
year = eval(input("Input the year you would like to know the epact of: "))
#Equation to figure out integer division of C
C = year//100
#Equation to figur... | true |
26870cc55f6e78c2d25cc09b9119491abdef8434 | src053/PythonComputerScience | /chap2/convert.py | 331 | 4.28125 | 4 | #A program to convert Celsius temps to Fahrenheit
def main():
print("This program will convert celsius to farenheit")
count = 0
while(count < 5):
celsius = eval(input("What is the Celsuis temperature? "))
fahrenheit = 9/5 * celsius + 32
print("The temperature is", fahrenheit, "degree Fahrenheit.")
count +... | true |
f40123af7ffca03d3d4184aa3fcf131f7f8f2ce4 | Kdk22/PythonLearning | /PythonApplication3/exception_handling.py | 2,688 | 4.21875 | 4 | # ref: https://docs.python.org/3/tutorial/errors.html
while True:
try:
x = int(input('Please enter a number: '))
break
except ValueError:
print('Ooops ! THat was no valid number. Try agian..')
''' If the error type matches then only in displays message.
If the error t... | true |
bb52036b8bf49eb4af098c7f2025fce8080316d8 | Kdk22/PythonLearning | /PythonApplication3/class_var_and_instance_var.py | 1,005 | 4.5625 | 5 |
class foo:
x='orginal class'
c1,c2 = foo(), foo()
''' THis is creating the multiple objects of
same as
c1 = foo()
c2 = foo()
and these objects can access class variable (or name)
'''
print('Output of c1.x: ', c1.x)
print('Output of c2.x: ', c2.x)
'''
Here if you change the c1 instance, and i... | true |
b6417cda68e6efe3792e317980cbbdb923a5cb63 | vohrakunal/python-problems | /level2prob4.py | 806 | 4.375 | 4 | '''
In this task, we would like for you to appreciate the usefulness of the groupby() function of itertools . To read more about this function, Check this out .
You are given a string . Suppose a character '' occurs consecutively times in the string. Replace these consecutive occurrences of the character '' with in ... | true |
61d217ee89bf72920f370c96b6554d675a4c035e | steveiaco/COMP354-Team-E | /Functions/pi.py | 1,320 | 4.125 | 4 | # Goal: Calculate pi to the power of a given variable x
# Author: Ali
from Functions.constants import get_pi
# Pie Function
# Using Table Method
# I have basically created a global variable for PIE and its power
PIE = get_pi()
# the index (n) of the dictionary represent PIE**(10**n)
PIE_Dictionary = {
-5: 1.000... | true |
2dd449e8b85f1814e6c857a1e411936f21ea6c09 | verjavec/guessing_game | /game.py | 1,217 | 4.25 | 4 | """A number-guessing game."""
import random
# Put your code here
# Greet the player
name = input("Please enter your name: ")
print (f'Hello {name}!')
#choose a random number
numbertoguess = random.randrange(1,100)
print(numbertoguess)
keep_guessing = True
num_guesses = 0
#repeat this part until random number equal... | true |
946d079c682179d1e5b09bfeed6ae36a23045eae | inwk6312winter2019/week4labsubmissions-deepakkumarseku | /lab5/task4.py | 762 | 4.34375 | 4 | import turtle
class rectangle():
"""Represents a rectangle.
attributes: width, height.
"""
class circle():
"""Represents a circle.
attributes: radius.
"""
radius=50
def draw_rect(r):
""" Draws a rectangle with given width and height using turtle"""
for i in ... | true |
8f2e39d178be9670253ca98d275cc549226b6971 | williamstein/480_HW2 | /simple_alg.py | 1,050 | 4.15625 | 4 | print "Hello"
import math
#computes the probability of the binomial function in the specified range inclusive
#min, max are the values for the range
#n is the total population
#p is the success probability
def binom_range(min, max, n, p):
if(min > max):
raise Exception("Please pass a valid range")
if(min < 0):
... | true |
5bc42f93d4da19adc21bc675f5cfa6aec78411a7 | tianxiongWang/codewars | /sum.py | 484 | 4.15625 | 4 |
# >Given two integers a and b, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return a or b.
# 其实就是把a到b之间的数求和,太简单了
def get_sum(a,b):
if a == b:
return a
if a < b:
sum = 0
for num in range(a, b+1... | true |
32699826b747b0009a4313fb427fda5a4ac7ef79 | Kallol-A/python-scripting-edureka | /Module 3/Case1/commavalues.py | 641 | 4.1875 | 4 | #Write a program that calculates and prints the value according to the given formula:
#Q = Square root of [(2 * C * D)/H]
#Following are the fixed values of C and H: C is 50. H is 30.
#D is the variable whose values should be input to your program in a comma- separated sequence.
#Let us assume the following comma s... | true |
58a0e3ca5ac367b7b994450b49fc7fc3a6c664ad | Alainfou/python_tools | /prime_list.py | 2,134 | 4.1875 | 4 | #!/usr/bin/python
import math
import sys
import getopt
print "\n\tHey, that's personal! That's my very, very personal tool for listing prime numbers! Please get out of here! =(\n"
dat_prime_list = [2,3]
def its_prime (p):
s = int(math.sqrt(p))+1
for i in dat_prime_list :
if (p%i) =... | true |
2a378d9c0099652c3f74f22fa67311636d6d477a | geraldo1993/CodeAcademyPython | /Strings & Console Output/String methods.py | 614 | 4.4375 | 4 | '''Great work! Now that we know how to store strings, let's see how we can change them using string methods.
String methods let you perform specific tasks for strings.
We'll focus on four string methods:
len()
lower()
upper()
str()
Let's start with len(), which gets the length (the number of characters) of a string!... | true |
d3b8a54fca1ec8f724ec1a2de1a81f952c0368d7 | ohwowitsjit/WK_1 | /2.py | 201 | 4.125 | 4 | num_1 = int(input("Enter the first number: "));
num_2= int(input("Enter the first number: "));
product=0;
for i in range(0, num_2):
product=product+num_1;
print("Product is:", str(product)); | true |
2db6a8ca529a72823ce4e7ba45cfcb050ff830bd | puneet672003/SchoolWork | /PracticalQuestions/06_question.py | 358 | 4.28125 | 4 | # Write a Python program to pass a string to a function and count how many vowels present in the string.
def count_vowels(string):
vowels = ["a" ,"e", "i", "o", "u"]
count = 0
for char in string:
if char.lower() in vowels:
count += 1
return count
print(f"Total vowels : ", c... | true |
6647ec2418ab875585ed562ceeea49a6bd1c9746 | puneet672003/SchoolWork | /PracticalQuestions/03_question.py | 411 | 4.40625 | 4 | # Write a python program to pass list to a function and double the odd values and half
# even values of a list and display list element after changing.
def halfEven_doubleOdd(arr):
for i in range(len(arr)):
if arr[i] % 2 == 0:
arr[i] = arr[i]/2
else :
arr[i] = arr[i]*2
... | true |
d1fff6ff6f5f6c089029a521907eb1fe14a9680c | erin-koen/Whiteboard-Pairing | /CountingVotes/model_solution/solution.py | 1,377 | 4.28125 | 4 | # input => array of strings
# output => one string
# conditions => The string that's returned is the one that shows up most frequently in the array. If there's a tie, it's the one that shows up most frequently in the array and comes last alphabetically
# sample input => input: ['veronica', 'mary', 'alex', 'james', 'ma... | true |
4c051300bade9b496dcb31f81376b704a82f84eb | fionnmcguire1/LanguageLearning | /PythonTraining/Python27/BattleShip_medium.py | 1,815 | 4.1875 | 4 | '''
Author: Fionn Mcguire
Date: 26-11-2017
Description:
Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules:
You receive a valid board, made of only battleships or empty slots.
Battleships ... | true |
a6d0f86a9c77d54bec821e91a665522357466cf5 | Dallas-Marshall/CP1404 | /prac_01/electricity_bill_estimator.py | 719 | 4.15625 | 4 | # Electricity Costs
TARIFF_11 = 0.244618
TARIFF_31 = 0.136928
electricity_cost = 0
# Define Menu:
MENU = """Please select tariff;
Tariff(11)
Tariff(31)"""
# Display Menu
print(MENU)
# Ask user to select menu option
user_choice = int(input(">>> "))
# Define relevant electricity cost
if user_choice == 31:
electri... | true |
306684db850ddb2a45b4b554a8a4f940b9322151 | EtienneBauscher/Classes | /student.py | 1,970 | 4.1875 | 4 | """'student.py' is a program that computes the following:
1. The average score of a student's grades.
2. It tests whether a student is a male or a female.
The program utilises a class called Student
The class hosts various fucntions for the computation of the needed outcomes.
"""
class Student(object):
""... | true |
532d90e13e03f6af7ef54e45544688a5ef934009 | ghostassault/AutomateTheBoringWithPython | /Ch7/RegEx.gyp | 2,277 | 4.375 | 4 | #The search() method will return a match object of the first matched text in a searched string
#1 Matching Multiple groups with the pipe
import re
heroR = re.compile(r'Batman|Tina Fey')
mo1 = heroR.search('Batman and Tina Fey.')
print(mo1.group())
#2 Optional Matching with the Question Mark
batRe = re.compile(r'Bat(... | true |
db7cd6a5237bdfca4a0622c10b1cdd3ddb430bf8 | jinshanpu/lx | /python/func.py | 280 | 4.125 | 4 | print "the prog knows which number is bigger"
a=int(raw_input("Number a:"))
b=int(raw_input("Number b:"))
def theMax(a, b=0):
'''Prints the maximun of two numbers.
the two values must be integers'''
if a>b:
return a
else:
return b
print theMax(a, b)
print theMax.__doc__
| true |
e2e6f661dece58eb23e84de878e866878d54d295 | franklinharvey/CU-CSCI-1300-Fall-2015 | /Assignment 3/Problem1.py | 251 | 4.125 | 4 | #Franklin Harvey
#Assignment 3
#Problem 1
#TA: Amber
fullName = raw_input("What is your name in the format Last, First Middle? ")
comma = fullName.find(",")
lastName = fullName[0:comma]
#print lastName
print fullName [comma + 2:len(fullName)] + " " + lastName | true |
1398a66b86aca613a6dbb7ba5c534615e14348cc | ShreyasAmbre/python_practice | /PythonPracticeQuestion2.0/PythonProgram_2.3.py | 432 | 4.1875 | 4 | # WAP to add 'ing' at the end of a given string (length should be at least 3). If the given
# string already ends with 'ing' then add 'ly' instead. If the string length of the given string is less than 3,
# leave it unchanged.
s = "playing"
ls = list(s)
if len(s) > 3:
estr = "ing"
ostr = s[-3:]
if estr == ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.