python tutorial with exercises

Read about python tutorial with exercises, The latest news, videos, and discussion topics about python tutorial with exercises from alibabacloud.com

Python Input and output exercises

Hello world! Simple Interactive (interactive, file-style) textbook P19 The user enters two numbers and calculates and outputs the sum of two digits: The user enters the triangular three-side length and calculates the area of the triangle: (Helen Formula) Enter a radius to calculate the area of the circle. Draw a set of identical tangent circles Draw a Pentagram Draw an all-yellow pentagram 1Hello WorldPrint ("helloWorld")2 Simple Interactive (interactive, file-st

Python Basics Exercises

1.>>> Name=input (' What's Your Name: ')What's your name: JYX>>> Print (name)JYX2.>>> print (' Two sum of%s '% (float (input (' Enter the first number: ') +float (Input (' Enter second number: ')))Enter the first number: 1Enter a second number: 2The sum of the two numbers is 3.0>>>3.>>> r=input (' radius of Input circle: ')Radius of input Circle: 2>>> t=3.14>>> Print (the area of the circle is:%.1f '% ((float (r) **2) *t))The area of the circle is: 12.6>>>Py

Python Basics Exercises

Simple input-Output interactionInput (' Please input your name: ')Please input your name:xx' XX '>>> name= ' AA '>>> Print (name)Aa>>> Name=input (' What's Your name?\n ')What is your name?Ss>>> print (' hi,%s '%name)Hi,ss2. The user enters two numbers, calculates and outputs the sum of two digits: (try to do this with just one line of code)Print (' Two sum of%s '% (float (input (' Enter the first number: ') +float (Input (' Enter the second number: ')))Enter the first number: 5Enter a second nu

Python Exercises (i)

Python Practice (i):Give a positive integer of no more than 5 digits, and judge how many of them, in turn, print out the digits of single, 10, Hundred, thousand, and million digits:Num=int (Input (' pleaseenteranumber: ')) lst=[]for NBSP;INBSP;INNBSP;STR (num): lst.append (i) Lenlst=len (LST) if num>=1000:ifnum>=10000: print (' Toobig ') else: print (' 4-digit ') else:ifnum>=100: print (' 3-digit ') elifnum>=10 : print (' 2-digit ') elifnum>= 0:print

Ii. Basic Python Exercises

1. Simple input/output interaction.Age=input ( ' Please enter age:')print('wow,%s. '%age)2. The user enters two numbers, calculates and outputs the sum of two digits: (try to do this with just one line of code)# receive a digital x=input(' Please enter the first number:') y=input (' Please enter the second number:') )# sum sum=float (x) +float (y)# Show results Print (' two number added result:%.2f'%sum)3. Enter a radius to calculate the area of the circle.π=3.14# Enter the radius of the Circle

Python Basics Exercises

1. Simple input/output interaction.Print (' information interaction ') name=input (' Please enter a name ') print ( ' hi,%s. '%name)2. The user enters two numbers, calculates and outputs the sum of two digits: (try to do this with just one line of code)Print'sum of two numbers') #输入数字a=input ('Please enter the first number:') b=input ('Please enter a second number:') #求和sum=float(a) +float(b) #输出print ('the%.2f of two numbers:'%sum) #一句话输出print ('two numbers of the and for%.2f'%(float(Input ('Pl

Python Basics Exercises

1. Simple input-output interaction. , NB Sp , NB Sp , NB Sp , NB Sp , NB Sp , NB Sp Number=input (' Please enter school number:')print2. The user enters two numbers, calculates and outputs the sum of two digits: (try to do this with just one line of code)# user Input number a=input (' Enter first number:') b=input (' Enter second number:') )# summation sum=float (m) +float (n)# show sum re

Python Basics Exercises

Simple input-output interaction.# Enter name=input (' Please enter your name:')# output print(name)Please enter your name: Loeloe The user enters two numbers and calculates and outputs the sum of two digits: (try to do this with just one line of code) # Enter first number n=input (" Enter the first number: " ) # Enter the second number m= Input ( Enter the second number: " ) # sum Sum=float (n) +float (m) # output print (" Two of the sum of:%2f "%sum) Please enter th

Python Basics Exercises

1. Simple input/output interaction. n=input ( " please input: " ) name =input ( "" Span style= "COLOR: #800000" >input: " ) print (N+name) sum =int (n) +int (name) print ( Two numbers and is:%i "% sum) name = " arashi " print ( " say%s %name) 2. The user enters two numbers, calculates and outputs the sum of two digits: (try to do this with just one line of code)Print (' two digits ' and:%.2f'% (float (input (' Enter first number:') ') +float (input ( ' Please enter a second nu

Python Basics Exercises

1. Simple input/output interaction. >>> old=input ('How old isyou?\n') How is old is you? Print ('I am %s'% old) I am 2, the user input two numbers, calculate and output two numbers of the sum: (try to use only one line of code to achieve this function) n1=input ( Enter the first number: " ) n2 =input ( " Span style= "COLOR: #800000" > Enter the second number: " ) Sum =float (N1) +float (n2) print ( Span style= "COLOR: #800000" > " Two sum of:%.2f ' % R=input (' Please en

Python Basics Exercises

1. Simple input/output interaction.Print (' Hello wrold! ‘)Name = input (' Please input name: ')2. The user enters two numbers, calculates and outputs the sum of two digits: (try to do this with just one line of code)The result of print (' two number addition is:%.1f '% (float (input (' Enter the first number: ')) +float (Input (' Input second Number ')))3. Enter a radius to calculate the area of the circle.R = input (' radius of Input circle: ')Print (' This is the area of a circle:%.1f '% ((fl

Job 2--python Basic Exercises

1. Simple input/output interaction.Input (' Please input your name: ')Please input your name:coffee ' coffee ',2, use a formula to find out the sum of two.X=input (' Enter first number: ')Enter first Number: 1Y=input (' Enter second number: ')Enter second number: 5Sum=float (x) +float (y)Print (sum)6.03, the input radius, to find the area of the garden.R=input (' r= ')R=3S=float (R) *float (r) *3.14Print (S)28.26Job 2--python Basic

Python Input and output exercises

Hello world! Simple interaction (Interactive, file-style) The user enters two numbers, calculates and outputs the sum of two digits (try to implement it in one line of code). The user enters the triangular three-side length and calculates the area of the triangle: (Helen Formula) 1 A = float (input ("a="))2 B = float (input ("b=")) 3 c = float (input ("c="))print(' Triangle area is%0. 2f' %area) Enter a radius to calculate the area of the circle. Radius = float ( i

Len in Python exercises: Get and output the indexes and corresponding elements in the collection

Len () is used to obtain values such as length, byte, etc.1 a = ["hello""World""dlrb" ]2 b = len (a)3 for in range (0, b): 4 Print (c, A[c])Output Result:0 Hello1 World 2 DLRBWe define the set a, which is given by Len to the number of elements in the collection to the variable B, in the For loop by traversing from 0 to variable B to get all the indexes to the variable CA[C] The corresponding element is found by index, the last print output index and the corresponding elementLen in

Python, looping exercises

("Congratulations, you are male! ") Else: Print("Hershey, you're not a man! ") Else : Print("you entered the wrong ID number, please verify and try again! ")Else : Print("The information base does not change the document number! ")Vii. calculation of the day of the weekA = input ("Please enter a number (1--7)")ifint (a) = ='1': Print("today is: Monday")elifA = ='2': Print("today is: Tuesday")elifA = ='3': Print("today is: Wednesday")elifA = ='4':

Python Basics Exercises

Simple input-output interaction. >>>name=input (' My name is: ')My name Is:yuanyinglin>>>print (name)Yuanyinglin>>>name= ' Yuanyinglin '>>>print (name)Yuanyinglin The user enters two numbers and calculates and outputs the sum of two digits: >>>a=input (' Please enter the first number: ')Please enter the first number: 5>>>b=input (' Please enter a second number: ')Please enter a second number: 6>>>sum=float (a) +float (b)>>>print (SUM) Enter a radius to calculate the a

"Python" Two for loop nesting exercises

) -Writer.writerow (['Events','Start time','hosts','Visiting Team','Data','Home wins','Draw','The visiting team wins','Betting Distribution']) - writer.writerows (outputtr) in #csvfile.close () - #Main function to if __name__=="__main__": +Outputtr=[] -Driver =Webdriver. Chrome () theDriver.get ("http://caipiao.hao123.com/") *Movescorllbar (Driver," Down", 30, 60) $ " "Panax Notoginseng ths = driver.find_element_by_id ("Panel-zucai-jingji"). Find_elements_by_tag_name ("th") - For th in t

Python string Exercises

") BreakOperation Result:Xn2rPlease inputNGInput errorIgdpPlease inputIgdpInput successDevelop a sensitive word filter that prompts the user to enter content if the user enters content that contains special characters: such as "Ms. Cang" and "Tokyo Hot", replace the content with * * *M1=str.maketrans ("Ms. Cang","***") M2=str.maketrans ("Tokyo Hot","***") Search=input ("Please enter the content you want to search \ n")ifSearch = ="Ms. Cang": New_search=Search.translate (M1)Print(New_sear

Python Exercises (1)

1 a = 02 while a :3 A = a + 14 if a = = 7:5 pass6 else:7 Print(a)1 a = 02 b = 03 while a :4 a = a + 1 # once per loop, a will automatically add a 5 B = b + A # Each loop B will record the current value of a and add it to a 6 Print (b)1 a = 02 while a :3 a = a +14 if A% 2 = = 0: # if except 2 is equal to 05 pass #Pass placeholder, Don't do anything. 6 else: # Otherwise output odd 7 Print (a)1 a

Python several exercises (prime, Fibonacci series)

Random input Prime number:x = Int (input ("Please enter the number:")) if x! = 1: for I in range (2, x): if x% i = = 0: Break Else: Print (x)Find all the primes within 10Wc = 0for x in range (2,100000): for I in range (2, int (x * * 0.5) +1): if x% i = = 0: Break Else: c + = 1 print (x) print (c)101 items in the Fibonacci sequencex = 0y = 0for i in range (0, 102): if i = = 0: y = 1 elif i = = 1: x = 1 y = 1 else:

Total Pages: 15 1 .... 11 12 13 14 15 Go to: Go

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.