blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
23ab00fb5704520dc6bd99fabd951f3fdff77f8c | wickyou23/python_learning | /python3_learning/operators.py | 251 | 4.15625 | 4 | #####Python operators
# x1 = 3/2 #float div
# x2 = 3//2 #interger div
# x3 = 3**2
# x4 = 6%2
# print(x1, x2, x3, x4)
#####Operator Precedence
# x5 = 1+3*2
# print(x5)
#####Augmented Assignment Operator
# x6 = 1
# x6 += 1
# print(x6) | false |
366ffad8460a65261f57e99b28789147a915e3d0 | TimothyCGoens/Assignments | /fizz_buzz.py | 613 | 4.21875 | 4 | print("Welcome back everyone! It's now time for the lighting round of FIZZ or BUZZ!")
print("""For those of you following at home, it's simple. Our contestants need
to give us a number that is either divisible by 3, by 5, or by both!""")
name = input("First up, why don't you tell us your name? ")
print(f"""Well {name... | true |
f2ce2ad7ad3703bb800c7fc2dfd79b6bab76d491 | thedern/algorithms | /recursion/turtle_example.py | 835 | 4.53125 | 5 |
import turtle
max_length = 250
increment = 10
def draw_spiral(a_turtle, line_length):
"""
recursive call example:
run the turtle in a spiral until the max line length is reached
:param a_turtle: turtle object "charlie"
:type a_turtle: object
:param line_length: length of line to draw
:t... | true |
bc87f755b34064cc614504c41092be4765251e03 | njg89/codeBasics-Python | /importSyntax.py | 1,007 | 4.15625 | 4 | # Designate a custom syntax for a default function like th example 'statistics.mean()' below:
'''
import statistics as stat
exList = [5,3,2,9,7,4,3,1,8,9,10]
print(stat.mean(exList))
'''
# Only utilize one function, like the 'mean' example below:
'''
from statistics import mean
exList2 = [3,2,3,5,6,1,0,3,8... | true |
66b5826912e87770d5e305e93f2faacba745ac7e | CleonPeaches/idtech2017 | /example_02_input.py | 499 | 4.15625 | 4 | # Takes input from user and assigns it to string variable character_name
character_name = input("What is your name, adventurer? ")
print("Hello, " + character_name + ".")
# Takes input from user and assigns it to int variable character_level
character_level = (input("What is your level, " + character_name + "? "))
# ... | true |
4e17d157d0abc7d7f36a454b3a3fe62887e98cc4 | ian7aylor/Python | /Programiz/GlobKeyWrd.py | 654 | 4.28125 | 4 |
#Changing Global Variable From Inside a Function using global
c = 0 # global variable
def add():
global c
c = c + 2 # increment by 2
print("Inside add():", c)
add()
print("In main:", c)
#For global variables across Python modules can create a config.py file and store global variables there
#Using a Glo... | true |
b220370ca9ffd82ea7189e0a5167c9bae233f223 | ian7aylor/Python | /Programiz/For_Loop.py | 1,260 | 4.28125 | 4 | #For Loop
'''
for val in sequence:
Body of for
'''
# Program to find the sum of all numbers stored in a list
# List of numbers
numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]
# variable to store the sum
sum = 0
# iterate over the list
#iterates through list of numbers and sums them together
for val in numbers:
sum = ... | true |
1c14df00fa1f6304216b8fd1d7a28186610c3182 | rishabmehrotra/learn_python | /Strings and Text/ex6.py | 879 | 4.625 | 5 | #use of f and .format()
"""F-strings provide a concise and convenient way to embed python expressions inside string literals for formatting.
f'some stuff here {avariable}'"""
#.format()
""" The format() method formats the specified value(s) and insert them inside the string's placeholder.
txt1 = "My name is {fname}, I... | true |
806969204ed0adab1f751fc6c3aa6ac07eb4cf7d | DonaldButters/Module5 | /input_while/input_while_exit.py | 1,300 | 4.28125 | 4 | """
Program: input_while_exit.py
Author: Donald Butters
Last date modified: 9/25/2020
The purpose of this program is prompt for inputs between 1-100 and save to list.
Then the program out puts the list
"""
#input_while_exit.py
user_numbers = []
stopvalue = 404
x = int(input("Please Enter a number between 1 and ... | true |
8fe8605311210ea18e381eae1957c3b282f026f6 | kzk-maeda/algorithm_and_data_structure | /python/sort/bubble_sort.py | 495 | 4.3125 | 4 | from typing import List
# Listのソート範囲の最後尾が最大値となるよう、繰り返し比較処理を実行する
def bubble_sort(numbers: List[int]) -> List[int]:
len_numbers = len(numbers)
for i in range(len_numbers):
for j in range(len_numbers - 1 - i):
if numbers[j] > numbers[j+1]:
numbers[j], numbers[j+1] = numbers[j+1], numbers[j]
re... | false |
c54cbeb7fa6238af2922e6fa980064bc48699791 | q737645224/python3 | /python基础/python笔记/day04/exercise/right_align.py | 1,283 | 4.25 | 4 | # 练习:
# 输入三行文字,让这三行文字依次以20个字符的宽度右对齐输出
# 如:
# 请输入第1行: hello world
# 请输入第2行: aaa
# 请输入第3行: ABCDEFG
# 输出结果如下:
# hello world
# aaa
# ABCDEFG
# 做完上面的题后思考:
# 能否以最长的字符串的长度进行右对齐显示(左侧填充空格)
a = input("请输入第1行: ")
b = input("请输入第2行: ")
c = input("请输入第3行: ")
... | false |
ec8d676308de59e6224af6a8eb1416e5c3978502 | q737645224/python3 | /python基础/python笔记/day09/exercise/print_odd.py | 1,084 | 4.25 | 4 | # 2. 写一个函数,print_odd, 此函数可以传递一个实参,也可以传递两个实参,当传递一个实参时代表结束值
# 当传递两个实参时,第一个实参代表起始值,第二个实参代表结束值
# 打印出以此区间内的全部奇数,不包含结束数:
# print_odd(10) # 1 3 5 7 9
# print_odd(11, 20) # 11 13 15 17 19
# 方法1
def print_odd(a, b=0):
if b == 0:
for x in range(1, a, 2):
print(x, end=' ')
else:
... | false |
90db359ca865a4a29a815f2c0d7a0fc8fbe0ad77 | q737645224/python3 | /python基础/python笔记/day15/exercise/iterator_set.py | 519 | 4.15625 | 4 | # 有一个集合:
# s = {'唐僧', '悟空', '八戒', '沙僧'}
# 用 for语句来遍历所有元素如下:
# for x in s:
# print(x)
# else:
# print('遍历结束')
# 请将上面的for语句改写为 用while语句和迭代器实现
s = {'唐僧', '悟空', '八戒', '沙僧'}
# for x in s:
# print(x)
# else:
# print('遍历结束')
it = iter(s) # 拿到迭代器
try:
while True:
x = next(i... | false |
dc7ef8a26abcf8b466fbfdda721744f287a885e6 | q737645224/python3 | /python基础/python笔记/day03/day02_exercise/score.py | 661 | 4.25 | 4 | # 2. 输入一个学生的三科成绩(三个整数):
# 打印出最高分是多少?
# 打印出最低分是多少?
# 打印出平均分是多少?
a = int(input("请输入第一科成绩: "))
b = int(input("请输入第二科成绩: "))
c = int(input("请输入第三科成绩: "))
# if a > b:
# if a > c:
# print("最大数是:", a)
# else:
# print("最大数是:", c)
# else:
# if b > c:
# print("最大数是:", b)
# else:
# ... | false |
8abda8068278d4ceba6a2e60d5d76db6e2c02a86 | DannyMcwaves/codebase | /pythons/stack/stack.py | 1,526 | 4.125 | 4 | __Author__ = "danny mcwaves"
"""
i learnt about stacks in the earlier version as a record activation container that holds the variables
during the invocation of a function. so when the function is invoked the, the stack stores all the
variables in the function and release them as long as their parent functions once the... | true |
951c7e5183fa5c141cc354c47dadf1b4821c19e8 | BlackHeartEmoji/Python-Practice | /PizzaToppings.py | 511 | 4.15625 | 4 | toppings = ['pepperoni','sausage','cheese','peppers']
total = []
print "Hey, let's make a pizza"
item = raw_input("What topping would you like on your pizza? ")
if item in toppings:
print "Yes we have " + item
total.append(item)
else:
print "Sorry we don't have " + item
itemtwo = raw_input("give me anothe... | true |
7fca8ff0cec660dbf2c22d658bad5ba1b6d4a8a4 | Aditya-Malik/Edyoda-Assignments | /subArray.py | 444 | 4.3125 | 4 | # 1. Print all sub arrays for a given array. Ex - if array is [2, 7, 5], Output will be: [2] [2, 7] [2, 7, 5] [7] [7, 5] [5].
def subArray(array):
n=len(array)
for i in range(0,n):
for j in range(i,n):
k=i
sub_array=[]
while k<=j:
sub_array.app... | false |
030e3abfd6bce4b33f9f5735aefbc21d94543304 | jamarrhill/CS162Project6B | /is_decreasing.py | 810 | 4.15625 | 4 | # Name: Jamar Hill
# Date: 5/10/2021
# Description: CS 162 Project 6b
# Recursive functions
# 1. Base case -> The most basic form of the question broken down
# 2. If not base, what can we do to break the problem down
# 3. Recursively call the function with the smaller problem
# lst = [5, 6, 10, 9, 8, 7, 64, 10]
# ... | true |
58a4de9900cdfcc825800f5c2a39f660ece015ab | pnovotnyq/python_exercises | /12_Fibonacci.py | 947 | 4.75 | 5 | #! /usr/bin/env python
'''
Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. Take this opportunity to think about how you can use functions. Make sure to ask the user to enter the number of numbers in the sequence to generate.(Hint: The Fibonnaci seqence is a sequence of... | true |
9e81f8e5faf23a690b9a20eb06227c4a779848e4 | Goutam-Kelam/Algorithms | /Square.py | 813 | 4.25 | 4 | '''
This program produces the square of input number without using multiplication
i:=
val:= square of i th number
'''
try :
num = int(raw_input("\n Enter the number\n"))
if(num == 0): # FOR ZERO
print "\nThe square of 0 is 0\n"
exit(1)
... | true |
e8a587f892f49edeaf6927e57113a7eeec0f3495 | prasadhegde001/Turtle_Race_Python | /main.py | 1,115 | 4.28125 | 4 | from turtle import Turtle,Screen
import random
is_race_on = False
screen = Screen()
screen.setup(width=500, height=400)
user_input = screen.textinput(title="Please Make Your Bet", prompt="Which Turtle Will win the Race? Enter a color")
colors = ["red", "orange", "yellow", "green", "blue", "purple"]
y_positio... | true |
d6e91528d13834231a950e675781ddccab502986 | shabbir148/A-Hybrid-Approach-for-Text-Summarization- | /fuzzy-rank/Summarizers/file_reader.py | 1,100 | 4.15625 | 4 | # Class to simplify the reading of text files in Python.
# Created by Ed Collins on Tuesday 7th June 2016.
class Reader:
"""Simplifies the reading of files to extract a list of strings. Simply pass in the name of the file and it will automatically be read, returning you a list of the strings in that file."""
... | true |
b0304411d3408c08056d86457ef288d10ecf461d | pole55/repository | /Madlibs.py | 1,360 | 4.21875 | 4 | """Python Mad Libs"""
"""Mad Libs require a short story with blank spaces (asking for different types of words). Words from the player will fill in those blanks."""
# The template for the story
STORY = "This morning %s woke up feeling %s. 'It is going to be a %s day!' Outside, a bunch of %ss were protesting to keep %s... | true |
1f48d9529ae94ae0deb313d495ffce1ee57179ec | Apropos-Brandon/py_workout | /code/ch01-numbers/e01_guessing_game.py~ | 634 | 4.25 | 4 | #!/usr/bin/env python3
import random
def guessing_game():
"""Generate a random integer from 1 to 100.
Ask the user repeatedly to guess the number.
Until they guess correctly, tell them to guess higher or lower.
"""
answer = random.randint(0, 100)
while True:
user_guess = int(input("What is your... | true |
6e9ae233ec122eeafe301ba8f76cfe4da0972798 | liuxingyuxx/cookbook | /date_structure/zip.py | 888 | 4.25 | 4 | #怎样在数据字典中执行一些计算操作(比如求最小值、最大值、排序等等)为了对字典值执行计算操作,通常需要使用 zip() 函数先将键和值反转过来
prices = {
'ACME': 45.23,
'AAPL': 612.78,
'IBM': 205.55,
'HPQ': 37.20,
'FB': 10.75
}
min_price = min(zip(prices.values... | false |
eedde460936b41c711402499160c903855636a3a | Struth-Rourke/cs-module-project-iterative-sorting | /src/searching/searching.py | 1,332 | 4.21875 | 4 | def linear_search(arr, target):
# for value in the len(arr)
for i in range(0, len(arr)):
# if the value equals the target
if arr[i] == target:
# return the index value
return i
# # ALT Code:
# for index, j in enumerate(arr):
# if j == target:
# ... | true |
ddf570644ae74b247569a0f9a303abf2906f83b9 | Dagim3/MIS3640 | /factor.py | 381 | 4.25 | 4 | your_number = int(input("Pick a number:")) #Enter value
for factor in range( 1, your_number+1): #Range is from 1 to the entered number, +1 is used as the range function stops right before the last value
factors = your_number % factor == 0 #This runs to check that the entered number doesn't have a remainder
if ... | true |
3df59ff6049246c715d31544df192d245fba4da6 | Dagim3/MIS3640 | /BMIcalc.py | 616 | 4.3125 | 4 | def calculate_bmi(Weight, Height):
BMI = 703* (Weight / (Height*Height))
if BMI>= 30:
print ('You are {}'.format(BMI))
print ('Obese')
elif BMI>= 25 and BMI< 29.9:
print ('You are {}'.format(BMI))
print ('Overweight')
elif BMI>= 18.5 and BMI<24.9:
print ('You a... | true |
69d1287d9328bb83dc8cd52f8a587a90a0614feb | derekdyer0309/interview_question_solutions | /Array Sequences/sentence_reversal.py | 1,416 | 4.40625 | 4 | """
Given a string of words, reverse all the words. For example:
Given:
'This is the best'
Return:
'best the is This'
As part of this exercise you should remove all leading and trailing whitespace. So that inputs such as:
' space here' and 'space here '
both become:
'here space'
###NOTE: DO NOT USE .re... | true |
4ba8df598a59c5f1ce1bdf81046b1719d447d277 | derekdyer0309/interview_question_solutions | /Strings/countingValleys.py | 964 | 4.21875 | 4 | import math
def countingValleys(steps, path):
#Make sure steps and len(path) are == or greater than zero
if steps == 0:
return 0
if len(path) == 0:
return 0
if steps != len(path):
return 0
#keep track of steps down, up, and valleys
sea_level = 0
steps = 0
valley... | true |
5b08179675bca8d0be53cc754f0e8eaa6bb3d2ac | AdityaNarayan001/Learning_Python_Basics | /Python Basics/weight_converter.py | 440 | 4.125 | 4 | # Weight converter
type = input('To Enter weight in (L)Lbs or (KG)kilogram :- ')
if type.upper() == "L":
weight = int(input('Enter your Weight in Pound : '))
kg_weight = weight / 0.45
print('Your weight in Kg is ' + str(kg_weight) + ' Kg')
elif type.upper() == "KG":
weight = int(input('Enter yo... | false |
acb3c73a5497db189795a56cea70fda0895ed9e5 | msinnema33/code-challenges | /Python/almostIncreasingSequence.py | 2,223 | 4.25 | 4 | def almostIncreasingSequence(sequence):
#Take out the edge cases
if len(sequence) <= 2:
return True
#Set up a new function to see if it's increasing sequence
def IncreasingSequence(test_sequence):
if len(test_sequence) == 2:
if test_sequence[0] < test_sequence[1]:
... | true |
96eb009a11129f84ea3bb1c98abbc7fc93c0937e | jayceazua/wallbreakers_work | /week_1/detect_cap.py | 1,407 | 4.4375 | 4 | """
Given a word, you need to judge whether the usage of capitals in it is right or not.
We define the usage of capitals in a word to be right when one of the following cases holds:
All letters in this word are capitals, like "USA".
All letters in this word are not capitals, like "leetcode".
Only the first letter in ... | true |
325c1a34c36080380709be79330a2ded62c4e4fe | jayceazua/wallbreakers_work | /practice_facebook/reverse_linked_list.py | 658 | 4.3125 | 4 | """
Reverse a singly linked list.
Example:
Input: 1->2->3->4->5->NULL
Output: 5->4->3->2->1->NULL
Follow up:
A linked list can be reversed either iteratively or recursively. Could you implement both?
"""
def reverseList(head):
# if not head or not head.next:
# return head
# ... | true |
83aa02c1e5f13e596e4858f4d56f50acf6ccc559 | jayceazua/wallbreakers_work | /week_1/reverse_int.py | 1,049 | 4.21875 | 4 | """
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123
Output: 321
Example 2:
Input: -123
Output: -321
Example 3:
Input: 120
Output: 21
Note:
Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the pu... | true |
db18748f39f1d17bfbcf5e28daa511b4b49df53b | jayceazua/wallbreakers_work | /week_1/transpose_matrix.py | 1,179 | 4.28125 | 4 | """
Given a matrix A, return the transpose of A.
The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix.
Example 1:
Input:
[
[1,2,3],
[4,5,6],
[7,8,9]
]
Output: [[1,4,7],[2,5,8],[3,6,9]]
Example 2:
Input: [[1,2,3],[4,5,6]]
Output: ... | true |
8c05cf6c225a14f05bc041485267a6a22bdb3929 | Crick25/First-Project | /First Project ✓.py | 908 | 4.15625 | 4 | #ask if like basketball, if yes display nba heights the same, if no ask if like football,
#if yes display football heights the same, if no to that print you boring cunt
#height from 5ft8 to 6ft5
myString = 'User'
print ("Hello " + myString)
name = input("What is your name?: ")
type(name)
print("Welcome, "... | true |
f41b8dc0c69a15541a9c13636a709cfdeacf77b1 | iconocaust/csci102-wk11-git | /fibonacci.py | 592 | 4.21875 | 4 | # Galen Stevenson
# CSCI 101 - B
# WEEK 1 - LAB 1B
# fibonacci.py
def fib():
fibs = [1, 2]
for i in range(1,9):
'''
implement Fibonacci sequence to calculate the
first 10 Fibonacci numbers, note Fn = Fn-1 + Fn-2
'''
return fibs
def main():
print('OUTPUT', fib())
i... | false |
5f0d3e5837cd98a06f4e0234d896f430ad4dc4e3 | houdinii/datacamp-data-engineering | /data-engineering/streamlined-data-ingestion-with-pandas/importing-data-from-flat-files.py | 1,550 | 4.25 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
def get_data_from_csvs():
"""
Get data from CSVs
In this exercise, you'll create a data frame from a CSV file. The United States makes available CSV files containing tax data by
ZIP or postal code, allowing us to analyze income ... | true |
4cb6ced5de1ffb717fb617b881d655510f508cd9 | Muneshyne/Python-Projects | /Abstractionassignment.py | 1,157 | 4.375 | 4 |
from abc import ABC, abstractmethod
class Mortgage(ABC):
def pay(self, amount):
print("Your savings account balance is: ",amount)
#this function is telling us to pass in an argument.
@abstractmethod
def payment(self, amount):
pass
class HomePayment(Mortga... | true |
bc0ffff09955ac29454d2193c38de89025afe25c | MrLW/python | /chapter_05/demo02.py | 215 | 4.25 | 4 | name = input('what is your name ?')
if name.endswith('Bob'):
print("Hello Mr.Bob")
else:
print("Hello LiWen")
# python的三目运算符
status = 'friend' if name.endswith("Bob") else "liwen"
print(status)
| false |
7eb969c50bcb0c462c0711f044891b0a6f4bfe58 | mgardiner1354/CIS470 | /exam1_Q21.py | 911 | 4.21875 | 4 | import pandas as pd
#Without using pandas, write a for loop that calculates the average salary of 2020 Public Safety per division of workers in the Cambridge Data Set#
import csv #adding csv library
total_salary = 0 #defining total salary across all employees
emp_count = 0 #defining how many employees work at ... | true |
846ba86bb7a3468ad1ff09035f74e8c992cd093c | lewiss9581/CTI110 | /M3LAB_Lewis.py | 978 | 4.1875 | 4 | # The purpose of this program is to calculate user input of their number grades and then output the letter grade
# Lewis.
# The def main or code being excuted later sets the following variables: A_score = 90, B_score = 80, C_score = 70, D_score = 60, F_score = 50,
A_score = 90
B_score = 80
C_score = 70
D_score ... | true |
938e7ec894153df47319fd6d88581ee7c30e6dc8 | cx1802/hello_world | /assignments/XiePeidi_assign5_part3c.py | 2,558 | 4.125 | 4 | """
Peidi Xie
March 30th, 2019
Introduction to Programming, Section 03
Part 3c: Custom Number Range
"""
'''
# iterate from 1 to 1000 to test whether the iterator number is a prime number
for i in range(1, 1001):
# 1 is technically not a prime number
if i == 1:
print("1 is technically not a prime number.... | true |
a5f10c74f6a140ad75604c9defd3a44e3e0bd4f8 | GunjanPande/tutions-python3 | /REVISION CONTENT/3. Output/3 end in print function.py | 637 | 4.4375 | 4 | def main():
# below three print statements will print in three separate lines
# because default end character/string is "\n" i.e. new line
print("Hello")
print("hi")
print("Namaste")
# we can change default end character/string to any thing we want
# Hello, hi, Namaste\n
print... | false |
1da87e75e533b3dd33251cc8a75c2fdd699eb236 | GunjanPande/tutions-python3 | /Challenges/While Loop Challenges/050.py | 824 | 4.15625 | 4 | """
50
Ask the user to enter a number between
10 and 20.
If they enter a value under 10,
display the message “Too low” and ask
them to try again.
If they enter a value
above 20, display the message “Too high”
and ask them to try again.
Keep repeating
this until they enter a value that is
between 10 and ... | true |
032151fc2846316feeeabdda96fd724783d7b18e | GunjanPande/tutions-python3 | /Challenges/Basics/005.py | 404 | 4.28125 | 4 | # 005
# Ask the user to enter three
# numbers. Add together the first
# two numbers and then multiply
# this total by the third. Display the
# answer as The answer is
# [answer]. .
def main():
num1 = int( input("Enter number 1: ") )
num2 = int( input("Enter number 2: ") )
num3 = int( input("Enter number 3: "... | true |
fa45e0bf675adaffdecdf35f3c20c315431b9104 | GunjanPande/tutions-python3 | /10-12. Loops/oddNo2.py | 303 | 4.15625 | 4 | """
Q - Print first n odd number
Take value of n from user
ex. if n = 3
print -> 1, 3, 5
Hint: Use odd no. formula
"""
def main():
n = int(input("Please enter how many odd no.s to print:"))
i = 1
while( i <= n ):
oddNo = 2 * i - 1
print(oddNo)
i = i + 1
main() | false |
048fa2b8bddcea58578490c440cc0902c4c026fc | GunjanPande/tutions-python3 | /10-12. Loops/FOR LOOPS/forloop1.py | 247 | 4.25 | 4 |
names = [] # names list
n = int(input("How many names? : "))
for i in range(n): # loop will repeat n times
name = input()
names.append(name)
# advanced for loop (for loop in combination with list)
for name in names:
print(name) | false |
fd14e438d7cded648828192a171e18f8a38f1a95 | GunjanPande/tutions-python3 | /REVISION CONTENT/4. Input/1. Input.py | 1,173 | 4.125 | 4 | def main():
name = input("Please enter name - ")
print("Name - '{}'".format(name))
# ValueError comes during when we the input provided is not of required
age = int( input("Please enter age - ") )
print("Age - {}".format(age))
height = float( input("Please enter height - ") )
print("Height... | false |
b2fe7b891e4f40d446d2cb784df8d5f0c5b6b342 | GunjanPande/tutions-python3 | /22. List Methods/main2.py | 700 | 4.25 | 4 | def main():
# 5. Combining items of two different lists in one single list using the + operator
rishavList = ["GTA", "Notebooks", "Bicycle"]
harshitList = ["Pens", "Hard disk", "Cover"]
shoppingList = rishavList + harshitList
print( str(shoppingList) )
# Note - when we use + operator -> ... | true |
f9a8a7021c76d91edb5ff3d0903a9d9ebb41e1dd | GunjanPande/tutions-python3 | /10-12. Loops/wholeNos.py | 275 | 4.21875 | 4 | """
Print WHOLE numbers upto n. Ask value of n from user.
"""
def main():
print("program to print whole numbers upto n")
n = int(input("Enter value of n: "))
i = 0 # whole number starts from 0
while( i <= n ):
print( i )
i = i + 1
main() | true |
92582e199045c37d0bf11ffc564deb37ca2f4c3e | GunjanPande/tutions-python3 | /14. String Methods/StringFunctions-2.py | 882 | 4.28125 | 4 | def main():
name = input("enter a string: ")
print(name) # harshit jaiswal
# always remember, in coding, couting starts from 0 and it is called
# variable_name[start_index: end_index + 1] will give a part of the complete string stored in the variable_name
first_name = name[0: 7]
print(fi... | true |
d5e67654ccf34d7b953a87ee29c731d7c7c7e9fd | vanshika-2008/Project-97 | /NumberGuess.py | 616 | 4.25 | 4 | import random
number = random.randint(1 , 9)
chances = 0
print("Number Guessing Game")
print("Guess a number (between 1 to 9)")
while chances<5 :
guess = int(input("Enter your guess :"))
if(guess == number) :
print("Congratulations!! You won the game")
if(guess> number) :
print("Your gue... | true |
640c540cda422daed64649da63fdf0e50c784131 | bainco/bainco.github.io | /course-files/homework/hw01/turtle_programs.py | 1,456 | 4.53125 | 5 | from MyTurtle import *
### TURTLE CHEATSHEET ###############################################
# Pretend we have a turtle named: turtle_0
# If we want turtle_0 to go forward 100 steps we just say:
# turtle_0.forward(100)
# If we want turtle_0 to turn left or right 90 degrees, we just say:
# turtle_0.left(90)
# turtle_0... | false |
58cfb075dbcaa11e511c92a6a5d42b336498096f | bainco/bainco.github.io | /course-files/tutorials/tutorial05/warmup/a_while_always_true.py | 803 | 4.125 | 4 | import time
'''
A few things to note here:
1. The while loop never terminates. It will print this greeting until
you cancel out of the program (Ctl+C or go the Shell menu at the top of
the screen and select Interrupt Execution), and "Program terminated"
will never print.
2. This is known as... | true |
dc67ecd32fc7e602e97675510c2d97d2cb2e184b | bainco/bainco.github.io | /course-files/homework/hw01/calculator_programs.py | 329 | 4.21875 | 4 | # Exercise 1:
# Exercise 2:
# Exercise 3:
# Exercise 4:
# Hint: to find the length in number of letters of a string, we can use the len function
# like so: len("hello"). If we wanted to find the number of characters in a string
# that's stored in a variable, we'd instead use the variable's name: len(v... | true |
32ce4bc7ed6d3c02f8c2f9a1f1fe74d56c4eb724 | bainco/bainco.github.io | /course-files/lectures/lecture04/turtle_programs.py | 837 | 4.5625 | 5 | from MyTurtle import *
### TURTLE CHEATSHEET ###############################################
# Pretend we have a turtle named: turtle_0
# If we want turtle_0 to go forward 100 steps we just say:
# turtle_0.forward(100)
# If we want turtle_0 to turn left or right 90 degrees, we just say:
# turtle_0.left(90)
# turtle_0... | true |
8f4230226c46ca9ff049e2289b97df9be0604840 | fmacias64/CourseraPython | /miniProject1/miniProject1.py | 2,328 | 4.125 | 4 | import random
# Rock-paper-scissors-lizard-Spock template
# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
# helper functions
def name_to_number(name):
# convert name ... | true |
9499eb017ab1052f331ee3e9bef2e98b0926b5e9 | MeghaSah/python_internship1 | /day_4.py | 681 | 4.28125 | 4 | # write a prrogram to create a list of n integer values and add an tem to the list
numbers = [1,2,3,4,5,6]
numbers.append(7)
print(numbers)
#delete the item from the list
numbers.remove(5)
print(numbers)
# storing largest number to the list
largest = max(numbers)
print(largest)
# storing smallest number... | true |
bda340062aed8861e6fb566b06c034619b3ae70f | Jonnee69/Lucky-Unicorn | /05_Lu_statement_generator.py | 1,032 | 4.21875 | 4 | token = input("choose a token: ")
COST = 1
UNICORN = 5
ZEB_HOR = 0.5
balance = 10
# Adjust balance based on the chosen and generate feedback
if token == "unicorn":
# prints unicorn statement
print()
print("*******************************************")
print("***** Congratulations! It's ${:.2f} {} **... | true |
2403815f758c6f4148d9e57d7dd23ce2d507451d | gabrieleliasdev/python-cev | /ex055.py | 1,185 | 4.21875 | 4 | """
055 - Faça um programa que leia o peso de cinco pessoas. No final, mostre qual foi o maior
e o menor peso lidos.
"""
"""
w1 = float(input(f"Type the weight of 1ª person: Kg "))
w2 = float(input(f"Type the weight of 2ª person: Kg "))
w3 = float(input(f"Type the weight of 3ª person: Kg "))
w4 = float(input(f"Type... | false |
72a1c6cee1535bd01a68fae1dc905c774fc5fd26 | gabrieleliasdev/python-cev | /ex037.py | 752 | 4.125 | 4 | """037 - Escreva um programa que leia um número inteiro qualquer e pela para o usuário escolher qual será a
base de conversão: 1) para binário 2) octal 3) hexadecimal"""
n = int(input("\nType the number you want to convert:\n>>> "))
print("""\nChoose the option for conversion:
[a] Convert to Binary
[b] Convert to O... | false |
fe7bf50c9a7fbde5bce12f2a10d114d978a78526 | gabrieleliasdev/python-cev | /ex042.py | 784 | 4.25 | 4 | """042 - Refaça o Desafio 035 dos triângulos, acrescentando o recurso de mostrar que tipo de triângulo será formado:
- Equilátero: todos os lados iguais.
- Isóceles: dois lados iguais.
- Escaleno: todos os lados diferentes."""
s = '-=-'*20
print(s)
print('Analisador de Triângulos')
print(s)
r1 = float(input('Fir... | false |
681fba3f6d5b0595e604367258c96e98a7ac2e83 | gabrieleliasdev/python-cev | /ex044.py | 1,250 | 4.125 | 4 | """044 - Elabore um programa que calcule o valor a ser pago por um produto, considerando o seu preço normal e
condição de pagamento:
- à vista dinheiro/cheque: 10% de desconto.
- à vista no cartão: 5% de desconto.
- em até 2x no cartão: preço normal
- 3x ou mais no cartão: 20% de juros"""
v = float(input("\n... | false |
3a0756c16a5479ac6e722d4441ba8d544a327571 | gabrieleliasdev/python-cev | /ex085.py | 578 | 4.21875 | 4 | """
Exercício Python 085
Crie um programa onde o usuário possa digitar sete valores numéricos
e cadastre-os em uma lista única que mantenha separados os valores pares e ímpares.
No final, mostre os valores pares e ímpares em ordem crescente.
"""
lst = [[],[]]
for i in range(7):
i = int(input(f"Type... | false |
e200573fe5c9ac5266e5f16453d3468fe1e103f0 | ZhaoFelix/Python3_Tutorial | /02.py | 1,099 | 4.125 | 4 | # coding=utf-8
# 类
class Student(object):
#定义类属性
name = 'Felix'
age = 23
#变量名两个下划线开头,定义私有属性,这样在类外部无法直接进行访问,类的私有方法也无法访问
__sex = 0
#定义构造方法
def __init__(self,name,age,sex):
self.name = name
self.age = age
self.__sex = sex
#类方法
def get_sex(self):
return ... | false |
65dd78967adb237925b4c3f68f502fb610ed1318 | alifa-ara-heya/My-Journey-With-Python | /day_02/Python_variables.py | 1,672 | 4.3125 | 4 | #Day_2: July/29/2020
#In the name 0f Allah..
#Me: Alifa Ara Heya
Name = "Alifa Ara Heya"
Year = 2020
Country = "Bangladesh"
Identity = "Muslim"
print(Name)
print(Country)
print(Year)
print(Identity)
print("My name is", Name)
#Calculating and printing the number of days, weeks, and months in 27 years:
days_in_27_year... | true |
73465c62f71a8a0a5b83eab5bba074212aa322c3 | alifa-ara-heya/My-Journey-With-Python | /day_14/exercise7.py | 1,011 | 4.28125 | 4 | # Day_14: August/10/2020
# In the name 0f Allah..
# Me: Alifa
# From: Book : Python for everybody
# Chapter:4 (Functions)
# Exercise 3: Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error message. If the score is between 0.0 and 1.0, print a grade using the following... | true |
38d16d0908fcbcde5f9aa9a8131fe3691efcee40 | alifa-ara-heya/My-Journey-With-Python | /day_33/reg_expressions.py | 1,885 | 4.59375 | 5 | # bismillah
# Book: python for everybody (chapter: 11)
# Regular Expressions
# Search for lines that contain 'From':
import re
hand = open('.\day_28\mbox-short.txt')
for line in hand:
line = line.rstrip()
if re.search('From:', line):
print(line)
'''output:
From: stephen.marquard@uct.ac.za
From: louis... | false |
9d3f67cf1ab645c4d5744187c8d53ac6f84df0a6 | alifa-ara-heya/My-Journey-With-Python | /day_03/formatting_strings.py | 1,864 | 4.375 | 4 | #Topic: Formatting strings and processing user input & String interpolation:
#Day_2: July/30/2020
#In the name 0f Allah..
#Me: Alifa Ara Heya
print("Nikita is 24 years old.")
print("{} is {} years old".format("John", 24))
print("My name is {}.".format("Alifa"))
output="{} is {} years old, and {} works as a {}." ... | true |
4fe2d1fece511b56dc3851f01a2119b4b7575ac7 | alifa-ara-heya/My-Journey-With-Python | /day_14/exercise6.py | 1,372 | 4.34375 | 4 | # Day_14: August/10/2020
# In the name 0f Allah..
# Me: Alifa
# From: Book : Python for everybody
# Chapter:4 (Functions)
# Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked abov... | true |
1c6b11c96f7f9afb0f6ce92883e0433e78f37042 | alifa-ara-heya/My-Journey-With-Python | /day_13/coditional_execution.py | 2,354 | 4.53125 | 5 | # Day_13: August/09/2020
# In the name 0f Allah..
# Me: Alifa
# From: Book : Python for everybody
# chapter: 3
# Conditional operator:
print("x" == "y") # False
n = 18
print(n % 2 == 0 or n % 3 == 0) # True (the number is divisible by both 2 and 3)
x = 4
y = 5
print(x > y) # False
print(not x > y) ... | true |
ebfe1976b54c596ca0e4a8355e26f8903e7d42a0 | alifa-ara-heya/My-Journey-With-Python | /day_13/exercise 3.1.py | 780 | 4.46875 | 4 | # 3.1 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use in... | true |
439c26ee1127ae5be9cb49356e83e1456f23d71c | Royalsbachl9/Web-page | /dictionary_attack.py | 726 | 4.125 | 4 | #Opens a file. You can now look at each line in the file individually with a statement like "for line in f:
f = open("dictionary.txt","r")
print("Can your password survive a dictionary attack?")
#Take input from the keyboard, storing in the variable test_password
#NOTE - You will have to use .strip() to strip whitesp... | true |
e0d22fcafd6e0c8ede004ca82ae7ea77165ebc67 | Vignesh77/python-learning | /chapter3/src/list_add.py | 607 | 4.34375 | 4 | """
@file :list_add.py
@brief :Create the list and add the elements.
@author :vignesh
"""
list_len = input("Enter the length of list :")
input_list =[ ]
print "Enter the values to list"
for index in range(list_len) :
list1 = input("")
input_list.append(list1)
print input_list
print "Enter do u w... | true |
d3b86b7af656f2fcbf08d7184c04bd0abe1fda81 | Daksh/CSE202_DBMS-Project | /pythonConnection.py | 1,233 | 4.34375 | 4 | # Proof of Concept
# A sample script to show how to use Python with MySQL
import mysql.connector as mysql
from os import system, name
def clear():
if name == 'nt': # for windows
system('cls')
else: # for mac and linux
system('clear')
def createDB():
db = mysql.connect(
host = "localhost",
user = "ro... | true |
b769423ba1874f1202146751959087287fcc8e07 | valdergallo/pyschool_solutions | /Tuples/remove_common_elements.py | 778 | 4.40625 | 4 | """
Remove Common Elements
======================
Write a function removeCommonElements(t1, t2) that takes in 2 tuples as arguments and returns a sorted tuple containing elements that are not found in both tuples.
Examples
>>> removeCommonElements((1,2,3,4), (3,4,5,6))
(1, 2, 5, 6)
>>> removeCommonElements(('b','a',... | true |
63d11c0e40b26c71ca55cbac209df9f89c3ee31d | farhanjaved47/python | /Generators/FibonacciSequenceGenerator.py | 649 | 4.21875 | 4 | """
Farhan Javed
farhan.javed47@gmail.com
12/24/2019
Generate a Fibonacci sequence using Python generators
"""
def fibonacci(n):
print('In Fibonacci Generator')
if n == 1:
yield 1
if n == 2:
yield 1
yield 1
if n >= 3:
base_number = 1
yield base_number
ne... | false |
8ebb9a939d3b9070c959fd0af7ce6e7e9c2bf723 | ramanuj760/PythonProject | /oops cl1.py | 508 | 4.125 | 4 | class A:
#print("this is a parent class")
#d={"name":"ram"}
"this is a sample string"
def __init__(self):
print("inside construcor")
def display(self):
print("inside method")
class B(A):
pass
#a is an instance of class A. A() is an object of class A
#calling a default constr... | true |
297845ca1a3fc0719816d32e0aa30a324e404299 | Aguniec/Beginners_projects | /Fibonacci.py | 306 | 4.21875 | 4 | """
Write a program that asks the user how many Fibonnaci numbers to generate and then generates them.
"""
number = int(input("Give me a number"))
list_of_numbers = [0, 1]
for i in range(0, number):
a = list_of_numbers[-1] + list_of_numbers[-2]
list_of_numbers.append(a)
print(list_of_numbers)
| true |
28f439a0a623ffd4654f51d37a9fe5d5abc84f0f | Aguniec/Beginners_projects | /Reverse Word Order.py | 376 | 4.21875 | 4 | """
Write a program that asks the user for a long string containing multiple words.
Print back to the user the same string, except with the words in backwards order.
"""
def reverse_order(string):
words_to_array = string.split()
reverse_words_order = a[::-1]
return " ".join(reverse_words_order)
string... | true |
ba0bf66c366c1a195984487975f8ac734263fe52 | Prones94/Leet-Code | /vowel_removal.py | 2,534 | 4.25 | 4 | # 1. Remove Vowels From String
'''
1. Restate Problem
- Question is asking if given a string, remove all the vowels from that string 'a,e,i,o,u' and then return the string without the vowels
2. Ask Clarifying Questions
- How large is the string?
- Is there other data types as well besid... | true |
20124716905e7280df81672bdfe4b95187a57db6 | Anubis84/BeginningPythonExercises | /chapter6/py_chapter6/src/chapter6_examples.py | 808 | 4.53125 | 5 | '''
Created on Nov 21, 2011
This file shows some examples of how to use the classes presented in this chapter.
@author: flindt
'''
# import the classes
from Ch6_classes import Omelet,Fridge
# making an Omelet
# Or in python speak: Instatiating an object of the class "Omelet"
o1 = Omelet()
print( o1 )
print( o1.ge... | true |
8bcdf622949e650a300e33433de3edfbafdfbebd | jdotjdot/Coding-Fun | /programmingchallenge2.py | 2,683 | 4.1875 | 4 | def __init__():
print('''Programming-Challenge-2 J.J. Fliegelman
At least starting off with this now, this strikes me as a
a textbook example of the knapsack problem. I'll start
with that on a smaller scale, and then see how that scales
when we go up to 70 users.
As we scale to 70 people, it ... | true |
d6b4a5b0e05d8305f318b22958eba3dc58b3ff5b | bestcourses-ai/math-through-simulation | /monty-hall.py | 1,019 | 4.34375 | 4 | '''
https://en.wikipedia.org/wiki/Monty_Hall_problem
Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats.
You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat.
He then says t... | true |
838819204e66a2e58e3a602e0db827d5120c24ed | bestcourses-ai/math-through-simulation | /hht-or-htt.py | 836 | 4.25 | 4 | '''
You're given a fair coin. You keep flipping the coin, keeping tracking of the last three flips.
For example, if your first three flips are T-H-T, and then you flip an H, your last three flips are now H-T-H.
You keep flipping the coin until the sequence Heads Heads Tails (HHT) or Heads Tails Tails (HTT) appears.
... | true |
a2a6008f7c2d7b189bbea9f694f4d7cad454ca0d | rapenumaka/pyhton-cory | /Strings/python_strings.py | 2,310 | 4.4375 | 4 | """
Namespace is a way to implement scope. In Python, each package, module, class, function and method function owns a "namespace" in which variable names are resolved. When a function, module or package is evaluated (that is, starts execution), a namespace is created. Think of it as an "evaluation context". When a fu... | true |
e33352708de4d7a14e320021cc983a02f00561cc | yang15/integrate | /integrate/store/order.py | 862 | 4.46875 | 4 | """
Example introduction to OOP in Python
"""
class Item(object):
# count = 0 # static variable
def __init__(self, name, num_items, unit_price):
self.name = name
self.num_items = num_items
self.unit_price = unit_price
print ('Hello world OOP')
# Item.count += 1
... | true |
e336b79128e8b59a036545dade31c816a1e19f42 | lukaa12/ALHE_project | /src/BestFirst.py | 2,416 | 4.25 | 4 | import Graph
from Path import Path
import datetime
class BestFirst:
"""Class representing Best First algorithm
It returns a path depending on which country has the highest number of cases on the next day"""
def __init__(self, starting_country, starting_date, alg_graph, goal_function):
"""Initializ... | true |
7309a377af0802fee1b441108e9bd1768e0044ba | Athenian-ComputerScience-Fall2020/mad-libs-eskinders17 | /my_code.py | 1,164 | 4.15625 | 4 | # Collaborators (including web sites where you got help: (enter none if you didn't need help)
#
name = input("Enter your name: ")
town = input("Enter a name of a town: ")
feeling = input("Enter how are you feeling now. Happy, sad or bored: ")
trip = input("Enter a place you want to visit: ")
friend = input("Enter the n... | true |
daeaba5d4388308be9aa532cc91b1d8efa32b6b7 | Pocom/Programming_Ex | /9_PalindromeNumber/t_1.py | 831 | 4.375 | 4 | """
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 not a palindrome.
"""
... | true |
31fc463b4b6ddf773f3db7ca30d431184562f711 | tofritz/example-work | /practice-problems/reddit-dailyprogramming/yahtzee.py | 1,614 | 4.25 | 4 | # The game of Yahtzee is played by rolling five 6-sided dice, and scoring the results in a number of ways.
# You are given a Yahtzee dice roll, represented as a sorted list of 5 integers, each of which is between 1 and 6 inclusive.
# Your task is to find the maximum possible score for this roll in the upper section of ... | true |
4ab26eb65f520448e489c6707fc46fd16c7e6ecd | venkateshchrl/python-practice | /exercises/stringlists.py | 269 | 4.25 | 4 | def reverse(word):
revStr = ''
for ch in range(len(word)):
revStr += word[len(word)-1-ch]
return revStr
str = input("Enter a word: ")
revStr = str[::-1]
if revStr == str:
print("This is a Palindrome")
else:
print("This is NOT a Palindrome") | true |
c44cbe7889a04f24d2b8f0df6d435957cb78b27b | GreenDevil/geekbrains_python_algorithms | /les_2/task_2/les_2_task_2.py | 575 | 4.28125 | 4 | # 2. Посчитать четные и нечетные цифры введенного натурального числа. Например, если введено число 34560,
# в нем 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5).
number = int(input("Введите натуральное число:"))
even_num = 0
odd_num = 0
while number > 0:
if number % 2 == 0:
even_num += 1
else:
... | false |
7958bb9a2065fafa59e99133a7df9008079f6e95 | JavaRod/SP_Online_PY210 | /students/Tianx/Lesson8/circle.py | 849 | 4.5625 | 5 | # ------------------------------------------------------------------------#
# !/usr/bin/env python3
# Title: Circle.py
# Desc: Create a class that represents a simple circle
# Tian Xie, 2020-05-11, Created File
# ------------------------------------------------------------------------#
import math
class Circle(object... | true |
7ce9d86fec01c6c36c6d777bc6888908cfd6b54a | rajeshsvv/Lenovo_Back | /1 PYTHON/6 MOSH/31_35_Dictionaries.py | 2,172 | 4.1875 | 4 | # 31 Dictionaries 2:18:21
# store info in key value pairs
"""
customer={
"name":"John",
"age":30,
"is_verified":True
}
print(customer["age"])
# print(customer["birthdate"]) #keyerror does not exist
# print(customer["Name"])
print(customer.get("Name",None))
customer["name"]="M... | false |
ec3aac36e8e11d4e5da44a56e9c53588b3ab6877 | rajeshsvv/Lenovo_Back | /1 PYTHON/9 PYTHON PROGRAMS/PYTHON PROGRAMS NOUS/5_Guru(regex and unit test logging here)/regex.py | 1,919 | 4.65625 | 5 | print("Hello world")
'''
Match Function:
This method is used to test whether a regular expression matches a specific string in Python.
The re.match().
The function returns 'none' of the pattern doesn't match or
includes additional information about which part of the string the match was found.
syntax:
re.match (... | true |
063fc481e2df9783a23b39a2a3ae7b57f2023b1f | rajeshsvv/Lenovo_Back | /1 PYTHON/9 PYTHON PROGRAMS/PYTHON PROGRAMS NOUS/1_Dataflair/Intermediate/Generators.py | 885 | 4.21875 | 4 | #A Python generator is a kind of an iterable, like a Python list or a python tuple.
# It generates for us a sequence of values that we can iterate on.
# You can use it to iterate on a for-loop in python, but you can’t index it
# def counter():
# i=1
# while i<10:
# yield i
# i+=1
#
# for i in c... | true |
890a5a8982009a123d6efcab9dadfa63d4df8fdf | rajeshsvv/Lenovo_Back | /1 PYTHON/4 SENDEX/else_if_statement.py | 402 | 4.125 | 4 | # x = 95
# y = 8
# if x > y:
# print("x is greater than y")
# if x > 55:
# print('x is greater than 55')
# elif y < 7:
# print('y is greater than 7')
# else:
# print('x is not greater than y')
x = 10
y = 10
z = 10
if x > y:
print('x is greater than y')
elif x == z:
print('x is equal to z')
if... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.