
练习
Schatzke
坚持每天码字码代码
展开
-
Python exercise 12 - List Ends
Python exercise 12 - List Ends'''Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. For p...原创 2019-02-22 02:37:28 · 252 阅读 · 0 评论 -
Python exercise 15 - Reverse Word Order
Python exercise 15 - Reverse Word OrderExercise 15 (and Solution)Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same st...原创 2019-04-12 17:24:51 · 300 阅读 · 0 评论 -
Python exercise 14 - List Ends
Python exercise 14 - List EndsWrite a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates.Extras:Write two diffe...原创 2019-04-12 17:18:16 · 253 阅读 · 0 评论 -
Python exercise 13 - Fibonacci
Python exercise 13 - FibonacciWrite 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 s...原创 2019-04-12 17:13:51 · 267 阅读 · 0 评论 -
Python exercise 7 - List comprehension
Python exercise 7 - List comprehensionLet’s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write one line of Python that takes this list a and makes a new list...原创 2019-04-12 17:02:57 · 224 阅读 · 0 评论 -
Python exercise 6 - string & list
Python exercise 6 - string & listAsk the user for a string and print out whether this string is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.)Code 1...原创 2019-04-12 17:01:17 · 223 阅读 · 0 评论 -
Python exercise 5 - List Overlap
Python exercise 5 - List Overlap Take two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] and write a program that retu...原创 2019-04-12 16:57:57 · 443 阅读 · 0 评论 -
Python exercise 4 - divisors
Python exercise 4 - divisors Create a program that asks the user for a number and then prints out a list of all the divisors of that number. (If you don’t know what a divisor is, it is a numb...原创 2019-04-12 16:52:47 · 369 阅读 · 0 评论 -
Python exercise 3 -list & lambda
Python exercise 3 -list & lambda Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a program that prints out all the elements of the list tha...原创 2019-04-12 16:49:30 · 226 阅读 · 0 评论 -
Python exercise 11 - Check Primality Functions
Python exercise 11 - Check Primality Functions'''Ask the user for a number and determine whether the number is prime or not. (For those who have forgotten, a prime number is a number that has no div...原创 2019-02-21 00:35:40 · 215 阅读 · 0 评论 -
Python exercise 10 - List Overlap Comprehensions
Python exercise 10 - List Overlap Comprehensions'''This week’s exercise is going to be revisiting an old exercise (see Exercise 5), except require the solution in a different way.Take two lists, sa...原创 2019-02-20 00:52:37 · 225 阅读 · 0 评论 -
你有一行Python代码情书未拆封
马上就是情人节了,试试下面这行代码,画一个爱心原创 2019-02-14 02:16:43 · 2200 阅读 · 0 评论 -
Python exercise 2 - Odd or Even
Python exercise 2 - Odd or Even''' Exercise 2 - Odd or Even Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a program that prints out all the elements ...原创 2019-02-18 02:48:29 · 467 阅读 · 0 评论 -
PYTHON Exercise 1 Input & Print
Exercise 1 - Input & Print'''Exercise:Create a program that asks the user to enter their name and their age.Print out a message addressed to them that tells them the year that they will turn 1...原创 2019-02-18 02:48:15 · 223 阅读 · 0 评论 -
Python exercise 9 - Guessing Game
Exercise 9 - Guessing Game'''Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. ...原创 2019-02-18 02:47:54 · 407 阅读 · 0 评论 -
Python exercise 8 - Rock Paper Scissors
Exercise 8 - Rock Paper Scissors'''Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask ...原创 2019-02-17 00:56:47 · 337 阅读 · 0 评论 -
Python exercise 16 - Password Generator
Python exercise 16 - Password GeneratorWrite a password generator in Python. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers...原创 2019-04-12 17:28:27 · 384 阅读 · 0 评论