blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
8a91d4bf14c9215077834ed74748ee2e6b8fa163 | TheHugeHaystack/Solucion-a-problemas-con-Programacion | /temperature.py | 1,636 | 4.65625 | 5 | #Code by: rghost Academic Purposes
#This code is to do the following:
# Write a program that will prompt the user for a temperature asking the user between Fahrenheit and Celsius;
# then, convert it to the other. You may recall that the formula is C = 5 ∗ (F − 32)/9.
# Modify the program to state whether or not... | true |
69ba50bcd982901a944ae4c5be100dce7ceebe79 | mrinfosec/cryptopals | /c10.py | 2,265 | 4.15625 | 4 | #!/usr/bin/python
# Implement CBC mode
# CBC mode is a block cipher mode that allows us to encrypt irregularly-sized
# messages, despite the fact that a block cipher natively only transforms
# individual blocks.
#
# In CBC mode, each ciphertext block is added to the next plaintext block before
# the next call to the ci... | true |
8be0d2e9a8d67dcad48786a68b37d216bee1b28d | cdean00/PyNet | /pynetweek4_excersise3.py | 1,361 | 4.21875 | 4 | """
Week 4, Excersise 3
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
III. Create a program that converts the following uptime strings to a tim... | true |
aa7924e7483d1757d0ebf8e3b8ed6008f143060d | nilskingston/String-Jumble | /stringjumble.py | 1,277 | 4.28125 | 4 | """
stringjumble.py
Author: Nils Kingston
Credit: Roger
Assignment:
The purpose of this challenge is to gain proficiency with
manipulating lists.
Write and submit a Python program that accepts a string from
the user and prints it back in three different ways:
* With all letters in reverse.
* With words in reverse... | true |
a60fd066512a2fe60e465b8556d046b344e94dc3 | Kalpesh14m/Python-Basics-Code | /Basic Python/8 Function.py | 756 | 4.34375 | 4 | # The idea of a function is to assign a set of code, and possibly variables, known as parameters, to a single bit of text.
# You can think of it a lot like why you choose to write and save a program, rather than writing out the entire program every time you want to execute it.
#
# To begin a function, the keyword 'def'... | true |
124765cd61ad7ba8518b3027531cfc5b535ad353 | Kalpesh14m/Python-Basics-Code | /Basic Python/TKinter/33 Tkinter intro.py | 1,268 | 4.3125 | 4 | """
The tkinter module is a wrapper around tk, which is a wrapper around tcl, which is what is used to create windows and graphical user interfaces.
Here, we show how simple it is to create a very basic window in just 8 lines.
We get a window that we can resize, minimize, maximize, and close! The tkinter module's purpo... | true |
5496f6f9ad1393c9f72bda44bdc0b24129de562b | smrmkt/project_euler | /problem_009.py | 1,395 | 4.25 | 4 | #!/usr/bin/env python
#-*-coding:utf-8-*-
'''
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.
'''
import numpy as np
import timeit
import ... | false |
b4b3bff8bf1922b70e8d3e38af1fbb69e30f318e | smrmkt/project_euler | /problem_001.py | 822 | 4.21875 | 4 | #!/usr/bin/env python
#-*-coding:utf-8-*-
'''
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.
'''
import timeit
# slow
# simple loop
def loop(n):
t = 0
for i in range(1, n... | true |
262e88040edd2f5724ed93e282e5945b07d52d01 | ismailasega/Python_Cert_2019 | /Python Basics/Q2.py | 267 | 4.28125 | 4 | #accepts a sequence of words as input and prints the words in a sequence after sorting them alphabetically.
str = input("type 7 names, then press enter: \n ")
names = str.split()
names.sort()
print("The names in alphabetic order:")
for name in names:
print(name) | true |
833c17c00e98c40643bf0db2a04220a48e77b7a2 | ismailasega/Python_Cert_2019 | /Data visualisation/CaseStudy1/Qn1.py | 616 | 4.34375 | 4 | # You are given a dataset, which is present in the LMS, containing the number of
# hurricanes occurring in the United States along the coast of the Atlantic. Load the
# data from the dataset into your program and plot a Bar Graph of the data, taking
# the Year as the x-axis and the number of hurricanes occurring as the... | true |
177170fd7f050b898cb18642d6e22e9ab45dccad | Falsaber/mhs-python | /Basics Tutorial #1 - Python.py | 2,065 | 4.125 | 4 | #This is a comment.
#Comments are ignored during code activation.
print("The shell will print what is contained within this area.")
var = input("var will now become a variable that can be called upon later. var is now:")
print(var)
#This will print the text in the variable "var" and require a response.
#input asks for... | true |
60db9080ef8cf89aed97749191a024bc2bb50e42 | jvillega/App-Academy-Practice-Problems-I | /SumNums.py | 456 | 4.4375 | 4 | #!/usr/bin/env python3
# Write a method that takes in an integer `num` and returns the sum of
# all integers between zero and num, up to and including `num`.
#
# Difficulty: easy.
# Precondition: num is a defined integer
# Postcondition: sum of all integers between zero and num are returned
def sumNums( num ):
... | true |
ea70a815fe1af0e4a9d744be5e65716583d905b0 | shefreyn/Exercise_1-100 | /Ex_(2).py | 498 | 4.21875 | 4 | print('__ Tip Calculator __')
totalBill = input('Total bill amount : ')
totalBill = int(totalBill)
percentage = input('Percentage you would like to tip : ')
percentage = int(percentage)
totalPeople = input('Total no of people you want to split the bill : ')
totalPeople = int(totalPeople)
tip = percentage/totalBi... | true |
d37a0503e24a9adc939a88afb84290820d8ca565 | ClosetcoderJ/python | /chapter2/Ex9.py | 445 | 4.25 | 4 | oddRange = range(1, 10, 2)
evenRange = range(2, 10, 2)
print(oddRange)
print(evenRange)
print(list(oddRange))
print(list(evenRange))
tenRange = range(1, 11, 1)
tenRange1 = range(10, 0, -1)
# 1 ~ 10 까지 모든 수를 갖고 있는 Range
range1 = range(1, 11, 1) #range라고 변수명 지으면 안됨
range2 = range(1, 11)
# 10 ~ 1 까지 모든 수를 갖고 있는 Range... | false |
42daa52bcad63bb4a42ba9f2598423a9d0b8f329 | umeshraj/MITx-6.00.1x_CS | /wk2_ex_isin.py | 597 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 17 15:10:39 2017
@author: umesh
"""
def isIn(char, aStr):
'''
char: a single character
aStr: an alphabetized string
returns: True if char is in aStr; False otherwise
'''
# Your code here
if len(aStr) == 0:
retur... | false |
000a977fa8f8df9751c97dd6d92c8b307ccd8759 | liaosuwei/learnGit | /1.py | 1,300 | 4.15625 | 4 |
#print('please enter your name:')
#name = input()
#print('hello',name)
#print('中文测试正常')
'''age = 7
if age >=18:
print('your age is',age)
print('adult')
elif 18 > age >= 6:
print('your age is',age)
print('teenager')
else:
print('your age is',age)
print('kid')
height = 1.75
weight = 80.5
bmi ... | false |
7cf1e38bed3059b0e455ee77a91c394c7307b3d4 | gitBlackburn/Learn-Python-The-Hard-Way | /ex15.py | 614 | 4.21875 | 4 | # uses argv from the sys lib
# adds arguments
# from sys import argv
# # two arguments scripts and filename
# script, filename = argv
# # opens the text file and stores it in txt
# txt = open(filename)
# # notifies the user
# print "Here's your file %r:" %filename
# # reads the text file
# print txt.read()
# promp... | true |
84252e3008a9d3e59636948801cff89ef25ae676 | samfrances/coding-challenges | /codewars/6kyu/write_number_in_expanded_form.py | 875 | 4.1875 | 4 | #!/usr/bin/env python3
"""
Solution to https://www.codewars.com/kata/5842df8ccbd22792a4000245/
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 retur... | true |
959d90c339a63bc8fe81a2c82cf03d06fed6a3d6 | samfrances/coding-challenges | /codewars/5kyu/calculating_with_functions.py | 1,685 | 4.40625 | 4 | #!/usr/bin/env python2
"""
Solution to https://www.codewars.com/kata/525f3eda17c7cd9f9e000b39/
This time we want to write calculations using functions and get the results.
Let's have a look at some examples:
JavaScript:
seven(times(five())); // must return 35
four(plus(nine())); // must return 13
eight(minus(three(... | true |
f688003052f4e3dff5422dc4eb669322434fc3b4 | Biraja007/Python | /Looping-Statements.py | 1,423 | 4.625 | 5 | # Looping statements is used to repeatedly perform a block of operations.
# For loop: It is used to iterate over a sequence starting from first value to the last.
Numbers = [1,2,3,4,5]
for number in Numbers:
print (number , end=' ')
print()
print()
# While loop: It is used to repeatedly execute a block of ... | true |
027f5fd55ea60cddc723d52fd8bcba69789f7f8c | bondarum/python-basics | /examples/ex19_object_and_classes.py | 2,575 | 4.375 | 4 | # class
# Tell Python to make a new type of thing.
# object
# Two meanings: the most basic type of thing, and any instance of some thing.
# instance
# What you get when you tell Python to create a class.
# def
# How you define a function inside a class.
# self
# Inside the functions in a class, self ... | true |
9601c95246f411b410d64ed76bbeb117d2635e31 | saikiran6666/rama | /operators.py | 1,402 | 4.28125 | 4 | #addition
x=12
y=2
print(x+y)
#substraction
x=10
y=5
print(x-y)
#multiplication
x=10
y=10
print(x*y)
#division
x=10
y=2
print(x / y)
#modulus
x=6
y=2
print(x%y)
#exponenetiation
x=2
y=3
print(x**y)
#floor division
x=5
y=2
print(x // y)
#assignment operators
# "=" operator
x=10
print(x)
# += operator
x=10
x+=2
pri... | false |
2c0499d4e9b9a35f6b5157932fa2d58bcdf5f7d3 | bnsreenu/python_for_microscopists | /052-GMM_image_segmentation.py | 2,975 | 4.125 | 4 | #!/usr/bin/env python
__author__ = "Sreenivas Bhattiprolu"
__license__ = "Feel free to copy, I appreciate if you acknowledge Python for Microscopists"
# https://www.youtube.com/watch?v=kkAirywakmk
"""
@author: Sreenivas Bhattiprolu
NOTE: I was alerted by one of the viewers that m.bic part needs more explana... | true |
15acd9528c16d6b48e195e8d34fec459cd356560 | hossainlab/numpy | /book/_build/jupyter_execute/notebooks/07_ChangingShapeOfAnArray.py | 1,828 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# ## Array Shape Manipulation
# In[1]:
import numpy as np
# ### 1. Flattening
# In[2]:
a = np.array([("Germany","France", "Hungary","Austria"),
("Berlin","Paris", "Budapest","Vienna" )])
# In[3]:
a
# In[4]:
a.shape
# #### The ravel() function
# The... | true |
aa0b0faf17e8610c304726adae4c0ec31b4ecdc4 | subramario/Data_Structures_Algos_Practice | /Sorting/Quicksort.py | 1,711 | 4.15625 | 4 | #Classic quicksort - chooses the first element in the array as the pivot point and sorts accordingly
class Solution:
def partition(self, array, start, end):
# [start|low_ _ _ _ _ _high] --> Three pointers
pivot = array[start]
low = start + 1
high = end
while True:
... | true |
a270bf6c277a23874cd16044fb25e1669d865d56 | Ronaldo192/meus_codigos | /função_P_N.py | 337 | 4.125 | 4 | """
Faça um programa, com uma função que necessite de um argumento. A função retorna o valor de caractere ‘P’,
se seu argumento for positivo, e ‘N’, se seu argumento for zero ou negativo.
"""
def nummero(x):
if x > 0:
print("P")
elif x < 0:
print("N")
else:
print("Zero")
nummero... | false |
a0e48325dedb2e416c7ac28f68cf33202886cdc5 | laomao0/Learn-python3 | /Function/ex20.py | 876 | 4.125 | 4 | from sys import argv
script, input_file = argv
def print_all(f):
print(f.read())
# Each time you do f.seek(0) you're moving to the start of the file
# seek(0) moves the file to the 0 byte(first byte) in the file
def rewind(f):
f.seek(0)
# each time you do f.readline() you're reading a line from the file ... | true |
cfe855ef9cdf7a05a083fd5c3b39ef1b20e16589 | sushmitaraii1/Python-Datatypes-Fucntions | /Function/15.py | 226 | 4.15625 | 4 | # 15. Write a Python program to filter a list of integers using Lambda.
lst = [1, 5, 6, 4, 8, 5, 6, 9, 5, 3, 5, 9]
sorted_list = list(filter(lambda x:x%2==0,lst))
print("The even numbers from list are: ")
print(sorted_list) | true |
158c692aa383ca6f426cabf70d2dc45db3de20b5 | sushmitaraii1/Python-Datatypes-Fucntions | /Function/16.py | 319 | 4.25 | 4 | # 16. Write a Python program to square and cube every number in a given list of
# integers using Lambda.
lst = [1, 5, 6, 4, 8, 5, 6, 9, 5, 3, 5, 9]
print(lst)
print("After squaring items.")
square = list(map(lambda x:x**2,lst))
print(square)
print("After cubing items.")
cube = list(map(lambda x:x**3,lst))
print(cube) | true |
f3a5622a1badea10083c9a1990aefbcdef124dfa | sushmitaraii1/Python-Datatypes-Fucntions | /Datatype/2.py | 480 | 4.40625 | 4 | # 2. Write a Python program to get a string made of the first 2 and the last 2 chars
# from a given a string. If the string length is less than 2, return instead of the empty string.
# Sample String : 'Python'
# Expected Result : 'Pyon'
# Sample String : 'Py'
# Expected Result : 'PyPy'
# Sample String : ' w'
# Expected... | true |
8ccf58ee6e37889d78fff8fdc2a21a5ec99c10e3 | sushmitaraii1/Python-Datatypes-Fucntions | /Function/17.py | 201 | 4.125 | 4 | # 17. Write a Python program to find if a given string starts with a given character
# using Lambda.
start = lambda x: True if x.startswith('P') else False
print(start('Python'))
print(start('Java'))
| true |
ddf9b7911a1853b20a87f6471492991110ff450f | Keilo104/faculdade-solucoes | /Semestre 1/AP1/exercicios2/exercicio8.py | 243 | 4.1875 | 4 | num = int(input("Digite o numerador da divisão: "))
den = int(input("Digite o divisor da divisão: "))
res = num / den
mod = num % den
div = num // den
print("O resultado da divisão é {}, o div é {} e o mod é {}".format(res, div, mod))
| false |
e089c675631f21a21b35ab49e805bc7016d337f1 | jingyiZhang123/leetcode_practice | /dynamic_programming/62_unique_paths.py | 824 | 4.1875 | 4 | """
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there... | true |
2b31d4a4790e35c9d384e9c8f3e8c1bd3eb19696 | jingyiZhang123/leetcode_practice | /recursion_and_backtracking/17_letter_combinations_of_a_phone_number.py | 1,025 | 4.15625 | 4 | """
Given a digit string, 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.
2: abc
3: def
4: ghi
5: jkl
6: mno
7: pqrs
8: tuv
9: wxyz
Input:Digit string "23"
Output: ["ad", "ae", "af", "bd", "be", "... | true |
830e22e15f52ce5d1d0eb65a39c1ea345caadf5a | gokarna123/Gokarna | /classwork.py | 333 | 4.125 | 4 | from datetime import time
num=[]
x=int(input("Enter the number:"))
for i in range(1,x+1):
value=int(input(" Please Enter the number: "))
num.append(value)
num.sort()
print(num)
num=[]
x=int(input("Enter the number:"))
for i in range(1,x+1):
value=int(input(" Please Enter the number: "))
num.reverse()... | true |
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 |
01e5302a82a73d1b89e4996622ae3a76afa542be | TRoyer86/AlgorithmsInPythonExercises | /ImplementedDataStructures/queuetest.py | 973 | 4.25 | 4 | #!/usr/bin/env python
from queueclass import Queue
if __name__ == '__main__':
myqueue = Queue()
print(myqueue.size())
print(myqueue.isEmpty())
# Add each letter in the name of the cutest soon to be 2 year old
myqueue.enqueue('J')
myqueue.enqueue('O')
myqueue.enqueue('S')... | false |
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 |
e2cb5ff79e19754a0de1723983ca3e6fbc5ddbc0 | Arwen0905/Python_Test | /TQC_考題練習_第二類/PYD301.py | 841 | 4.15625 | 4 | # -*- coding: utf-8 -*-
# 載入 pandas 模組縮寫為 pd
import pandas as pd
# 資料輸入
datas = [[75, 62, 85, 73, 60], [91, 53, 56, 63, 65],
[71, 88, 51, 69, 87], [69, 53, 87, 74, 70]]
indexs = ["小林", "小黃", "小陳", "小美"]
columns = ["國語", "數學", "英文", "自然", "社會"]
df = pd.DataFrame(datas, columns=columns, index=indexs)
print('行... | false |
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 |
d61bc138d85bce329077a818754b7ac9dd15dede | GeraldoFBraga/Urion | /problema_1847.py | 1,798 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""A entrada consiste apenas de três inteiros, A, B e C (-100 ≤ A, B, C ≤ 100), os quais representam respectivamente as
temperaturas registradas no 1º, no 2º e no 3º dias."""
wert = input()
A,B,C = wert.split()
a = int(A)
b = int(B)
c = int(C)
if a > b < c:
'''Se a... | false |
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 |
828c58ffd48d16e2fa9521c5142d3cbc08dbf781 | smohapatra1/scripting | /python/practice/start_again/2021/01202021/leap_year.py | 757 | 4.3125 | 4 | #Python Program to Check Leap Year
#Write a Python Program to Check Leap Year
#or Not by using the If Statement, Nested If Statement, and Elif Statement in Python with example.
#Logic :-
# 366 days
# must be divisible by 4
# Century year - ends with 00, 1200,2400, 2500 - If divisible by 400 ( leap year), if not then... | false |
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 |
9473d9df78d57dbf279956c0fc491cfdaa674e8a | smohapatra1/scripting | /python/practice/start_again/2022/01112022/function03.py | 211 | 4.125 | 4 | # Define a function named say_my_name that asks user to enter his/her name
# This functon would print as : "Hi [ username ] "
def say_my_name(n):
print (f' Hi {n} ')
say_my_name(input("Enter your name : ")) | false |
d00e756205cde1f47268c1ea0e676d1d34def6bc | smohapatra1/scripting | /python/practice/start_again/2022/03162022/square_of_stars_with_while.py | 294 | 4.28125 | 4 | #Draw a square of stars with while
def square_of_stars_with_while(n):
i=0
while i < n:
stars=" "
j=0
while j < n:
stars+="* "
j +=1
print (stars)
i +=1
square_of_stars_with_while(int(input("Enter the number of stars "))) | false |
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 |
dc525f721a46294ad9480e2f048e11f60db7bfc2 | smohapatra1/scripting | /python/practice/start_again/2020/11032020/Assesment1.py | 396 | 4.4375 | 4 | #Use for, .split(), and if to create a Statement that will print out words that start with 's':
#st = 'Print only the words that start with s in this sentence'
st = 'Sam Print only the words that start with s in this sentence'
#print (st.split())
for w in st.split():
if w[0] == 's' or w[0] == 'S':
print (w)... | false |
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 |
831b36909f6487ea728f372718dc5dbf2c5f982b | smohapatra1/scripting | /python/practice/start_again/2022/03212022/isosceles_stars.py | 335 | 4.21875 | 4 | #Print ISOSCELES stars
def isosceles_for(n):
for i in range(n):
stars=""
for j in range(i+1):
stars+="* "
print (stars)
for i in range(n,0,-1):
stars=""
for j in range(i):
stars+="* "
print (stars)
isosceles_for(int(input("Enter the number... | false |
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 |
90b152be2880ea265c2a05924a4be0b526179a5e | Yet-sun/python_mylab | /Lab_projects/lab5/Lab5_04_f1.py | 1,281 | 4.34375 | 4 | '''
需求:改进Person类,在满足之前要求不变的情况下,
将姓名(name)、年龄(age)、性别(sex)变为私有属性
(注意私有属性的定义要求),并使用@property装饰器。
要求使用两种方法
(提示:另一种方法可以直接使用property()函数)。
'''
class Person4:
def __init__(self, name='任我行', age='60', sex='男'):
self.__name = name
self.__age = age
self.__sex = sex
@property
def name(self)... | false |
94237377d8e3c8a64d9dff094a2c3dfdab823484 | Yet-sun/python_mylab | /Lab_projects/lab5/Lab5_02.py | 761 | 4.15625 | 4 | '''
需求:改进Person类,增加构造函数,
要求对于姓名(name)、年龄(age)、性别(sex)三个实例属性,
可以传递任意一个或任意两个参数实例化对象(提示:默认值)。
接着,请编写测试代码测试你的类定义符合题目要求。
'''
class Person2:
def __init__(self, name='杜甫', age='20', sex='男'):
self.name = name
self.age = age
self.sex = sex
def prin_info(self):
print('... | false |
756d1d6de3d815162d40bdbe71d7cf5b35dbdf30 | marinehero/Capital-construction-project | /Projects/BlogWebSite/框架/find().py | 268 | 4.25 | 4 | str = "this is really a string example....wow!!!"
substr = "is"
print (str.rfind(substr)) # 从str字符串右开始 匹配到is 位置从左边0的索引开始 为5
print (str.find(substr)) # 从str字符串左开始 匹配到is 位置从左边0的索引开始 为2 | false |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.