blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
ee0c50c7586746a4dfdbf6348592f561246942c4 | UjjwalP08/Basics-Of-Python | /No_55_Functioncaching.py | 2,008 | 4.65625 | 5 | """
--------------------> Function Caching <---------------------------
some times we are call the same function in program again and again so our time
of program is taken more than expected so reduce this we are use the function
caching
this method is inside the functool module and method is lur_cache
"... | true |
4a89663ccb22ff3f3a9138af70b346b60aa43ab1 | aravinthusa/python-prgramme | /file1.py | 479 | 4.40625 | 4 | program:
#to find the radius of the circle
r=float(input("input the radius of the circle:"))
a=(22*r*r)/7
print("the area of circle with radius",r,"is:",a)
output:
input the radius of the circle:1.1
the area of circle with radius 1.1 is: 3.8028571428571434
program:
#to find the extension of the file
a=input("Inp... | true |
9665330448fa691346f1117e65665b734cd79aa3 | hungnd11111984/DataCamp | /pandas Foundation/Build a DataFrame.py | 2,933 | 4.28125 | 4 | # 1 Zip lists to build a DataFrame
# Display tuple
print(list_keys)
# ['Country', 'Total']
print(list_values)
# [['United States', 'Soviet Union', 'United Kingdom'], [1118, 473, 273]]
# Zip the 2 lists together into one list of (key,value) tuples: zipped
zipped = list(zip(list_keys,list_values))
# Inspect the list usi... | true |
7b4645a593d068c7ab87dc7a71a3022740223ad7 | Luedman/MiscMath | /Collatz.py | 1,267 | 4.125 | 4 | from matplotlib import pyplot as plt
import numpy as np
number = int(input("Starting Number: "))
def collatz(number: int, plot=False):
series = []
odd_series = []
while number > 1:
if number % 2 == 0:
number /= 2
else:
odd_series.append(int(number))
numb... | false |
3bfa1389d2d43bcbdda5995b99c01a8fb16b6496 | yuede/Lintcode | /Python/Reverse-Linked-List.py | 495 | 4.125 | 4 | class Solution:
"""
@param head: The first node of the linked list.
@return: You should return the head of the reversed linked list.
Reverse it in-place.
"""
def reverse(self, head):
# write your code here
if head is None or head.next is None:
return hea... | true |
51aa90a32ee61c3e3891f4cad80c6a06d59a81dd | chunweiliu/leetcode2 | /insert_interval.py | 1,286 | 4.21875 | 4 | """Insert a new interval
<< [[1, 2], [3, 5], [7, 9]], [4, 8]
=> [[1, 2], [3, 9]]
<< [[1, 2]], [3, 4]
=> [[1, 2], [3, 4]]
- Insert a number
[0, 1, 2, 10], 3
Seperate the intervals to left and right half by comparing them with the target interval
- If not overlap, put them ... | true |
0c5d9e1322959ea228ef2e8ac23076caa162a192 | chunweiliu/leetcode2 | /the_skyline_problem.py | 1,998 | 4.21875 | 4 | """Use a dict to represent heights. For each critical point, pop the heightest.
<< [[1, 10, 5], [3, 8, 7]]
=> [[1, 5], [3, 7], [8, 5], [10, 0]]
A good illustration of the skyline problem
https://briangordon.github.io/2014/08/the-skyline-problem.html
Time: O(nlogn)
Space: O(n)
"""
from heapq import *
class ... | true |
309df73c581fbddafb1d952ef24b7d107e445da4 | chunweiliu/leetcode2 | /implement_trie_prefix_tree.py | 1,849 | 4.3125 | 4 | """
Each Trie node has a dict and a flag.
For inserting a word, insert each character to the Trie if the character is not
there yet. For distiguish a word and a prefix, use the '#' symbol.
Trie
(f) (b)
(o) (a)
(o)T (r)T
"""
from collections import defaultdict
class TrieNode(object):
def _... | true |
23c498871baaf75458fb1f6180d7aa9aaa5bf7f0 | premkumar0/30DayOfPython | /Day-12/day_12_Premkumar.py | 648 | 4.28125 | 4 | def linearSearch(n, k, arr):
"""
This function takes k as the key value and linear search
for it if the value is found it returns the index of the key
value else it will return -1
Example:-
n, k = 4, 5
arr = [2, 4, 5, 8]
returns 2
"""
for i in range(n):
if arr[i] == k:
return i
... | true |
a7c25e91839df58225d7978d02a44f3069f4e74d | Wjun0/python- | /day03/01-下标.py | 735 | 4.375 | 4 | # 下标:又称为索引,其实就是数字
# 下标的作用:就是根据下标获取数据的
# 下标的语法格式:
# my_str = "abc"
# my_str[0] => 变量名[下标]
# 下标可以结合range,字符串,列表,元组
my_str = "hello"
# 正数下标取值
result = my_str[3]
print(result)
# 负数下标取值
result = my_str[-2]
print(result)
# 正数下标取值
result = my_str[0]
print(result)
# 负数下标取值
result = my_str[-1]
prin... | false |
ddad14d92093d19c4abad6272676be512523fc47 | Wjun0/python- | /day06/15-高阶函数.py | 1,260 | 4.15625 | 4 | # 高阶函数: 函数的参数或者返回值是一个函数类型,那么这样的函数称为高阶函数
# 学习高阶函数目的: 为高级讲闭包和装饰器做铺垫
# 高阶函数1:函数的参数是一个函数类型
# def show(new_func): # 此时new_func参数是一个函数类型
# print("show函数开始执行了")
# # 调用传入过来的函数
# new_func("人生苦短,我用python!")
#
# print("show函数执行结束了")
#
# # 调用函数的时候进行传参使用匿名函数进行代码的简化
# # 高阶函数结合匿名函数一起使用
# show(lambda msg: print(msg... | false |
7fe0b7f1a2b35d7ee75157b74df3ec7c395c8645 | gabipires/ExerciciosImpactaADS | /media_conjunto_notas.py | 1,105 | 4.40625 | 4 | # Em uma escola, um professor deve realizar três avaliações por semestre. Para o cálculo da nota final, ele pode usar
# três diferentes métodos de cálculo de médias:
# Média aritmética ("a");
# Média ponderada ("p"): nesse caso, o programa deve perguntar também os pesos de cada nota;
# Média harmônica ("h"): pode ser d... | false |
699f261fc02664f070af9158f6a1d158d28f70cc | KuroCharmander/Turtle-Crossing | /player.py | 602 | 4.15625 | 4 | from turtle import Turtle
STARTING_POSITION = (0, -280)
MOVE_DISTANCE = 10
FINISH_LINE_Y = 280
class Player(Turtle):
"""The turtle in the Turtle Crossing game."""
def __init__(self):
"""Initialize the turtle player."""
super(Player, self).__init__("turtle")
self.penup()
self.s... | true |
17ec9865fa01cf14e1a90715110b98138c182093 | lekasankarappan/PythonClasses | /Day2/Userinput.py | 470 | 4.25 | 4 | name =input("Enter your name: ")
print("hey",name)
#input method takes only string so we have to convert into integer
num1=int(input("Enter first num:"))
num2=input("Enter second num:")
print("Addition of",num1,"and",num2,"is",num1+int(num2))
print("subtraction of",num1,"and",num2,"is",num1-int(num2))
print("multiplic... | false |
ddd53c5798d033ce7d85b51b3805aeca263a2ad8 | d1l0var86/Dilovar | /classes/cars.py | 2,200 | 4.5 | 4 |
class Car():
"""This is class to represent a car."""
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
self.color = 'White'
self.odometer_reading = 0
# getter and setter
def get_description(self):
msg = f"Your ca... | true |
66c2a539db2169fc48436f2faff1ff287765d0ff | JagadishJ4661/Mypython | /Numbers.py | 759 | 4.25 | 4 | '''Take 2 numbers from the user, Print which number is 2 digit number and which number is 3 digit number
If it neither, then print the number as it is'''
def entry():
num1 = input("Select any number that you wish.")
num1 = int(num1)
num2 = input("select any number that you wish again.")
num2 = int(num... | true |
0911c018b5024d7dc525ebc285e67ba1d2e2663b | p-ambre/Python_Coding_Challenges | /125_Leetcode_ValidPalindrome.py | 821 | 4.25 | 4 | """
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
Note: For the purpose of this problem, we define empty string as valid palindrome.
Example 1:
Input: "A man, a plan, a canal: Panama"
Output: true
Example 2:
Input: "race a car"
Output: false
"""
clas... | true |
2e74ccb9169f92530d7e4eaac320b0786e94bf5c | p-ambre/Python_Coding_Challenges | /M_6_Leetcode_ZigZagConversion.py | 1,712 | 4.40625 | 4 | """
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows
like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: "PAHNAPLSIIGYIR"
Write the code that will take a string and make this conve... | true |
f14e9ec92efde63bc05a013bcb323be89cd123ec | retroxsky06/Election_Analysis | /Python.practice.py | 931 | 4.125 | 4 | # counties = ["Arapahope", "Denver", "Jefferson"]
# if counties[1] == 'Denver':
# print(counties[1]
# temperature = int(input("What is the temperature outside? "))
# if temperature > 80:
# print("Turn on the AC.")
# else:
# print("oooh you cold boo")
# counties_dict = {"Arapahoe": 422829, "Denver": 46335... | false |
8c09eac5594829eb922e78688f3d91a6378cdd68 | graag/practicepython_kt | /exercise_9.py | 888 | 4.25 | 4 | import random
takes = 0
print("Type 'exit' to end game.")
outer_loop_flag = True
while outer_loop_flag:
#Generate number
number = random.randint(1,9)
print('Try to guess my number!')
takes = 0
while True:
user_input = input("Type your guess: ")
try:
user_input = int(u... | true |
aa88db0d81a38fb2d62e01e69d460c166aa2b22e | pranshu798/Python-programs | /Data Types/Strings/accessing characters in string.py | 277 | 4.1875 | 4 | #Python Program to Access characters of string
String = "PranshuPython"
print("Initial String: ")
print(String)
#Printing first character
print("\nFirst character of String: ")
print(String[0])
#Printing last character
print("\nLast character of String: ")
print(String[-1]) | true |
8e4d2c3b574445d7e36dfb1e6b3726551f7ec4d8 | pranshu798/Python-programs | /Data Types/Strings/string slicing.py | 368 | 4.53125 | 5 | #Python program to demonstrate string slicing
#Creating a string
String = "PranshuPython"
print("Initial String: ")
print(String)
#Printing 3rd to 12th character
print("\nSlicing characters from 3-12: ")
print(String[3:12])
#Printing characters between 3rd and 2nd last character
print("\nSlicing characters between 3r... | true |
7c4808931b9f3a7524eee2d16e53b85d69db4a67 | pranshu798/Python-programs | /Data Types/Sets/Adding elements using add() method.py | 417 | 4.65625 | 5 | #Python program to demonstrate Addition of elements in a Set
#Creating a Set
set1 = set()
print("Initial blank set: ")
print(set1)
#Adding elements and tuple to the Set
set1.add(8)
set1.add(9)
set1.add((6,7))
print("\nSet after Addition of Three elements: ")
print(set1)
#Adding elements to the Set using Iterator
for ... | true |
673bda4cbb55311159f64da91f523a3558a430b8 | pranshu798/Python-programs | /Data Types/Sets/Removing elements using pop() method.py | 275 | 4.3125 | 4 | #Python program to demonstrate Deletion of elements in a Set
#Creating a Set
set1 = set([1,2,3,4,5,6,7,8,9,10,11,12])
print("Initial Set: ")
print(set1)
#Removing element from the Set using the pop() method
set1.pop()
print("\nSet after popping an element: ")
print(set1)
| true |
c61d200009259fbad763fe8583a8345ed949d31e | pranshu798/Python-programs | /Functions/Python classes and objects/Functions can be passed as arguments to other functions.py | 358 | 4.3125 | 4 | # Python program to illustrate functions
# can be passed as arguments to other functions
def shout(text):
return text.upper()
def whisper(text):
return text.lower()
def greet(func):
# storing the function in a variable
greeting = func("Hi, I am created by a function passed as an argument.")
print(... | true |
b6d22fe203e0abb0dc40b9a0221293729a86bf04 | linafeng/Py3 | /part4/function_param.py | 1,193 | 4.3125 | 4 | # -*- coding:utf-8 -*-
"""函数定义的格式"""
def my_func():
print('my func')
def my_func_with_param(p1, p2):
print(p1, p2)
my_func_with_param(1, 2)
# my_func_with_param(1)
# 关键字参数
my_func_with_param(p1=1, p2=2)
# 默认参数 如果调用者没有传值,那么就用默认值,可以不指定名字
# 混合使用时,非默认参数必须在默认参数的前边
def my_function_with_param(name, sex, age=1... | false |
5bcbac676259b19faa8e8f5144105840ceac6c68 | muftring/iu-python | /module-04/Question3.py | 640 | 4.125 | 4 | #!/usr/bin/env python
#
# Michael Uftring, Indiana University
# I590 - Python, Summer 2017
#
# Assignment 4, Question 3
#
# Write a program that calculates the numeric value of a single name
# provided as input. This will be accomplished by summing up the values
# of the letters of the name where ’a’ is 1, ’b’ is 2, ... | true |
0ec8e80b01fbf1ec69a3b8afe1086415c13ecb23 | muftring/iu-python | /module-03/Question2_2.py | 633 | 4.53125 | 5 | #!/usr/bin/env python
#
# Michael Uftring, Indiana University
# I590 - Python, Summer 2017
#
# Assignment 3, Question 2.2
#
# Given the length of two sides of a right triangle: the hypotenuse, and adjacent;
# compute and display the angle between them.
#
import math
def main():
print("Angle between hypotenuse an... | true |
932a6b227d1127dbdfa2b4517c92b0b7873a8bed | muftring/iu-python | /module-04/Question1.py | 519 | 4.5625 | 5 | #!/usr/bin/env python
#
# Michael Uftring, Indiana University
# I590 - Python, Summer 2017
#
# Assignment 4, Question 1
#
# Write a program that takes an input string from the user and prints
# the string in a reverse order.
#
def main():
print("Print a string in reverse!")
forward = input("Please enter a str... | true |
da8f74d891428c8fd90e7a68b7037c3cf5c8ab4c | muftring/iu-python | /module-07/Question4.py | 1,647 | 4.28125 | 4 | #!/usr/bin/env python3
#
# Michael Uftring, Indiana University
# I590 - Python, Summer 2017
#
# Assignment 7, Question 4
#
# Display the sequence of prime numbers within upper and lower bounds.
#
import math
#
""" isPrime(n): checks whether `n` is prime using trial division approach (unoptimized)"""
#
def isPrime(n):... | true |
13e22b088fcf09564ac82f25c775564f106310d6 | Dadsh/PY4E | /py4e_08.1.py | 555 | 4.5625 | 5 | # 8.4 Open the file romeo.txt and read it line by line. For each line, split the
# line into a list of words using the split() method. The program should build a
# list of words. For each word on each line check to see if the word is already
# in the list and if not append it to the list. When the program completes, so... | true |
620bdd6eaeea894aaaf0abc6b716309a907ae181 | Dadsh/PY4E | /py4e_13.9.py | 2,565 | 4.34375 | 4 | # Calling a JSON API
# In this assignment you will write a Python program somewhat similar to
# http://www.py4e.com/code3/geojson.py. The program will prompt for a location,
# contact a web service and retrieve JSON for the web service and parse that
# data, and retrieve the first place_id from the JSON. A place ID is ... | true |
0c078d889ed24a1de6b020b99ebd2456814c2de6 | RobertoGuzmanJr/PythonToolsAndExercises | /Algorithms/KthLargest.py | 1,391 | 4.125 | 4 | """
This is an interview question. Suppose you have a list of integers and you want to return the kth largest. That is,
if k is 0, you want to return the largest element in the list. If k is the length of the list minus 1, it means that
you want to return the smallest element.
In this exercise, we want to do this... | true |
2760af375842734ef59a5ae070565cf624444ac7 | viethien/misc | /add_digits.py | 513 | 4.21875 | 4 | #!/usr/bin/python3
def main():
print ("Hello this program will add the digits of an integer until a singular digit is obtained")
print ('For example 38 -> 3+8 = 11 -> 1+1 = 2. 2 will be returned')
number = input('Enter an integer value: ')
print (number + ' will reduce to ' + str(addDigits(number)))
def addDigits... | true |
b5d527bb74efdb554058338f8ce82a1616508510 | fedoseev-sv/Course_GeekBrains_Python | /lesson_2/hw_2_3.py | 910 | 4.4375 | 4 | '''
Пользователь вводит месяц в виде целого числа от 1 до 12. Сообщить к какому времени года
относится месяц (зима, весна, лето, осень). Напишите решения через list и через dict.
'''
numberMonth = int(input("Введите номер месяца (число от 1 до 12): "))
listMonth = ['зима', 'зима', 'весна', 'весна', 'весна', 'лето', '... | false |
94445c25ddef249f32f33e8df682506a3d12225e | fedoseev-sv/Course_GeekBrains_Python | /lesson_2/hw_2_1.py | 690 | 4.3125 | 4 | '''
Создать список и заполнить его элементами различных типов данных. Реализовать скрипт проверки типа данных каждого
элемента. Использовать функцию type() для проверки типа. Элементы списка можно не запрашивать у пользователя,
а указать явно, в программе.
'''
line = [1, 2, 4.23, True, False, "string", -3]
print("Спис... | false |
9a2195053cd1dc6597b060e070c10db9a81f67ca | titanspeed/PDX-Code-Guild-Labs | /Python/frilab.py | 2,639 | 4.21875 | 4 | phonebook = {
'daniels': {'name': 'Chase Daniels', 'phone':'520.275.0004'},
'jones': {'name': 'Chris Jones', 'phone': '503.294.7094'}
}
def pn(dic, name):
print(phonebook[name]['name'])
print(phonebook[name]['phone'])
def delete():
correct_name = True
while correct_name == True:
delete_name = ... | true |
19b8fc27ad30e6e45a0161f1fcbc27ce9871d51e | Tejas199818/Python | /fibonacci.py | 241 | 4.1875 | 4 | def fibonacci():
a=0
b=1
sum=0
x=int(input("Enter the range:"))
print(a,end=" ")
print(b,end=" ")
for i in range(2,x):
sum=a+b
a=b
b=sum
print(sum,end=" ")
print()
fibonacci()
| false |
6692ab95a0df6ab106565a063d1f0fc9ad4806dd | MeenaShankar/python_project_aug5 | /remove_item_tuple.py | 241 | 4.1875 | 4 | tuplex1=(1,2,3,5,6,7,9)
tup2=('a','b','c','d','r')
print("Before removing tuple:",tuplex1)
tuplex1=tuplex1[:2]+tuplex1[3:]
print(tuplex1)
print("Before removing tuple:",tup2)
list1=list(tup2)
list1.remove('d')
tup2=tuple(list1)
print(tup2)
| false |
9c2f772a2c0188cc845f8721c62069524fbd0a5c | AsbelNgetich/python_ | /fundamentals/functions/functions_Intermediate/list_iteration.py | 1,088 | 4.46875 | 4 | # Create a function iterateDictionary(some_list) that, given a list of dictionaries,
# the function loops through each dictionary in the list and prints each key and the
# associated value. For example, given the following list:
students = [
{'first_name': 'Michael', 'last_name' : 'Jordan'},
{'firs... | false |
805efe0ecd2da5e8e225c295f2a34d0902ebcd27 | thepavlop/code-me-up | /shapes.py | 1,362 | 4.28125 | 4 | """
This program calculates the area and perimeter of a given shape.
Shapes: 'rectangle', 'triangle'.
"""
shape = input("Enter a shape (rectangle/triangle): ")
# User input is 'rectangle':
if shape == 'rectangle':
# Ask user for a height and width of the rectangle
i1 = input ('Enter the width of th... | true |
ccfff65f4fb425d4fd4e5246c9f6a65e0b518d6b | nwgdegitHub/python3_learning | /12-下标.py | 840 | 4.15625 | 4 | str = 'abcdefg'
print(str[0])
print(str[1])
# 序列[开始位置下标:结束位置下标:步长]
# 步长正负数都行 默认是1 为负数表示倒着选 结尾不包含
# 不写开始 默认从0开始
# 不写结尾 默认选到最后
# 下标-1表示最后一位 -2表示倒数第二位
str1 = "0123456789"
print(str1[2:5:1])
print(str1[2:5:2])
print(str1[2:5]) #默认步长1
print(str1[:5]) #默认结束下标5
print(str1[2:])
print(str1[:])
print(str1[:-1]) # 在头部开始 -1处结束 ... | false |
a344c5d1b7a3457d5c63bf45306f8d0106031a60 | hpisme/Python-Projects | /100-Days-of-Python/Day-3/notes.py | 380 | 4.4375 | 4 | """Conditionals / Flow Control"""
#If statement
if 2 > 1:
print('2 is greater than 1')
#Adding an else statement
if 3 < 2:
print('This won\'t print')
else:
print('This will print!')
#Adding an elif statement
x = 0
if x == 1:
print('This will print if x is 1.')
elif x == 2:
print('This will print if x i... | true |
bd07ed2c24d4cea71914d5ff91109bd3d0c8bd7e | mohitkh7/DS-Algo | /Assignment1/1divisible.py | 319 | 4.3125 | 4 | # 1.WAP to check the divisibilty
def isDivisible(a,b):
#To check whether a is divisible by b or not
if a%b==0:
return True; #Divisible
else:
return False; #Non Divisible
num=int(input("Enter Any Number : "))
div=int(input("Enter Number with which divisibilty is to check : "))
print(isDivisible(num,div));
| true |
29fad1f70a64fb15378c74e16b1bade6f3b12a7e | Wil10w/Beginner-Library-2 | /Exam/Check Code.py | 1,262 | 4.21875 | 4 | #Write a function called product_code_check. product_code_check
#should take as input a single string. It should return a boolean:
#True if the product code is a valid code according to the rules
#below, False if it is not.
#
#A string is a valid product code if it meets ALL the following
#conditions:
#
# - It must be ... | true |
41a221f4719dc573f0e7949b0b9b8e8d0ee7e250 | Wil10w/Beginner-Library-2 | /Loops/if-if-else movie ratings.py | 542 | 4.3125 | 4 | rating = "PG"
age = 8
if rating == 'G':
print('You may see that movie!')
if rating == "PG":
if age >= 8:
print("You may see that movie!")
else:
print("You may not see that movie!")
if rating == "PG-13":
if age >= 13:
print("You may see that movie!")
else:
print('You may not see that movie!')
if rating... | true |
2da45f99244731fc4207270d95c5ed11a7a604b3 | Wil10w/Beginner-Library-2 | /Practice Exam/Release Date.py | 2,414 | 4.375 | 4 | #Write a function called valid_release_date. The function
#should have two parameters: a date and a string. The
#string will represent a type of media release: "Game",
#"Movie", "Album", "Show", and "Play".
#
#valid_release_date should check to see if the date is
#a valid date to release that type of media according to... | true |
420ea8f4d52a9be071420d6f54514a41a13a9473 | kiyalab-tmu/learn-python | /2_functions/Team_top_function_caculate.py | 562 | 4.15625 | 4 | def Caculate(num1,num2):
sum = num1 + num2
difference = num1 - num2
product = num1*num2
quotient = num1/num2
remainder = num1%num2
print(sum)
print(type(sum))
print(difference)
print(type(difference))
print(product)
print(type(product))
print(quotient)
print(type... | false |
1e284b683528ded1a80e40d9b7889999982d518d | kiyalab-tmu/learn-python | /4_sort/kinoshita_quicksort.py | 1,340 | 4.15625 | 4 |
import copy
def quicksort(list_):
sorted_list = copy.copy(list_)
recursive_quicksort(sorted_list, 0, len(sorted_list))
return sorted_list
def recursive_quicksort(list_, start, stop):
if stop - start <= 1:
return
med_idx = (start + stop - 1) // 2
pivot = list_[med_idx]
i = start
... | false |
cf730580af6dc9754abfcb9a1e58d63ded705689 | HarryBMorgan/Special_Relativity_Programmes | /gamma.py | 776 | 4.1875 | 4 | #Calculation of gamma factor in soecial relativity.
from math import sqrt
#Define a global variable.
c = 299792458.0 #Define speed of light in m/s.
#Define a function to calculate gamma.
def gamma(v):
if v < 0.1 * c: #If v is not in order of c, assume it's a decimal and * c.
v *= c
return 1 / sqrt(1... | true |
b6182a34f51f0393626723f33cd60cfedfef5e5a | nagaprashanth0006/code | /python/remove_duplicate_chars_from_string.py | 1,131 | 4.125 | 4 | from collections import Counter
str1 = "Application Development using Python"
# Constraints:
# Capital letters will be present only at the beginning of words.
# Donot remove from start and end of any word.
# Duplicate char should match across whole string.
# Remove not only the duplicate char but also all of its occur... | true |
88d3b4710b222d0787a96f7f4d8216f38e02f8fd | pablocorbalann/codewars-python | /5kyu/convert-pascal-to-snake.py | 442 | 4.21875 | 4 |
# Complete the function/method so that it takes CamelCase string and returns the string in snake_case notation.
# Lowercase characters can be numbers. If method gets number, it should return string.
def to_underscore(string):
s = ''
for i, letter in enumerate(str(string)):
if letter != letter.lower():... | true |
8fa85afc1a4b7f76c842b18c236e8b2e740b91b9 | ahirwardilip/python-programme | /27feb.py | 1,295 | 4.21875 | 4 | #While loop(syntax):-
# while <exp>:
# ===
# ===
#Print 1 2 3 4 5.
'''
i=1
while i<=5:
print(i)
i+=1
'''
#Write a program to print mathematical table of any number.
'''
a=int(input("Enter Number:"))
i=1
while i<=10:
print(n,"*",i,"=",n*i)
i+=1
'''
... | false |
69be0a9c8b24ae5882c636d363481f7a9be43775 | jonahp1/simple-bill-splitter | /Mainguy.py | 1,480 | 4.3125 | 4 | attendees = int(input("How many people are splitting the bill? : "))
bill_total = float(input("How much is the bill total (before tax)? (DO NOT INCLUDE $) : "))
tax_total = float(input("How much is the Tax total? (DO NOT INCLUDE $) : "))
tax_percentage = (tax_total / bill_total) # useful for math
effective_tax_percent... | true |
fafeba6ba874c5d7475aa7bf616d2843036d0915 | lappazos/Intro_Ex_11_Backtracking | /ex11_sudoku.py | 2,894 | 4.1875 | 4 | ##################################################################
# FILE : ex11_sudoku.py
# WRITERS : Lior Paz,lioraryepaz,206240996
# EXERCISE : intro2cs ex11 2017-2018
# DESCRIPTION : solves sudoku board game with general backtracking
##################################################################
from math impo... | true |
1c2c4471e04af2ea5b94eba3ddd1d7ed884b5b0d | NeoWhiteHatA/all_my_python | /march/count_coin.py | 1,356 | 4.125 | 4 | print('Вам необходимо ввести небольшое количество монет')
print('Цель - получить в титоге один рубль')
print('имеются монеты достоинством в 5 копеекб 10 копеек и 50 копеек')
nominal_one_coin = 5
nominal_two_coin = 10
nominal_three_coin = 50
coin_one = int(input('Введите количество монет достоинством 5 копеек:'))
coi... | false |
253df67cfa8bb387a919431b0ff0723e1565fbad | nomura-takahiro/study | /test/test8.py | 882 | 4.125 | 4 |
# test8
#①
tmp = "カミュ"
for i in range(3):
print(tmp[i])
#②
"""
tmp = input("What? >> ")
tmp2 = input("Who? >> ")
print("私は昨日{}を書いて、{}に送った!".format(tmp,tmp2))
"""
#③
text = "aldous Huxley was born in 1894."
print(text.capitalize())
#④
text = "どこで? だれが? いつ?"
print(text)
print(text.split(" "))
#⑤
text =["The","... | false |
640dbf5ad0fd5c12bc351f06cdf91bbe1555969b | Fainman/intro-python | /random_rolls.py | 860 | 4.125 | 4 | """
Program to simulate 6000 rolls of a die (1-6)
"""
import random
import statistics
def roll_die(num):
"""
Random roll of a die
:param num: number of rolls
:return: a list of frequencies
Index 0 maps to 1
.
.
.
Index 5 maps to 6
"""
frequency = [0] * 6 # Initial values ... | true |
a7879e0e1d5f1946447ac1403e55bf7b3afbdae2 | shivanshthapliyal/Algorithms | /day-1-sorting/merge-sort.py | 924 | 4.1875 | 4 | # Author => Shivansh Thapliyal
# Date => 1-Jan-2020
def merge(left_arr,right_arr):
output=[]
#adding to output till elements are found
while left_arr and right_arr:
left_arr_item = left_arr[0]
right_arr_item = right_arr[0]
if left_arr_item < right_arr_item:
output.append(left_arr_item)
left_arr.pop(0... | false |
7051a6b21b2b930fb09b50df114bc9d66607c7c7 | shaunakgalvankar/itStartedInGithub | /ceaserCipher.py | 1,287 | 4.375 | 4 | #this program is a ceaser cipher
print("This is the ceaser cipher.\nDo You want to encode a message or decode a message")
print("To encode your message press e to decode a messge press d")
mode=raw_input()
if mode=="e":
#this is the ceaser cipher encoder
original=raw_input("Enter the message you want to encode:")
en... | true |
f5936be33f6ea652325db7c9b8c688b11a8e9e53 | imclab/DailyProgrammer | /Python_Solutions/115_easy.py | 1,220 | 4.40625 | 4 | # (Easy) Guess-that-number game!
# Author : Jared Smith
#A "guess-that-number" game is exactly what it sounds like: a number is guessed at
#random by the computer, and you must guess that number to win! The only thing the
#computer tells you is if your guess is below or above the number.
#Your goal is to write a pr... | true |
2813c58d8faa2d30baa360966965b3082c4cc07a | Hirook4/Santander-Coder-Python | /2.Estruturas Avançadas/1_listas_e_tuplas.py | 1,643 | 4.40625 | 4 | print("Listas")
# Lista vazia
lista_vazia = []
# Listas podem ter diferentes tipos de valores
listamista = [10, "Leonardo", 0.5, True]
# Lista com valores
letras = ["a", "b", "c", "d", "e"]
# Acessamos cada elemento da lista através de um índice entre colchetes
# Os índices começam em 0
print(letras[0])
print(letra... | false |
cddcdda3eef207d3f2911b86f4f2b767d8124669 | Hirook4/Santander-Coder-Python | /2.Estruturas Avançadas/3_strings_II.py | 1,641 | 4.34375 | 4 | print("Strings II")
# Operador de soma (+): concatena (une) 2 strings
palavra1 = "Leo"
palavra2 = "nardo"
palavra3 = palavra1 + palavra2
print(palavra3, "\n")
# Operador de multiplicação * copia uma string 'n' vezes
palavra = "uma"
trespalavras = 3 * palavra
print(trespalavras, "\n")
print(".format()")
# .format() s... | false |
fb21e8080bb297c30402239a1020d1815c0c18aa | bouzou/starter-kit-datascience | /raphael-vignes/Lesson1/string2.py | 2,031 | 4.34375 | 4 | def verbing(s):
if s.__len__() >= 3:
print(s[-3:])
if s[-3:] != 'ing':
s+='ing'
else:
s+= 'ly'
return s
def not_bad(s):
if 'not' in s and 'bad' in s:
a = s.find('not')
b = s.find('bad')
if a < b :
return s[:a] + 'good' +s[b+3:]
return s
# F. ... | false |
3c443065b603371a6cb3733b5c2bcf52f1ab0c5a | NickAlicaya/Graphs | /projects/graph/interview.py | 1,441 | 4.5 | 4 | # Print out all of the strings in the following array in alphabetical order, each on a separate line.
# ['Waltz', 'Tango', 'Viennese Waltz', 'Foxtrot', 'Cha Cha', 'Samba', 'Rumba', 'Paso Doble', 'Jive']
# The expected output is:
# 'Cha Cha'
# 'Foxtrot'
# 'Jive'
# 'Paso Doble'
# 'Rumba'
# 'Samba'
# 'Tango'
# 'Viennese ... | true |
8d5e2833759970a21b7f9175aad9a3f8a9e8d345 | MertTurkoglu/Python_Projects | /Python.projects/hesap_makinesi.py | 664 | 4.125 | 4 | print("hesap makinesi programı")
print("Toplama işlemi için +\n"
"çıkarma işlemi için -\n"
"çarpma işlemi için *\n"
"bölme işlemi için / 'e basın "
)
sayi1=int(input("bir sayi gir"))
sayi2=int(input("bir sayi gir"))
işlem=input("işlemi girin")
if(işlem=="+"):
print("{} ... | false |
8b7bbd9cc3d0dbb4ccddab9ff8865866f5d03aa0 | kochsj/python-data-structures-and-algorithms | /challenges/insertion_sort/insertion_sort.py | 416 | 4.34375 | 4 | def insertion_sort(list_of_ints):
"""Sorts a list of integers 'in-place' from least to greatest"""
for i in range(1, len(list_of_ints)): # starting outer loop at index 1
j = (i - 1)
int_to_insert = list_of_ints[i]
while j >= 0 and int_to_insert < list_of_ints[j]:
list_o... | true |
4e1d46b1dd5b16f5e316dfbaedc8fbf5ab674464 | kochsj/python-data-structures-and-algorithms | /challenges/quick_sort/quick_sort.py | 1,301 | 4.34375 | 4 | def quick_sort(arr, left_index, right_index):
if left_index < right_index:
# Partition the array by setting the position of the pivot value
position = partition(arr, left_index, right_index)
# Sort the left_index
quick_sort(arr, left_index, position - 1)
# Sort the right_ind... | true |
1eda04501f801072b4c16c2f2450cbcc50765a61 | sdmiller93/Summ2 | /Zed/27-30/ex29studydrills.py | 468 | 4.5625 | 5 | # 1. The if prints the included statement if returned True.
# 2. The code needs to be indented to make it known that the print statement is included with that if statement, it's a part of it.
# 3. If it's not indented, it isn't included with the if statement and will print regardless of the truth of the if statement.... | true |
de260d1be0cecc69226b792d1ff4d9bf96f5dd8b | sdmiller93/Summ2 | /Zed/04-07/ex6.py | 1,015 | 4.5625 | 5 | # strings are pieces of text you want to export out of the program
# assign variables
types_of_people = 10
x = f"There are {types_of_people} types of people."
# assign more variables
binary = "binary"
do_not = "don't"
# write string with embedded variables
y = f"Those who know {binary} and those who {do_not}"
# pr... | true |
2b236c42e6802c261ef1c6427ef075313ace5667 | maiareynolds/Unit-3 | /warmUp9.py | 214 | 4.15625 | 4 | #Maia Reynolds
#3/1/18
#warmUp8.py - capitalize vowels
text=input("Enter text: ")
for ch in text:
if ch=="a" or ch=="e" or ch=="i" or ch=="o" or ch=="u":
print(ch.upper())
else:
print(ch.lower()) | false |
b7edfa22328e165b825e5834edf64fe96df04701 | mateuszkanabrocki/LPTHW | /ex19.py | 1,071 | 4.125 | 4 | # defining a function with 2 arguments
def cheese_and_crackers(chesse_count, boxes_of_crackers):
#print(">>> START chesse_count=:", chesse_count, "boxes_of_crackers:", boxes_of_crackers)
print(f"You have {chesse_count} cheeses.")
print(f"You have {boxes_of_crackers} boxes of crackers.")
print("Man, that... | true |
a57b8ccb2942c7c26903d406f6d8343ba0db2ebe | mateuszkanabrocki/LPTHW | /ex16.py | 1,071 | 4.25 | 4 | # import the argv feature from the system module
from sys import argv
# assign the input values to the variables (strings)
script, filename = argv
print(f"We're going to erase {filename}.")
print("If you don't want that hit Ctrl-C (^C).")
print("If you do want that hit RETURN.")
input("?")
print("Opening the file.... | true |
e8d8bb9d41eeffc6f68266469abd9f59f790bedb | vaibhavyesalwad/Python-Bootcamp-Programs | /MathFunc.py | 595 | 4.15625 | 4 | import math as m
def is_prime(num):
if num == 1:
return '1 is neither prime nor composite'
else:
for i in range(2, num//2+1):
if num % i == 0:
return False
else:
return True
print(dir(m))
print(m.pow(2,4))
print(m.sin(m.pi/6))
print(m.cos(m.pi/3)... | false |
921336e98aac123fae5f1760358f604ec7213112 | vaibhavyesalwad/Python-Bootcamp-Programs | /TaylorsSeries.py | 784 | 4.1875 | 4 | import math
def sin_term(x,n):
return (-1)**(n-1)*(x**(2*n-1))/math.factorial(2*n-1)
def cos_term(x,n):
return (-1)**(n-1)*(x**(2*n-2))/math.factorial(2*n-2)
def take_input():
angle = int(input('Enter angle in degrees:'))
angle_radians = angle*3.14/180 # = math.radians(angle)
terms = int(input(... | false |
5003672f108deea087e056411ee5a08de4cd2f54 | Nakshatra-Paliwal/Shining-Star | /Area of the Triangle.py | 229 | 4.15625 | 4 | Base = float(input("Please enter the value of Base of the Triangle : "))
Height = float(input("Please enter the value of Height of the Triangle : "))
Area = (1/2 * Base * Height)
print("Area of the Triangle is " + str(Area))
| true |
38df5b7ab5326cbedddc379d8d931d7ddb1c43b5 | Nakshatra-Paliwal/Shining-Star | /Calculate Area of Two Triangles and Compare the Smaller One.py | 849 | 4.25 | 4 | """
Write a code to calculate Area of two triangles.
And compare these areas, and
print which triangle has the greater area
Note : Take input from the user as Base
and Height values for two triangles
"""
Base1 = float(input("Please enter the value of Base of the 1st Triangle : "))
Height1 = float(input("Plea... | true |
0a45277982cb8bdf9f34b437b34ed5c017ece3d4 | Nakshatra-Paliwal/Shining-Star | /Take two Numbers as Input and Print Their Addition.py | 252 | 4.1875 | 4 | #Write a code to take two numbers as input and print their Addition
num1 = int(input("Write a Number 1 : "))
num2 = int(input("Write a Number 2 : "))
Multiply = num1 + num2
print()
print("The Addition of Both the Number is " + str(Multiply))
| true |
186b27c411a681ee1a704dc53d5ecc23ed2746bf | Nakshatra-Paliwal/Shining-Star | /Voice Chatbot about sports input by text.py | 2,142 | 4.28125 | 4 | """
Create a Voice Chatbot about sports. Ask the user to type the name of any
sport. The Chatbot then speaks about interesting information about that
specific sport.
"""
import pyttsx3
engine=pyttsx3.init()
print("Welcome !! This is a Voice Chatbot about sports.")
print("Please choose the Operation... | true |
16dd605a3f9efc51f76e2accb45470bcfdb9f767 | Nakshatra-Paliwal/Shining-Star | /Write a program for unit converter..py | 1,166 | 4.40625 | 4 | """
Write a program for unit converter. A menu of operations is displayed to the user as:
a. Meter-Cm
b. Kg-Grams
c. Liter-Ml
Ask the user to enter the choice about which conversion to be done. Ask user to enter the
quantity to be converted and show the result after conversion. Ask user whether he wish to
cont... | true |
3fe609269efbfddd1c814b1ab0091b868ddb73d2 | Nakshatra-Paliwal/Shining-Star | /Create a 'guess the password' game (3 attempts).py | 410 | 4.4375 | 4 | """
Create a 'guess the password' game , the user is given 3 attempts
to guess the password. Set the Password as “TechClub!!”
"""
attempt=1
while(attempt<=3):
password=input("Enter the Password : ")
if password=="TechClub!!":
print("You are Authenticated!!")
break
else:
a... | true |
6437450be62ab8b399334915dc464a9057311eac | thuyvyng/CS160 | /labs/lab4/lab4.py | 242 | 4.15625 | 4 | stars = int(input("How many stars do you want? "))
while (stars % 2 == 0):
stars = int(input(" Enter an odd number "))
for x in range(stars +1):
if x % 2 == 0:
continue
space = (stars-x)//2
print(" " * space + "*" * x + " " * space)
| false |
36de8f66b1996b5d42e96687cf91448b3fb500d2 | Akshaypokley/pythonStudy | /src/Study/Strings/stringreplace.py | 314 | 4.15625 | 4 | s1="my name is khan"
ReplaceS1=s1.replace('khan','Akshay')
print(ReplaceS1)
print(ReplaceS1.upper())
print (ReplaceS1.lower())
print(ReplaceS1.capitalize())
print("+".join(s1))
print("@@@@@@@Split@@@@@@@@@")
print(ReplaceS1.split(" "))
print(ReplaceS1.split("a"))
x = "Guru99"
x = x.replace(x,"Python")
print(x) | false |
f48e81bf8709003a354a5e6ca37a22e172c6dbaa | astavnichiy/AIAnalystStudy | /Python_algorithm/Lesson2/les_2_task_3.py | 613 | 4.1875 | 4 | """
3. Сформировать из введенного числа обратное по порядку входящих в него
цифр и вывести на экран. Например, если введено число 3486,
то надо вывести число 6843.
"""
number2 = input('Введите натуральное число:')
new_number2 = ''
try:
int(number2)
except:
print ('Хреновое число')
i ... | false |
bfe2ac7fb508f2fcca6192a35c893a453f2053f4 | brgyfx/Dice-Simulator | /DiceRollSimNew.py | 425 | 4.15625 | 4 | #DiceRollingSimulator
import random
import time
dice = random.randint(0,9)
count = 0
count_to = 10
response = input("Would you like to roll a dice? ")
if response == "yes":
times = int(input("How many times would you like to roll a dice? "))
count_to = times
while response == "yes" and count < count_t... | true |
7e835b8fa5ce87b359bc01a6d0be592c52efc324 | javvidd/gitProject | /functions_homework.py | 1,441 | 4.3125 | 4 | # homework
# chapter 8-1 to 8-5
def display_message():
print("im learning chapter 8 functions")
display_message()
def favourite_book(title):
print(f"one of my favourite books is {title.title()}")
favourite_book("alice in wonderland")
def make_shirt(size, text):
print(f"customised shirt is \"{size.upper... | false |
39f1439582a56031c247a91b4574614555e904fb | NieMandX/Algorithms | /lesson2_task8.py | 1,354 | 4.34375 | 4 | # Lesson 2 Task 8 -rus-
# Посчитать, сколько раз встречается определенная цифра
# в введенной последовательности чисел. Количество вводимых
# чисел и цифра, которую необходимо посчитать,
# задаются вводом с клавиатуры.
def digit_calc (dig, number):
amnt = 0
for i in range(len(str(number))):
... | false |
1738b878939eabefdeb29a0c0be498d6c2b9981a | mridulpant2010/leetcode_solution | /OOAD/ss_function_injection.py | 797 | 4.1875 | 4 |
'''
1- creating function
2- understanding static function
more on static-method:
1- static-method are more bound towards a class rather than its object.
2- they can access the properties of a class
3- it is a utility function that doesn't need access any properties of a class but makes sense that it belong to a clas... | true |
a41a38938250fe4514ee0db952f31f953422694f | mridulpant2010/leetcode_solution | /tree/right_view_tree.py | 1,102 | 4.125 | 4 |
'''
given a tree you need to print its right view
'''
from collections import deque
from typing import List
class TreeNode:
def __init__(self, val, left=None, right=None):
self.val=val
self.left=left
self.right=right
def tree_right_view(root):
res=[]
q=deque()
q.append(roo... | true |
ce9f4fd6558c9982c815c90ce40cf53b6540405f | chandhukogila/Pattern-Package | /Alphabets/Capital_Alphabets/J.py | 618 | 4.125 | 4 | def for_J():
"""We are creating user defined function for alphabetical pattern of capital J with "*" symbol"""
row=7
col=5
for i in range(row):
for j in range(col):
if i==0 or (j==2 and i<6)or i-j==5:
print("*",end=" ")
else:
print... | false |
7146a77b3df6dcad47002cf0701bf8f121b99f21 | chandhukogila/Pattern-Package | /Numbers/zero.py | 738 | 4.1875 | 4 | def for_zero():
"""We are creating user defined function for numerical pattern of zero with "*" symbol"""
row=7
col=5
for i in range(row):
for j in range(col):
if ((i==0 or i==6)and j%4!=0) or ((i==1 or i==2 or i==4 or i==5 or i==3)and j%4==0) or i+j==5:
print("*",en... | false |
a9a2ae4248ac36eb0af0b21b924967595f412b0b | deloschang/project-euler | /005/problem5.py | 782 | 4.125 | 4 | #!/usr/bin/env python
# 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
# What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
def factorize(x):
# < 11 don't need to be checked because 12-20 implicitly c... | true |
f0236977e3d6ad99197048b5dc077bbb9263d30d | ssw1991/Python-Practice | /Module 1 - Shilo Wilson/Level 1.4 - Shilo Wilson/1.4.2.py | 891 | 4.15625 | 4 | # coding=utf-8
"""
Name: Shilo S Wilson
Exercise: 1.4.2
Find the length of each list in part b of the previous exercise.
Then, verify that the lengths of all three lists indeed add up to the length of the full list in part a.
"""
import numpy as np
def Mortgages(N):
"""
A function that returns an unsorte... | true |
7a156ad4ed677a8315993eb17d0d5f2ccef94f4b | ssw1991/Python-Practice | /Module 3 - Shilo Wilson/Level 3.2/3.2.1 and 3.2.2/main.py | 590 | 4.34375 | 4 | """
Author: Shilo Wilson
Create a list of 1000 numbers. Convert the list to an iterable and iterate through it.
The instructions are a bit confusing, as a list is already an iterable. Is the intention
to create an iterator to iterate through the list?
"""
def main():
print('========== Exercise 3.2.1 and 3... | true |
3d617c48812fd4612ea2a082478efb76ab1b129f | ssw1991/Python-Practice | /Module 3 - Shilo Wilson/Level 3.1/3.1.3/main.py | 1,542 | 4.65625 | 5 | """
Author: Shilo Wilson
Create a regular function (called reconcileLists) that takes two separate lists as its parameters. In this example,
List 1 represents risk valuations per trade (i.e. Delta) from Risk System A and List 2 has the same from Risk System B.
The purpose of this function is to reconcile the two li... | true |
8abf8fd8b5e06481ed24e75fa6bcbc24cd641f0f | chi42/problems | /hackerrank/is_binary_search_tree.py | 1,167 | 4.125 | 4 | #!/usr/bin/python
#
# https://www.hackerrank.com/challenges/ctci-is-binary-search-tree?h_r=next-challenge&h_v=zen
class node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def is_valid(data, max_data, min_data):
if max_data and data >= max_data:
return False
if min_data and... | true |
205240df57c2ac6902f16b236c989bef38b7680d | K3666/githubtest | /solution-1.py | 220 | 4.3125 | 4 | Number = int(input("Entre Number :"))
if Number % 3 == 0 and Number % 2 == 0 :
print("BOTH")
elif Number % 3 == 0 or Number % 2 == 0 :
print("ONE")
elif Number % 3 == 1 and Number % 2 == 1 :
print("NEITHER")
| false |
72ee90d35585f110e01e929cbfdd27115f14aa49 | ztwilliams197/ENGR-133 | /Python/Python 2/Post Activity/Py2_PA_Task1_will2051.py | 2,595 | 4.28125 | 4 | #!/usr/bin/env python3
'''
===============================================================================
ENGR 133 Program Description
Takes inputs for theta1 and n1 and outputs calculated values for theta2
d3 and critTheta
Assignment Information
Assignment: Py2_PA Task 1
Author: Za... | true |
7b56a008f94895e31074dd7fc25a5ca111e70c02 | adrientalbot/lab-refactoring | /your_code/Guess_the_number.py | 1,986 | 4.1875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
import random
import sys
# In[100]:
def condition_to_play_the_game(string="Choose any integer between 1 and 100. Your number is "):
your_number = input(string)
if your_number.isdigit():
your_number = int(your_number)
if your_number > 100:
... | true |
aa3410e31edc7ce603dbf85bff00a80195b619d1 | pcmason/Automate-the-Boring-Stuff-in-Python | /Chapter 4 - Lists/charPicGrid.py | 1,077 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 30 01:58:47 2021
@author: paulmason
"""
#print out a grid of characters with a function called charPrinter
#create the that prints out every element in a 2D list
def charPrinter(givenChar):
#loop through the column
for y in range(len(givenC... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.