blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
5003bf0f352bb922db36802b0749389401d06bfa | ericsporto/BLASTOFF | /exercício05.py | 438 | 3.953125 | 4 | # considerei dois números como sendo a e b e os usei entre aspas para
# aceitação do Python
num01 = "a"
num02 = "b"
if num02 > num01:
k = num02 / num01
if (int(k)==k):
print("Os números são múltiplos")
else:
print("Os números não são múltiplos")
else:
k = num01 / num02
if (int(k)==k... |
bdc5dd27308dade0d17ac002c6aaefa908bede33 | kabusamieh/ProjectEuler | /P002 - EvenFibo.py | 1,195 | 3.65625 | 4 | ## @title EvenFibo
#
# @brief Finds the sum of all even Fibonacci numbers up to a cap.
# Reference: https://www.python.org/ (open source)
# Reference: https://projecteuler.net/problem=2
#
# @author Khalid Abusamieh
# @date 07/31/2019
#
# [WARNING] Runn... |
3d8ffdedac9361bc24dbb40a112a45c9a628202c | luokaidream/python_YiJinJing | /day02/conditaonal01.py | 1,976 | 3.765625 | 4 | # -*- coding:UTF-8 -*-
# Author: LuoKai
# date = 2021/1/6
"""
python 中也使用if else, While 等处理条件控制和循环控制
"""
"""
# if 条件控制
""""""
a = int(input("请输入数字:"))
if a == 10:
print("输入正确!!")
else:
print("输入错误!!")
# 多条件控制 if elif else
age = int(input("请输入年龄: "))
if age < 18:
print("我还是少年!")
elif 18 < age < 40:
pri... |
a41b80ee5740597ba3d469482669a247faebe208 | esteng/ULD | /code/pre_to_top.py | 777 | 3.578125 | 4 | import re
import os
import argparse
def pre_to_top(pre_file):
top_file = pre_file[:-4]+".top"
print("Converting "+pre_file+" to "+top_file)
with open(pre_file, 'r') as f:
pre_string = f.read().strip()
phones = pre_string.split(" ")
mappings = {}
nums = []
for phone in phones:
if phone not in mappin... |
466a1c4725afcdca2dfca4ab8e473ae46de58215 | lxy2222/python-learning | /diypython/task0005.py | 669 | 3.8125 | 4 | # -*-coding:utf-8 -*-
# 你有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率的大小
from PIL import Image
def changepicture(picfile,result):
img = Image.open(picfile) #获取图片大小
x,y = img.size
changex = float(x)/result[0]
changey = float(y)/result[1]
if changex > 1 or changey > 1:
change = changex if changex >... |
65ca45f3e7f13bc4c880fa6a4d701a30acaf1550 | 22sumit/python-practice | /concepts/decorators_demo.py | 515 | 3.8125 | 4 | '''
Modify the behaviour of function at compile time.
Adds special features to an existing functionality.
'''
#Example 1
def f1(func):
def wrapper():
print("hi")
func()
print("bye")
return wrapper()
@f1 #f = f1(f)
def f():
print("Hello")
#Example 2
def smart_div(func):
de... |
34cd82dc47355db24d1933a93ca29a293e4bc21e | 22sumit/python-practice | /general programs/armstrongNumber.py | 220 | 3.796875 | 4 | # A number whose cube of digits equals the number itself ex 0, 1, 153, 370, 371 and 407
n=370
s=0
k=n
while(k>0):
a=k%10
k=k//10
s=s+a*a*a
print("Armstrong Number") if n==s else print("Non amstrong Number")
|
e43fc12375763fe2521f4adb4cd3b8114cb0a708 | 22sumit/python-practice | /concepts/defaultdictExample.py | 356 | 4.03125 | 4 | # default dictionary doesn't throw keyError if the key isn't found
# dictionary throws keyError if the key isn't found
from collections import defaultdict
def get_value():
return "key not found"
d=defaultdict(get_value)
d[1]="sumit"
d[2]="kumar"
d[3]="burnwal"
print(d[5]) #prints key not found
d1={4:"anjali", 5... |
ec8f548aa122c78593892d9989df4ef4fae9bbe1 | NickPoletti/adventure_game | /adventure_game/rooms/room8.py | 2,212 | 3.703125 | 4 | import adventure_game.my_utils as utils
r8_inventory = {
"cake": 1
}
# # # # #
# ROOM 8
#
# Serves as a good template for blank rooms
room8_description = '''
. . . 8th room ...
As you enter this tiny room you can't help but notice the wonderful smell emitting from the back. You look up and
... |
079b1da27ef690fa5187633d928eb1debe303b09 | NickPoletti/adventure_game | /adventure_game/rooms/room5.py | 2,470 | 3.609375 | 4 | import adventure_game.my_utils as utils
r5_inventory = {
}
# # # # #
# ROOM 5
#
# Serves as a good template for blank rooms
room5_description = '''
. . . 5th room ...
You enter another lack luster room with four walls of stone surrounding you. The only point of interest is another
stone butt... |
a75a9b28f12d936756855a76ff3adedfbf841bc9 | kapilnchauhan77/Basic_Python_codes | /reverse words.py | 79 | 3.65625 | 4 | a=input('word:')
b=len(a)-1
while b+1>0:
print(a[b],end='')
b=b-1
|
bc84d1bf95fe22c194cc562a22a21a3704c68c25 | kapilnchauhan77/Basic_Python_codes | /Sqaure.py | 115 | 3.640625 | 4 | a=int(input('width:'))
for i in range(0,a):
for k in range(0,a):
print(' *',end='')
print('')
|
d4327349cf6f4d3f76da1fd0bc9b47a40729ba7c | TIANYE-123/CS61A | /Lecture.py | 5,165 | 4.09375 | 4 | ### Lecture 1
# Call expressions
pow(100, 2)
max(1, -2, 3, -4)
max(pow(10, 2), pow(2, 10), 1010)
# Importing and arithmetic with call expressions
from operator import add, mul
add(1, 2)
mul(4, 6)
mul(add(4, mul(4, 6)), add(3, 5))
add(2, mul(9, mul(add(4, mul(4, 6)), add(3, 5))))
# Objects
# Note: Download from http:/... |
684d359820a383804f522555022f712da208636f | yuweiwan/ML-MRF | /test.py | 218 | 3.5625 | 4 | import numpy as np
q = np.random.random((3, 3, 2))
print(q)
for row_num in range(3):
for col_num in range(3):
q[row_num, col_num, :] = q[row_num, col_num, :] / sum(q[row_num, col_num, :])
print(q)
|
64d16b3172d910897e8f36d186684e9d88f46cb7 | bundu10/lpthw | /example4.py | 1,987 | 4.25 | 4 | cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_driven
print("USING THE NORMAL METHOD OF (CONCATENATE) STRINGS")
# Blank line
print()
print("The... |
0450b9ea939e4a42052c41e6715c3f5a55aeb6b9 | lakshmi-narasimha-au16/py-problems-solutions | /BackTracking/print_zig_zag_sequences.py | 1,150 | 3.921875 | 4 | #BACKTRACKING PRINT SEQUENCES WITH Xi<Xi+1>Xi+2 or Xi>Xi+1<Xi+2 FOR i<n-2
print("BACKTRACKING PRINT SEQUENCES WITH Xi<Xi+1>Xi+2 or Xi>Xi+1<Xi+2 FOR i<n-2")
T = [0,0,0]
def zigzag(n,i):
if(i==n): # finished string, print it
print(T)
else:
if(i==0): # if first value I can put into {0,1,2}
... |
f1e12dfa8d571251e4df0ea8a5e59ef4f938ab82 | s3vi26/PythonTraining | /Section11-Project/war/deck.py | 401 | 3.5625 | 4 | import random
from card import Card, ranks, suits, values
class Deck:
def __init__(self):
self.all_cards = []
for suit in suits:
for rank in ranks:
created_card = Card(suit,rank)
print(created_card)
self.all_cards.append(created_card)
def shuffle(self):
random.s... |
7bdd8ab0db1fcfce9cb44481dff03354ab8faad8 | viveksyngh/MIT-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python | /Week-2/Pset2-1.py | 561 | 4.09375 | 4 | balance = 4213
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
month = 1
Total_amount_paid = 0.0
while month <= 12 :
min_monthly_payment = balance * monthlyPaymentRate
balance -= min_monthly_payment
balance += (balance * annualInterestRate)/12
Total_amount_paid += min_monthly_payment
print ("Mont... |
3ca15fbfd9baaa4b64bea4240850471e22dbbb05 | viveksyngh/MIT-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python | /FinalExam/uniqueValues.py | 651 | 3.9375 | 4 | def uniqueValues(aDict):
'''
aDict: a dictionary
returns: a sorted list of keys that map to unique aDict values, empty list if none
'''
res = []
for key1 in aDict.keys() :
temp = aDict[key1]
found = False
for key2 in aDict.keys() :
#print key1, key2
... |
13eb37c992ffef52f3c285c10412d32a322f3226 | viveksyngh/MIT-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python | /Week-2/Pset1-3.py | 576 | 3.9375 | 4 | s = 'zsgckcqptaqr'
#max_length = 0
longest_substr = ""
prev_char = 0
#count = 0
substr = ""
for char in s :
if ord(char) >= prev_char :
#count += 1
substr += char
else :
if len(substr) > len(longest_substr) :
#max_length = count
longest_substr = substr
su... |
d6b1ef9b8b6981801dda7317276d05d51c1e9d19 | prushton2/2.5dRenderEngine | /Vector2.py | 721 | 3.828125 | 4 | #Class to store 2 points.
class Vector2:
def __init__(self, x, y):
self.x = x
self.y = y
def toFloat(self):
self.x = float(self.x)
self.y = float(self.y)
def __repr__(self):
return f"Vector2: {self.x}, {self.y}"
def __add__(self, other):
return V... |
0f75d6bf0c8928802e6e31076ba6d42bccc2ae14 | HK002/JavaBasics | /Code/Data Structures/Linked Lists/MiddleElement.py | 1,269 | 4.125 | 4 | class Node:
def __init__(self,data):
self.value = data
self.link = None
class LinkedList:
def __init__(self):
self.start = None
def insert(self,data):
if self.start is None:
self.start = Node(data)
else:
x = self.start
... |
9546c4219a74d234ba93041aff46836ba243b3c4 | saar4vardi/pythonClass1 | /SaarFirstClass/4.1-4.5_targileyLuLaot.py | 6,335 | 4.03125 | 4 | from random import randint
# num1 = int(input("insert a number: "))
# num2 = int(input("insert a number: "))
# if num1 < num2:
# for i in range(num1 + 1, num2):
# if i % 2 == 0:
# print(i)
# else:
# for i in range(num2 + 1, num1):
# if i % 2 == 0:
# print(i)
# 4.2
# num... |
3468217eda250070effb82e9c49c2a4ceeee9724 | Neil-C1119/CIS156-Projects | /3exercise12.py | 1,102 | 4.25 | 4 | #Print the table of quantities and discount percentages
print("Here is the table of discounts: \n")
print(" QUANTITY | DISCOUNT")
print("------------------------")
print(" 10-19 | 10%")
print(" 20-49 | 20%")
print(" 50-99 | 30%")
print(" 100 or more | 40%")
#Store the user's package amoun... |
9bcbe5a5caa77120fe736a32f57e83b393a443e4 | Neil-C1119/CIS156-Projects | /6exercise6n9.py | 2,498 | 4.21875 | 4 | #Start of try
try:
#This opens the file as the var numbers, then closes the file once finished running
with open("numbers.txt", "r") as numbers:
#Variable for each line of the file
lines = numbers.readlines()
#Variable for the amount of lines in the file
line_amount = len(... |
969dd51c64bf4eeab6f4f8c19360b1e7b4d3825b | Neil-C1119/CIS156-Projects | /4exercise12.py | 597 | 4.40625 | 4 | #Factorial
#Ask the user to input a number to calculate
number = int(input("Which number would you like to find the factorial of? "))
#Defining the factorial function
def factorialFunc(number):
#Set the final_number variable to start at 1
final_number = 1
#For every number between 1 and the u... |
758db104ef47bfb2cd00843ef90063c2bbb86199 | sharonbrak/DI-Sharon | /Week_4/day_3/Exercises_XP_Gold.py | 1,746 | 4.28125 | 4 | # Exercise 1
fruits = input('What is/are your favorite fruits? ')
print(fruits)
type(fruits)
mylist = fruits.split(' ')
newfruit = input('Type another fruit: ')
if newfruit in mylist:
print('you chose one of your favorite fruits! Enjoy!')
else:
print('You chose a new fruit. I hope you enjoy it too!'... |
b9241a884859274b99894d27aa7e304cc9dc26b5 | pratikHan/leetcode | /DesignPatterns/SingletonPattern/Singleton.py | 465 | 3.828125 | 4 | class Singleton:
__instance = None
temp = 0
@staticmethod
def getInstance():
if Singleton.__instance == None:
Singleton()
return Singleton.__instance
def __init__(self):
if Singleton.__instance != None:
raise Exception("This is a singleton class")
... |
1a28c9982a39d6073b78a2de246589e31792e585 | monrjones/Python-Challenge | /PyBank/main1.py | 2,085 | 3.75 | 4 | import os
import csv
totalMonths =0
totalAmount =0
firstAmount = 0
averageAmountChange = 0
greatIncreaseDate = 'increasing date'
greatIncreaseAmount = 0
greatDecreaseDate = 'decreasing date'
greatDecreaseAmount = 0
totalAmountChange = 0
bankCSV = os.path.join('Resources','budget_data.csv')
with open(bankCSV, newline... |
ed7e6a1706b840c69c7a61bb439c72e55dcbf771 | ElaineBalgos/Balgos_E_PhythonHW | /FunctionExample.py | 375 | 3.90625 | 4 | #how to pass arguments into a function
def compareStuff(thing1, thing2):
# compare and print all the things
if thing1 == thing2
print('they match')
else:
print ('they do not match')
# invoke a functions by writing its name (calling it)
# and pass arguments
compareStuff('stuff', 'stuff')
compareStuff('stuff'... |
1b9f615c757eca935619d3efc391ced75d20f7f9 | sol4ik/politicians-talk | /modules/idea/idea.py | 881 | 3.53125 | 4 | class Idea:
"""
Class for representation of political Idea.
"""
def __init__(self, name='', politician='', session_date=''):
"""
(Idea, str, Politician, str) -> None
Initial function for Idea object.
"""
self.name = name
self.politician = politician
... |
f41aa1be3a521b5004c0ed67f26137d03c57d2dd | alvas-education-foundation/K.Muthu-courses | /25 May 2020/qstn_complex.py | 1,627 | 4.21875 | 4 | """
Problem Statement:
Take an input string parameter and determine if exactly 3 question marks exist between every pair of numbers that add up to 10.
If so, return true, otherwise return false. Some examples test cases are below:
"arrb6???4xxbl5???eee5" => true
"acc?7??sss?3rr1??????5" => true
... |
68b024412a8e0ff9e57797211031660e0118a94e | alvas-education-foundation/K.Muthu-courses | /19 May 2020/Function.py | 266 | 4.21875 | 4 | # Convert the temperature into Fahrenheit, given celsuis as inpit using function.
#Function definition
def temp(c):
f=(c*9/5)+32
return f
c=int(input("Enter the temperature in celsius : "))
#Function call
f=temp(c)
#Output
print("Temperature in Fahrenheit : ",f) |
95601467451fc0a3e31aab66581f96c7aba109cd | micropython/micropython-esp32 | /tests/basics/is_isnot.py | 221 | 3.734375 | 4 | print(1 is 1)
print(1 is 2)
print(1 is not 1)
print(1 is not 2)
print([1, 2] is [1, 2])
a = [1, 2]
b = a
print(b is a)
# TODO: strings require special "is" handling, postponed
# until qstr refactor.
#print("a" is "a")
|
f5e92378dc3cd79910995478630b874ce2750dcc | gitteraxcb/Duci | /src/word_parser.py | 638 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import pypinyin, jieba
def parse(text_list):
re = []
for text in text_list:
seg_list = jieba.cut(text.strip(), cut_all=True)
spliter = ",".encode("utf-8")
seg_strs = spliter.join(seg_list).encode("utf-8").split(",")
for seg_s in seg_strs:
seg_dec... |
e78d0ce44c7573231bb967f576aaa94bb8374a2e | narendra539804/Link-scheduler | /main.py | 1,254 | 3.734375 | 4 | import webbrowser
import time
# Taking website to be opened as input
#link = input("Enter the link to website you want to open ->")
# Taking alarm time from the user
#alarm = input("Set the website alarm time as (Format:- HH:MM:SS)(24 hour format) ->")
# This is the actual time that we will use to print. *
my_f... |
6aa0fa5e086c02a700751ca5fffb77cb74d26f24 | C-CCM-TC1028-111-2113/homework-2-MAngelFM | /assignments/02Licencia/src/exercise.py | 489 | 3.90625 | 4 | def main():
#Escribe tu código debajo de esta línea
age = int(input("Ingresa tu edad "))
if age >= 18:
ID = str(input("¿Tienes ID oficia? (s/n)"))
if ID == str("s"):
print("Tramite de Licencia Consedido")
elif ID == str("n"):
print("No cumples con los requisit... |
1b43185c938861cbc41488326c6f63aadb4a50e7 | AfnanRehman/ReutersDataMining | /getText.py | 4,309 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Kumar, Afnan
"""
from bs4 import BeautifulSoup # Make sure BeautifulSoup is installed on your device before running it
'''
This is the function takes PLACES as argument and takes body text from file for each body where PLACES happens.
It output whole body text to a file based on ... |
2d84a2b9faebc60ed5cb62ac57b7618c3ceea9fa | St-Manis/University-Projects | /CreditCards/CreditCards.py | 8,346 | 4.34375 | 4 | import sys
# This is the function of the program.
def checkCard(number, type, option):
counter = 0
sum = 0
# First we will check if the number is real. We reverse the number.
for digit in str(number)[::-1]:
# The first digit from the reversed number is our checksum.
if coun... |
91cc06e8e46a39f488bbf9455b900884dc693bfd | venkateshwaracholan/Thinkpython | /chapter 11/eleven_eight.py | 909 | 3.8125 | 4 | import math
import random
def is_prime(n):
"""Returns True id the arguemen is a prime number"""
for i in range(2, n - 1):
if n % i == 0:
return False
return True
def rand_prime(i, func):
"""Returns a random prime number in the range [i,func]"""
a = random.randint(i, func)
... |
9d34bbb2d485d0647246f278803ee1fd6d0405b3 | venkateshwaracholan/Thinkpython | /chapter 10/ten_one.py | 367 | 4.03125 | 4 | def nested_sum(list1):
"""Returns the sum of nested lists"""
nsum = 0
for i in range(len(list1)):
if isinstance(list1[i], list):
nsum = nsum+nested_sum(list1[i])
else:
nsum = nsum + list1[i]
return nsum
test_list=[1, 1, [1, [1, 1, 1], 1], 1, 1]
#print nest... |
3c35817843d29cd90aefe5194a785d1d2464010d | venkateshwaracholan/Thinkpython | /chapter 4/four_1.py | 1,192 | 3.84375 | 4 | import math
from swampy.TurtleWorld import *
#square code t is turle and len is length
def square(t, len):
for a in range(4):
fd(t, len)
rt(t)
#square(bob,100)
#polygon code t-turtle, len-length of sides,n-number of sides
def polygon(t, len, n):
for a in range(n):
fd(t, len)
... |
059319d8acb95c158a727d440c07160f897c6fc1 | venkateshwaracholan/Thinkpython | /chapter 10/ten_twelve.py | 328 | 3.890625 | 4 | from ten_eleven import *
data = read_words()
def find_reverse(data):
"""prints words that can be formed by reversing a word"""
for a in data:
t = bisect(data, a[::-1])
if(t):
print a,
for i in range(10 - len(a)):
print "",
print t
find_revers... |
9d49d0866bfb843c538298bb26585fd6f75851bb | venkateshwaracholan/Thinkpython | /chapter 8/eight_ten.py | 212 | 4.21875 | 4 | def is_palindrome_modified(word):
"""Returns true if the string is palindrome in a sinle check statement
without involving loop"""
return word==word[::-1]
print is_palindrome_modified("madam")
|
c7accef682ad20ed731f36dd4b25441d03413870 | venkateshwaracholan/Thinkpython | /chapter 10/ten_eleven.py | 843 | 3.75 | 4 | from ten_ten import *
import time
def bisect(item, find):
""" Returns the word if it finds otherwise false
uning binary search algorithm """
first = 0; last = len(item) - 1;
mid = (first + last) / 2
found = False
while first <= last and not found:
mid = (first + last) // 2
... |
763f8d9d7db3093bb454ff43ea3a0c58c13fca7a | venkateshwaracholan/Thinkpython | /chapter 12/twelve_two.py | 731 | 4.21875 | 4 | import random
def sort_by_length(words):
""" sorts with 2 argument tuple"""
t = []
for word in words:
t.append((len(word), word))
t.sort(reverse=True)
print t
res = []
for length, word in t:
print length, word
res.append(word)
return res
def sort_by_length_ran... |
cf49b28e91c98396a7bb2fc5f0864999b676823e | venkateshwaracholan/Thinkpython | /chapter 3/3.5.py | 537 | 3.78125 | 4 | def draw_pattern1(n, m):
for j in range(m):
print "+",
for k in range(4):
print "-",
print"+"
def draw_grid(n, m):
for i in range(n):
draw_pattern1(n, m)
for l in range(4):
for l2 in range(m + 1):
print "| ",
... |
3b82dcc452a6fe1f964f02bb2661f56d7efc0a57 | venkateshwaracholan/Thinkpython | /chapter 9/nine_one.py | 212 | 4.15625 | 4 | """reads all the words from the text file and prints
the words which has more than 20 characters"""
fin = open('words.txt')
for line in fin:
word = line.strip()
if(len(word) >= 20):
print word
|
d75cc3ec0d4b98b7665d2f79cfd6b889ee923229 | venkateshwaracholan/Thinkpython | /chapter 16/sixteen_three_add_time.py | 707 | 3.75 | 4 | import sixteen_one
class time(object):
"""represents a time variable
attributes: hour, minute,second """
t1 = time()
t1.hour = 5
t1.minute = 25
t1.second = 29
t2 = time()
t2.hour = 0
t2.minute = 120
t2.second = 31
def add_time(t1,t2):
"""Returns the sum of the two times and handles time variable limit... |
f5d3ccaea9b41905183b167c004392f04ffe199c | Radekov/BSK_Criptography | /railFence.py | 1,867 | 3.78125 | 4 | def encryptRailFence(message, numRails):
if numRails == 1:
return message
rail = arrayStringsRows(message,numRails)
# print(rail)
cipher = ''
for row in range(numRails):
cipher=cipher+rail[row]
return cipher
def decryptRailFence(cryptedMessage, numRails):
if numRails <= 1 or... |
ffce1cdf214e36f35d7d8d283cbcb0f7c92cdf4e | DireLines/hobby | /Scrabble.py | 2,268 | 3.671875 | 4 | import sys
import random
words = []
numletterwords = []
num = int(sys.argv[1])
addedletters = 'abcdefghijklmnopqrstuvwxyz'
with open('Scrab.txt','r') as file:
file.readline()
line = file.readline()
while(line):
words.append(line[:-1])#[:-1] gets rid of newline character
if(len(line) == num... |
9d7f44a3b84ff83bdfbb194950585310ca0dc544 | DireLines/hobby | /collatzUnmemoized.py | 448 | 3.796875 | 4 | # collatz
def iterate(num):
count = 0
while (num != 1):
if (num % 2 == 0):
num = num / 2
count += 1
else:
num = 3 * num + 1
count += 1
return count
highestSoFar = 1
results = {}
for i in range(1, 100000000):
iterations = iterate(i)
i... |
faac3882209441339c8941c238c700fb3a251167 | morganjacklee/com404 | /1-basics/4-repetition/4-sum-100/bot.py | 77 | 3.53125 | 4 | count = 0
for number in range(0,101):
count = count + number
print (count)
|
e2fa6f5594de3d52b39cae5fa29867778f5c520a | morganjacklee/com404 | /1-basics/3-decision/8-nestception/bot.py | 1,294 | 4.40625 | 4 | print("Where shall I look?")
print("Choices are:")
print("""- Bedroom
- Bathroom
- Labratory
- Somewhere else""")
location = str(input())
# Using if, else and elif statements
if location == "Bedroom" :
print("Where in the bedroom?")
print("""- Under the bed
- Somewhere else""")
location_bedroom = str(input())
... |
6961704033fcdcb5ec9b8c879774197cfbf69165 | morganjacklee/com404 | /1-basics/2-input/4-string-operator/bot.py | 288 | 3.578125 | 4 | # Display energy bars
print("Enter the number of lives remaining:")
lives = int(input())
print("Enter energy level:")
energy = int(input())
print("Enter shield level:")
shield = int(input())
print("Lives: ","♡" * lives)
print("Energy: ","☼"* energy)
print("Shield: ","◆"* shield)
|
5d8efc9060d07b3cda586e9c9685cf6efabf5655 | krunalmaniar/PythonProgram | /Python_Excel_Parsing.py | 778 | 3.953125 | 4 | #Import the Pandas module
import pandas as pd
#Set Pandas settings to see all rows and columns of dataFrame
pd.set_option("display.max_rows", None, "display.max_columns", None)
#Read the Excel file using pandas and Normalize the date columns in the standard date format
emp_df = pd.read_excel('C:\krunal.maniar\Python\... |
16214125be23fce25190cbb1857d02b14105e11d | warriorwithin12/python-django-course | /course/WarGameProject/hand.py | 1,045 | 4.25 | 4 | class Hand:
'''
This is the Hand class. Each player has a Hand, and can add or remove
cards from that hand. There should be an add and remove card method here.
'''
def __init__(self, cards):
self.cards = cards
def add_card(self, card):
"""
Add card to hand if not exists ... |
c5b341105b836ce803e61bd4c065eae6df2a9925 | wmm98/homework1 | /视频+刷题/6章2/生词本的生词.py | 1,449 | 4.1875 | 4 | """
【问题描述】
生词本包含多个条目。每个条目由生词和该生词的含义组成。例如,生词name的含义是名字。编写程序,输出多个生词及其含义,列出生词本中包含的生词。
【输入形式】
输入多行。每一行包含生词及其含义。这一行内,生词和含义之间用冒号分隔。
【输出形式】
输出一行。列出所有的生词,之间用空格分隔。生词按字典序从小到大排序
【样例输入】
name:名字
hello:你好
python:蟒蛇
【样例输出】
hello name python
【提示】
1. 在Pycharm集成开发环境中,运行程序的时候如何告诉程序输入已经结束?答案是,按Ctrl + D组合键。在Windows命令行中运行程序的话,
则是按Ctr... |
23763e6a12f59c64cbc2a32b42aa06da0d74c470 | wmm98/homework1 | /视频+刷题/函数/带参数装饰器注意事项.py | 896 | 4.15625 | 4 | # # 当程序有返回值的时候
# def print_num(func):
# def inner(n, m):
# print("*" * 30)
# func(n, m)
#
# return inner
#
#
# @print_num
# def pnum(n, m):
# print(n, m)
#
#
# pnum(1, 2) # 相当于调用inner函数,所以在在这里赋值的时候,
# # 所以要传相应的参数到inner函数里面,而后面还要调用pnum函数
# # 其函数也要传相对应得函数
# 当有几个函数的的时候,不能每个函数都配有有个装饰器,这样代码就... |
18d22f961fedcf9aea73c805af479553f07b9395 | wmm98/homework1 | /视频+刷题/考试习题/五分制转分数档.py | 721 | 4.09375 | 4 | '''
【问题描述】
编写程序,功能是输入五分制成绩,输出对应的百分制分数档。 不考虑非法输入的情形。
对应关系为:A: 90~100, B: 80~89, C: 70~79,D: 60~69, E: 0~59
【输入形式】
输入一个五分制成绩A, B, C, D或E。
【输出形式】
将五分制成绩换算为百分制成绩之后,根据对应关系,输出输入分数所对应的分数档。
【样例输入】
A
【样例输出】
90~100
【样例输出说明】
输出中的波浪线是英文半角。
'''
str = input()
if str == "A":
print("90~100")
elif str == "B":
... |
329ba34e60b4e2bef47e8e564fd40811f6c9b6ec | wmm98/homework1 | /叶常春视频例题/chap03/3-2-2-删除列表元素.py | 1,379 | 4.03125 | 4 | #例3-2-2 删除列表元素
# del语句删除列表元素
motorcycles = ['honda', 'yamaha', 'suzuki', '宗申', '钱江']
print(motorcycles)
print("删除第一个元素:")
del motorcycles[0]
print(motorcycles)
print("删除第三个元素:")
del motorcycles[2]
print(motorcycles)
#del 'suzuki' #这样写是错误的。
#pop()方法删除列表尾部元素
motorcycles = ['honda', 'yamaha', 'suzuki', '宗申', '钱江']
pri... |
212f63b5b38e596fff59af833d73efea2cce750c | wmm98/homework1 | /视频+刷题/第四章练习/单词个数统计.py | 1,104 | 4.4375 | 4 | """编写一个程序,输入一个句子,然后统计出这个句子当中不同的单词个数。例如,对于句子“one little two little three little boys",总共有5个不同的单词,one, little, two, three, boys。
说明:
(1)句子当中包含有空格。
(2)输入的句子当中只包含英文字符和空格,单词之间用一个空格隔开。
(3)不用考虑单词的大小写,假设输入的都是小写字符。
(4)句子长度不超过100个字符
(5)该问题实现的基本思路是:
a. 先定义一个存储不同单词的列表
b. 每次从句子中读取下一个单词
c.不断将新读取的单词加入该单词列表中。若单词列表中已存在该单词,则不添加。
【输入形式】... |
af2e9700ee3817e8efc22ae308fcbc551a0bfe71 | wmm98/homework1 | /视频+刷题/函数/生成器close方法.py | 411 | 3.6875 | 4 | def gen():
print("xxxxx")
yield 1
print("a")
yield 2
print("b")
yield 3
print("c")
yield 4
print("d")
yield 5
print("e")
# 只有执行生成器的时候print("xxxxx")才会被打印
test = gen()
print(next(test))
print(next(test))
print(next(test))
test.close()
# close方法后面还有next语句的话会出现异常
print(next... |
2d55ee10ec524f7013bb80e00edc668496bfe611 | wmm98/homework1 | /7章之后刷题/10章/文件大小写转换.py | 419 | 3.828125 | 4 | '''【问题描述】
文件src.txt存储的是一篇英文文章,将其中所有大写字母转换成小写字母存入文件dest.txt。
【样例输入】
src.txt里面存储内容为: This is a Book
【样例输出】
生成文件dest.txt。内容为: this is a book
'''
f1 = open("src.txt", "r")
content = f1.read().strip()
f = open("dest.txt", "w")
f.write(content.lower())
f.close()
|
3b443bad9b36cfceea11a1fa794edbb2b2f4db68 | wmm98/homework1 | /视频+刷题/第二到三章/运动员举重.py | 795 | 3.890625 | 4 | """
【问题描述】
从键盘输入两个举重运动员的成绩信息:
姓名、体重、抓举成绩、挺举成绩
输出获胜运动员的姓名。
总成绩高者获胜(总成绩=抓举成绩+挺举成绩)
总成绩相同时,体重轻者获胜。
【输入形式】姓名1 体重1 抓举成绩1 挺举成绩1 姓名2 体重2 抓举成绩2 挺举成绩2
【输出形式】获胜运动员的姓名
【样例输入】athlete1 78 120 130 athlete2 80 121 128
【样例输出】athlete1
"""
str1 = input().split()
total1 = eval(str1[2]) + eval(str1[3])
total2 = eval(str1[6]) + ... |
bce554b130b2b9be850461a3b137c2db03b3742f | wmm98/homework1 | /视频+刷题/第二到三章/求竿高度子的.py | 637 | 4.09375 | 4 | """
【问题描述】某战士根据太阳光的仰角和影子长度,利用数学函数来求解旗杆的高度。(圆周率取值为3.1415926)。请你编程实现计算过程。
【输入形式】采用浮点形式输入的角度值和影子长度值
【输出形式】一个浮点数,代表旗杆高度值。保留两位小数。
【样例输入】45 100
【样例输出】100.00
"""
import math
d, x = input().split()
d = float(d)
x = float(x)
# 求d角度对应的弧度
# tan(r) r为弧度,1度 = 圆周率/180度
r = d * 3.1415926 / 180
tan_value = math.tan(r)
# 求高度
y =... |
4bed2919d0be8bb3aa8e0550efefe75937ca9862 | wmm98/homework1 | /视频+刷题/第五章练习/-N=ABXBA.py | 1,616 | 3.515625 | 4 | '''
【问题描述】
输入三位数字N,求两位数AB(其中个位数字为B,十位数字为A,且有0 < A < B <=9)。使得下列等式成立:
AB x BA = N
其中BA是把AB中个、十位数字交换所得的两位数。
编写程序,接收控制台输入的三位整数N,求解A,B并输出。
如果没有解则输出No Answer。
【输入形式】
从键盘输入整数N。
【输出形式】
输出只有一行,包含两个数字A和B。输出时两个数字紧密输出,不使用其它字符进行分隔。
【样例输入】
976
【样例输出】
16
【样例说明】
输入整数N=976。经计算得16*61=976。可得a=1, b=6。将两个字符依次输出。
'''
#
#... |
2ffc76e63745696eb40ead735c3308068de2791f | wmm98/homework1 | /视频+刷题/第五章练习/判及格与否.py | 487 | 3.984375 | 4 | """
【问题描述】
编写程序,功能是输入一个百分制分数,输出及格与否的结论。不考虑非法输入的情形。
【输入形式】
输入一个0-100(包括0和100)之间的整数。
【输出形式】
如果及格(分数大于等于60),则输出“pass”,否则输出“fail”(大小写必须一致)。
【样例输入】
80
【样例输出】
pass
"""
score = int(input())
if score < 60:
print("fail")
else:
print("pass") |
4a267b10d1730588cfcf82d91c0fa7f54485100e | wmm98/homework1 | /视频+刷题/python2/字典的遍历.py | 675 | 4 | 4 | # num = {"name": "李华", "age": 18, "sex": "性别"}
#
# print(num.keys()) # num.keys()表键
# print(num.values()) # num.values()表值
# for temp in num.keys():
# print(temp)
#
# for temp in num.values():
# print(temp)
#
# print(num.items())
#
# for a, b in sorted(num.items()):
# print(a, b) # 打印字典里每一个整体
# # age... |
c1d3f129e52d43effa1412d9325bf3ef3ee67c31 | wmm98/homework1 | /7章之后刷题/7章2/10. 数字环.py | 1,348 | 3.8125 | 4 | def is_prime(n):
'''n是素数吗'''
for i in range(2, n // 2 + 1):
if n % i == 0:
return False
return True
def add_one_number(r_list, N, prime_list):
# print("add_one_number: r_list=", r_list)
result_lists = []
for p in prime_list:
next_number = p - r_list[-1]
if ... |
273f0f781d4885230b9600b5514967f821c9b85b | wmm98/homework1 | /视频+刷题/6章2/11. 求小岛面积老师.py | 1,577 | 3.59375 | 4 | n = int(input())
sea = []
for r in range(n):
sea.append(input().split())
# print(sea)
#求出各行的最左边1和最右边1的坐标
row_left_right = []
for r in range(n):
left_right = [None, None]
for c in range(n):
if sea[r][c] == '1':
if left_right[0] == None:
left_right[0] = c
if le... |
9cd6d94996dc2c110000ed31edb01d242e94e045 | wmm98/homework1 | /视频+刷题/python3/递归.py | 498 | 3.828125 | 4 | # 计算某个数的阶乘时可用循环,也可用递归
# 计算4阶乘
'''
i = 1
result = 1
while i <= 4:
result *= i
i += 1
print(result)
'''
# 也可以用递归的方法,切记用递归方法的时候一定要控制好执行的次数
# 要不会死循环,程序奔溃
def get_nums(num):
if num > 1:
# return num*get_nums(num - 1)
result = num * get_nums(num - 1)
return result
else:
... |
b419fec2050708466d92fd5294e2a7ef4be006c0 | wmm98/homework1 | /视频+刷题/python4/文件备份.py | 871 | 3.8125 | 4 | # 获取要复制的文件名
old_file_name = input("请输入你要备份点的文件名")
# 打开这个文件,读取数据
f = open(old_file_name, "r")
# 创建一个文件 xxx[副件].txt
position = old_file_name.rfind(".") # 找出点的位置,从右边开始找
str_name = old_file_name[:position] # 切出mm = str_name
new_file_name = str_name + "[复件].txt" # 最好改为+'[复件]'+old_file_name[position:]
# print(new_file_n... |
d8ab808b1d2303dde514796c6b18e1c1e9a8746a | wmm98/homework1 | /视频+刷题/列表 零玩转/列表排序.py | 1,061 | 3.84375 | 4 | s = [("a", 1), ("c", 3), ("b", 4), ("d", 5)]
s.sort() # [('a', 1), ('b', 4), ('c', 3), ('d', 5)] 按照元组的第一个元素排序
print(s)
s1 = [("a", 1), ("c", 3), ("b", 4), ("d", 5)]
# 按照元组的第二个元素排序
def getKey(x):
return x[1]
result = sorted(s1, key=getKey) # [('a', 1), ('c', 3), ('b', 4), ('d', 5)]
print(result)
result1 = so... |
d874222b9a955ea3e7a577e859ac61d785cf6924 | wmm98/homework1 | /7章之后刷题/8章/8-8-十进制小数转换为二进制.py | 1,263 | 3.515625 | 4 | def cxs2BinaryStr(xiaoshu, bitCount=10):
'''十进制纯小数转换为二进制小数(字符串形式,小数点后部分)'''
if xiaoshu == 0.0:
return "0"
bStr = ""
fPart = xiaoshu
# 小数部分不为0则循环
while fPart != 0.0 and len(bStr) < bitCount:
# 乘2取整
intPart = int(fPart * 2)
bStr = bStr + str(intPart)
# 得到小数... |
a7fc413a64e371e2d4ac86a6abc1fbb8b88ee8e0 | wmm98/homework1 | /视频+刷题/python5/存放家具(两个类之间).py | 1,117 | 3.828125 | 4 | class Home:
def __init__(self, new_area, new_addr):
self.area = new_area
self.addr = new_addr
self.left_area = new_area
self.contain_item = []
def __str__(self):
return "房子总面积是%d平米,还剩下%d平米,在%s" % (self.area, self.left_area, self.addr) +\
"当前的房子有%s" % (str... |
0efe14024551aa8bb7dc66131bb6390e25557a3b | wmm98/homework1 | /LeetCode/题/最长回文子串,通过.py | 856 | 3.734375 | 4 | '''
给定一个字符串 s,找到 s 子中最长的回文串。你可以假设 s 的最大长度为1000。
示例 1:
输入: "babad"
输出: "bab"
注意: "aba"也是一个有效答案。
示例 2:
输入: "cbbd"
输出: "bb"
'''
def longestPalindrome(s):
if len(s) > 0:
flag = 0
max_string = ''
for i in range(len(s)):
list1 = s[i]
for j in range(i + 1, len(s)):
... |
9c40f48defc7982d50a1f539e2bfb4c2473cdf71 | wmm98/homework1 | /视频+刷题/6章1/统计大小写字母个数和数字个数.py | 583 | 3.9375 | 4 | '''
【问题描述】统计一行字符的大写字母,小写字母和数字的个数。先输出大写字母个数,在输出小写字母个数,最后输出数字个数。
【输入形式】ljaij1A
【输出形式】1
5
1
【提示】用字符串的方法isupper, islower来判别大小写。isdigit来判断是否是数字。'''
str_list = input()
flag1 = 0
flag2 = 0
flag3 = 0
for i in str_list:
if i.isupper():
flag1 += 1
if i.islower():
flag2 += 1
if i... |
449c713b4d711a3a504c19111c052cc1b6c6a786 | wmm98/homework1 | /LeetCode/题/两个排序数组中的中位数.py | 1,789 | 3.71875 | 4 | '''给定两个大小为 m 和 n 的有序数组 nums1 和 nums2 。
请找出这两个有序数组的中位数。要求算法的时间复杂度为 O(log (m+n)) 。
你可以假设 nums1 和 nums2 不同时为空。
示例 1:
s1 = [1, 3]
s2 = [2]
中位数是 2.0
示例 2:
s1 = [1, 2]
s2 = [3, 4]
中位数是 (2 + 3)/2 = 2.5'''
def findMedianSortedArrays(nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype... |
ff163fb3318309c564045f01c078c6b424d6eb83 | wmm98/homework1 | /LeetCode/题/反转整数.py | 853 | 3.78125 | 4 | '''
给定一个 32 位有符号整数,将整数中的数字进行反转。
示例 1:
输入: 123
输出: 321
示例 2:
输入: -123
输出: -321
示例 3:
输入: 120
输出: 21
注意:
假设我们的环境只能存储 32 位有符号整数,其数值范围是 [−231, 231 − 1]。根据这个假设,如果反转后的整数溢出,则返回 0。
'''
def reverse(x):
"""
:type x: int
:rtype: int
"""
if x > 0:
s = str(x).strip("0")
s1 = s[::-1]
... |
de23ab9dc18e945f81a3a26bb7547a4a7a2d1aa0 | wmm98/homework1 | /叶常春视频例题/chap05/5-2-6-物理化学集训.py | 205 | 3.84375 | 4 | #例5-2-6
phy = float(input("输入物理成绩:"))
che = float(input("输入化学成绩:"))
if phy >= 90.0 or che >= 90.0:
print("获得集训资格")
else:
print("没有获得集训资格") |
85ae62cecf1fa3005df8ee8254b57f0cca4617c7 | wmm98/homework1 | /7章之后刷题/8章2/整数合并.py | 944 | 3.5625 | 4 | '''【问题描述】
编写一函数comb( a, b),将两个两位数的正整数a、b合并形成一个整数并返回。合并的方式是:
将a的十位和个位数依次放在结果的十位和千位上, b的十位和个位数依次放在结果的个位和百位上。
例如,当a=45,b=12。调用该函数后,返回5241。调用该函数进行验证:从键盘输入两个整数,
然后调用该函数进行合并,并输出合并后的结果。
【输入形式】
输入两个两位数的正整数,以空格隔开。
【输出形式】
输出合并后的正整数。
【输入样例】
45 12
【输出样例】
5241'''
def comb(a, b):
a = str(a)
b = str(b)
result = a[1] + ... |
0e58a386388363b0273cdff188c6e22f42e6abaf | wmm98/homework1 | /视频+刷题/第二到三章/输出三角形的三个角.py | 1,904 | 3.6875 | 4 | """
输入三角形的三条边长度,输出三个角的角度。
如果输入的三条边长度不合法,则提示输出"Not Valid"(不含双引号,注意大小写)。
余弦定律规定,若三角形三条边(a, b, c),边a和边b之间的夹角C满足:c2=a2+b2-2*a*b*cos(C)。
因此,
cos(C)=(c2-a2-b2) / (-2*a*b)
C = arccos( (c2-a2-b2) / (-2*a*b) )
在Python语言中,函数acos的作用是根据cos值求出弧度。
又,角度=弧度除以pi;再乘以180。 角度 = 弧度/pi * 180
【输入形式】
三条边a, b, c的边长(浮点数... |
0e2ab8e3750aea7e03c69dfc779b97b56b035a4f | wmm98/homework1 | /视频+刷题/python3/交换两个变量的值-1.py | 297 | 3.765625 | 4 | a = 10
def sum(a):
a += a
print(a)
sum(a)
print(a)
# 输出的结果分别为20和10,说明了不可变量不可改
# 数字,元组,字符串不可改
b = [11, 22]
def list(b):
b += b
print(b)
list(b)
print(b)
#两个print输出为相同的内容,说明元素可改 |
8fc657b9d0321cf93671b331eb30ab8c4aaec5f7 | wmm98/homework1 | /叶常春视频例题/chap04/4-4-2-列表复制和拼接.py | 727 | 3.71875 | 4 | # 例4-4-2 列表复制和拼接
# 引用复制
players = ['charles', 'martina', 'michael', '马龙', '孙杨']
print("1. players=", players)
plist = players # 引用复制:plist是players列表的另一个名字
plist.append('姚明')
print("2. players=", players)
# 内容复制
players = ['charles', 'martina', 'michael', '马龙', '孙杨']
print("3. players=", players)
plist = players[:]
#... |
403b0caa54d44032d31ecb13b14da0f376554d11 | wmm98/homework1 | /视频+刷题/python6/列表集合的去重.py | 424 | 3.734375 | 4 | a = [11, 22, 33, 44, 11, 22, 33, 44]
b = {11, 22, 33, 11, 12, 13} # 可表列表也可表集合
# 可创一个新列表
c = []
for i in a:
if i not in c:
c.append(i)
print(c)
# 没有该方法
'''
d = {}
for j in b:
if j not in d:
d.append(j)
print(d)
'''
# 列表去重方法, 集合没有重复元素的, 可以将列表变成集合再转回列表
f = set(a)
print(f)
e = list(f)
print(e)... |
de63dc7b42d272effd0ac8c6b53e7889fe5d6768 | wmm98/homework1 | /视频+刷题/字典/字典的批量修改.py | 446 | 3.625 | 4 | # 字典是可变的无序的键值对的集合
# 集合的的键是不可以相同的,而且是不可变的,比如列表,元组就属于可变的,所以不符合
# 因为key是不可变的,所以修改的时候只能修改values
# 字典批量修改
dic = {"name": "无", "age": 23, "num": 7032903}
dic.update({"name": "ming", "age": 90, "addr": "佛山"})
print(dic) # {'name': 'ming', 'age': 90, 'num': 7032903, 'addr': '佛山'}
|
1401e4bd3e8fbb017e6b391347d34bacced5bb1d | wmm98/homework1 | /7章之后刷题/类和对象/方法相关.py | 721 | 3.890625 | 4 | # 实例方法,默认第一个参数要接到一个实例
# 类方法,默认第一个参数要接到一个类
# 静态方法,静静地看着前面俩装逼,第一个参数啥也不默认接收
# 划分依据是:方法的第一个参数必须要接收的数据类型
# 不管哪一种类型方法,都是储存在类当中;没有在实例当中
# 不同类型方法的调用方式不同
class Person:
def one(self):
print("这是实例方法", self)
@classmethod
def two(cls):
print("这是类方法", cls)
@staticmethod
def three():
pr... |
3623c8bad0d5ee07b89b05fc3195e6f65ea7f708 | wmm98/homework1 | /视频+刷题/6章2/列出生词本的含义.py | 1,145 | 3.890625 | 4 | '''生词本包含多个条目。每个条目由生词和该生词的含义组成。例如,生词name的含义是名字。编写程序,输出所有的含义。
【输入形式】
输入多行。每一行包含生词及其含义。这一行内,生词和含义之间用冒号分隔。
【输出形式】
输出一行。列出所有的含义,之间用空格分隔。含义按字典序从小到大排序
【样例输入】
name:mingzi
hello:nihao
python:manshe
【样例输出】
manshe mingzi nihao
【提示】
1. 在Pycharm集成开发环境中,运行程序的时候如何告诉程序输入已经结束?答案是,按Ctrl + D组合键。在Windows命令行中运行程序的话
,则是按Ctrl + Z组合键。
2... |
c2d3a3337a337636c447d1a57bcc6d4ae1f96da0 | wmm98/homework1 | /视频+刷题/从零玩转/函数操作,查找计算.py | 1,340 | 3.671875 | 4 | name = "wo shi wu ming ming"
# 查找字符的索引,查到就返回下标,反之返回-1
# 对象.find[str, start , end = len(对象)] [star, end) 起始位置默认是0,结束默认是对象长度
result = name.find("wo")
print(result)
result = name.find("w") # 在有相同字符情况下只会查找到第一个字符的位置
print(result)
result = name.find("wu") # 这样找就可以查找到第二个w出现的位置
print(result)
result = name.find("o")
print(... |
d8eaf37e3262664f059989505d3c8668dc7b94d1 | wmm98/homework1 | /7章之后刷题/前5章考题/按序合并字符串.py | 740 | 3.875 | 4 | '''【问题描述】
str1、str2是两个有序字符串(其中字符按ASCII码从小到大排序),将str2合并到字符串str1中,
要求合并后的字符串仍是有序的,允许字符重复。最后输出合并后的结果。
【输入形式】
分两行从键盘输入两个有序字符串(不超过100个字符)
【输出形式】
输出合并后的有序字符串
【输入样例】
aceg
bdfh
【输出样例】
abcdefgh
【样例说明】
输入两个有序字符串aceg和bdfh,输出合并后的有序字符串abcdefgh
【评分标准】'''
str1 = input()
str2 = input()
str_list = []
for i in str1:
str_list.append... |
aa51d5e8bb65dd80ee501803eebf11e06a79d4c8 | wmm98/homework1 | /视频+刷题/列表 零玩转/查询遍历案列.py | 703 | 4.03125 | 4 | # 一个列表中要是有重复的元素,直接用for循环时不可以完全删除干净相同的元素的,查询也是一样,
# 因为这些方法都是从中左到右执行的,只会搜索到左边的元素
# 现在要遍历一个列表的元素并且显示出其对应的索引
# 方法一:
# list = ["a", "w", "a", "o"]
# index_count = 0
# for i in list:
# print(i, list.index(i, index_count), end=" ")
# # a 0 w 1 a 2 o 3
# index_count += 1
# 方法二:
list = ["a", "w", "a", "o"]
# 创... |
e6264a350628e807b0376fbd973d5893f274623d | wmm98/homework1 | /视频+刷题/第二到三章/超市购物小票.py | 1,203 | 4.09375 | 4 | """
问题描述】某超市促销,对购买的第二件商品(不限商品类别)打9折。路人甲购买两件商品,请按要求输出购物小票。
【输入形式】两个商品的原价
【输出形式】两个商品的购买价格及总价(请注意保留小数点后两位有效数字)。输出的每一行占16格。价格和总价靠右对齐。
【样例输入】
5.6 78.95
【样例输出】
5.60
71.06
----------------
Total: 76.66
"""
" 字符串的规格 "
price1, price2 = input().split()
price1 = float(price1)
price2 = float(pri... |
cc1746387214e2a10db090fb3c6e06a0bd8bab08 | wmm98/homework1 | /视频+刷题/python2/字符串中的下标.py | 147 | 3.578125 | 4 | name = "wumingming"
print(name[0],name[1])
last = name[len(name)-1]
print(last)
'''取出后面的字母课这样表示'''
print(name[-1],name[-2]) |
387b9f1fd12302b258a260cda679d21f3ac1e17e | wmm98/homework1 | /视频+刷题/集合/集合常用的操作.py | 275 | 4.09375 | 4 | # 可变集合可以增删,不可改查
# 不可变集合都不可以
# 都可以通过迭代器,for循环今进行遍历
s = {1, 2, 3, 5}
# 生成有个迭代器
its = iter(s)
for i in its:
print(i, end=" ") # 1 2 3 5
for j in s:
print(j, end=" ") # 1 2 3 5 |
8ffe566474131ad291d21addedd9ce887919eaac | wmm98/homework1 | /视频+刷题/第四章练习/整数排序.py | 367 | 3.515625 | 4 | '''
输入n的值和n个数,进行排序并输出。
【输入形式】
首先输入整数个数n;
接着输入n个整数
【输出形式】
从小到大地输出n个整数
【输入示例】
3
1 5 -10
'''
n = int(input())
num = input().split()
list = []
for j in num:
j = int(j)
list.append(j)
list.sort()
for r in list:
print(r, end=' ') |
de629997919bc82b0920099d06e61d8ad542df7f | wmm98/homework1 | /视频+刷题/python5/init方法.py | 472 | 3.59375 | 4 | class Cat:
# 属性
def __init__(self):
print("哈哈哈哈哈哈哈哈")
def run(self):
print("它在跑")
def sleep(self):
print("它在睡觉")
def introduce(self):
print("%s的年龄是%d" % (self.name, self.age))
tom = Cat()
tom.name = "汤姆"
tom.age = 34
tom.run()
tom.sleep()
tom.introduce()
blue_cat... |
e76bb25deb31dbd733aed3ea99d38908e033574c | wmm98/homework1 | /叶常春视频例题/chap10/10-1-5-读入100万位的pi.py | 436 | 3.546875 | 4 | #例10-1-5 读入100万位的圆周率
filename = 'chap10-data/pi_million_digits.txt' #chap10-data和本python文件在同一目录
with open(filename) as file_object:
lines = file_object.readlines()
pi_string = ''
for line in lines:
pi_string += line.strip()
print(pi_string[:52] + "...")
print(len(pi_string))
print("上面,圆周率是用字符串存储的。转换为浮点数看看...... |
f8e5d04287b986205bcf4711c69a0cdb39925a33 | wmm98/homework1 | /叶常春视频例题/chap02/2-3-9-换行符制表符.py | 444 | 3.765625 | 4 | #例2-3-9 换行符和制表符
print("I'm Bob. What's your name?") #没有换行
print("I'm Bob.\nWhat's your name?") #有换行
#制表符
#制表符的写法是\t,作用是对齐表格的各列。
print("学号\t姓名\t语文\t数学\t英语")
print("2017001\t曹操\t99\t\t88\t\t0")
print("2017002\t周瑜\t92\t\t45\t\t93")
print("2017008\t黄盖\t77\t\t82\t\t100")
#详情参阅http://blog.csdn.net/yedouble/article/detail... |
86bcf759663bf85c225c3e3560fe0d3dbfdc0c90 | uschwell/DI_Bootcamp | /Week4 (18.7-22.7)/Day3 (20.7)/DailyChallenge/ceaser_cypher.py | 1,747 | 4.21875 | 4 | from typing import final
alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
#function that builds an encryption dictionary
def build_dict(shift):
shift=int(shift)
dict={}
for letter in range(len(alphabet)):
if(letter+shift)<len(alpha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.