The problem with Python exercises is as follows:Description: There are four numbers, respectively: 1, 2, 3, 4Question: How many three digits can be composed of different and non-repeating numbers? What's the number? for in range (1,5): is in range (1,5): for in Range (1,5): ifand and shi!=ge: Print (bai,shi,ge) Else: ContinuePython mathemati
Tag: the sum () function provided by Python can accept a list and sum please write a prod () function to accept a list and use the reduce () to calculate the product:1 #Python提供的sum () function can accept a list and sum, write a prod () function, you can accept a list and use reduce () to calculate the product:Code:2 3 from Functools import reduce 4 Li = [1,2,3,4,5,7] 5 print (sum (LI)) 6 7 def prod (x, y):
located?M. Gets a subsequence that does not contain the last character. such as: Oldboy to obtain the oldbo; Root gets the roo21. Can a string iterate over an object? Can I use a for loop for each element?As long as the For loop is an iterative object22, please use the code to achieve:A. Using underscores to stitch each element of a list into a string, Li = "Alexericrain"B. Use an underscore to stitch each element of the list into a string, Li = [' Alex ', ' Eric ', ' Rain '] (optional)v = "_".
Write a script to determine whether the 80 port of the machine is open, if you do not open anything, if the discovery of the port does not exist, then restart the httpd service, the concurrent mail notify you yourself. Once the script is written, it can be executed every minute, and a dead loop script can be written, and 30s is detected once.#!/usr/bin/env python#!coding=utf-8Import OSImport timeImport SysImport SmtplibFrom Email.mime.text import Mime
Python syntax exercises-for loop
#! /Usr/bin/env python #-*-coding: utf8-*-age = 26 for I in range (3 ): intput = int (input ("Please guess my age:") if intput
The above is the content of the for loop in the Python syntax exercise. for more information, see The PHP Chinese website (www.php1.cn )!
"python exercise 027" to sort 10 numbers---------------------------------------------There is nothing to say, use Str.split (") to get the input 10 numbers, and then use the Lst.sort () to complete the sorting. The code is as follows:s = input (' Please enter 10 digits separated by a space: ') n = [int (x) for x in S.split (")]n.sort () print (n)The output results are as follows:
Please enter 10 digits separated by a space: 3 23 4 64 6 17 80 212
"python exercise 009" prints out all the "daffodils", the so-called "daffodils number" refers to a three-digit number, whose numbers are cubic and equal to the number itself. For example: 153 is a "narcissus number", because the 153=1 three times the square +5 of the three +3 Times Square.----------------------------------------------------------------------This problem is also sent to the sub-problem, as long as can be any three digits of the hundred
meters high landing, a total of 296.875 meters, and then rebounded to 0.78125 meters.The 8th time from 0.78125 meters high landing, a total of 298.4375 meters, and then rebounded to 0.390625 meters.The 9th time from 0.390625 meters high landing, a total of 299.21875 meters, and then rebounded to 0.1953125 meters.The 10th time from 0.1953125 meters high landing, a total of 299.609375 meters, and then rebounded to 0.09765625 meters.
That is: the 10th time Landing, a total of 299.609375 meter
"python exercise 023" there are 5 people sitting together and asking how old is the five? He said he was 2 years older than the 4th one. Asked the age of 4th, he said he was 2 years older than the 3rd man. Asked the third person, and said that the 2nd People's Congress two years old. Ask the 2nd person, who says two years older than the first one. Finally asked the first person, he said is 10 years old. How old is the fifth one?-----------------------
Python core programming-exercises-Chapter 2, Chapter 2
PS: PDF online address: http://bcmi.sjtu.edu.cn /~ Zhaohai/ptm2012/data/Python-kernel.programming.v2.pdf
2-1 variables, print and string formatting operators. Start the interactive interpreter, assign values (strings, values, and so on) to some variables, and display their values by entering the variable name
# Editor: Shanlong l = [2, 3, 4, 5, 6,7 for in# get a new list L1, each element in the new list is the square of the value of each element in L /c6>printforif i > Max]# filter out values greater than 40 in L1 and sum print(sum (L1))Above, there's nothing to say#edited by: ShanlongShares = { 'IBM': 36.6, 'Lenovo': 27.3, 'Huawei': 40.3, 'Oldboy': 3.2, 'Ocean': 20.1}#question one: A list of stock names with a stock price greater than 30L = [i forIinchSharesifFloat (shares[i]) >30]
=str (Li[i]) v = " _ " .join (LI) print (v) li=["aa","bb", 123] for in (0,len (LI)-1): li[i]=str (li[i]) v="_". Join (LI) Print (v)6. A list is known to use enumrate output elements and sequence numbers starting from 100li=["aa","bb", 123] for in Enumerate (li,100): print(i,q)Enumerate(sequence, [start=0]) Start-the subscript start position.7. Make a 301-length list and implement paging function page 10 dataLi=[] forIteminchRange (1,302): Temp={id:"
Python Basics Exercises 11. Two ways to execute Python scriptsAnswer: command line execution, editor execution2, briefly describe the relationship between bits and bytesA : Byte byte bit: bit, 1 bytes = 8 bits3. brief description of the relationship between ASCII, Unicode, Utf-8,GBKFor:ASCII is the first United States to use the standard Information Interchange c
4-1.Python object. What are the three attributes related to all Python objects? Please briefly describe it.[Answer]All Python objects have three features: identity, type, and value.Identity: each object has a unique identity. The identity of any object can be obtained using the built-in function id. This value can be considered as the memory address of the object
#encoding =utf-8Import Random#dict. Update (DICT2) a adds the key-value pairs of the dictionary dict2 to the dictionary dict# 7–1. Dictionary method. Which dictionary method can be used to merge two dictionaries together?Dict1 = {1: ' W ', 2: ' Y '}Dict2 = {3: ' t '}Dict1.update (DICT2)Print Dict1# 7–2. The key for the dictionary. We know that the value of the dictionary can be any Python object, what about the key of the dictionary? Please try# with
classes. Provides an interface to a time module that allows the user to format their own given times, such as:# "Mm/dd/yy," "Mm/dd/yyyy," "Dd/mm/yy," "Dd/mm/yyyy," "Mon DD, YYYY," or standard# Unix Date format: "Day Mon DD, HH:MM:SS YYYY" to see the date. Your class should maintain a date value, and# Create an instance with the given time. If no time value is given, the current system time is taken by default when the program executes. Also package# includes some other methods:# Update () modif
How many vowel letters are there?There is a string "I learn Python from Maya", we want to find out the vowel (aeiou) in it (actually find out these lowercase letters), and count the number of its vowel characters. At this point we can combine the conditional statement and the Loop statement to process the string.#sentence is a string that you need to count the number of vowels in this stringSentence ="I Learn Pyth
absolute value of the coefficients is required, and the increment or decrement function has been determined by the coefficient symbol.Since the coefficients have been determined, the following need to solve is the intercept problem (according to the geometrical meaning I understand the term), if according to the concept of geometrical intercept is very well understood, if x=0, y>=0, then the symbol of intercept is "+", and vice versa is "-", since the symbol is determined, Then the value can on
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.