Job Content:Implementation results:Read employees and their payroll information from the Info.txt file, and finally write the revised or increased employee payroll information to the original Info.txt file.Effect Demo:1. Check the employee's salary2. Revise employee's salary3. Add new Employee Records4. ExitIdeas:File reading and writing, read or write data using the Strip and split method, the contents of the file to increase the searchFlowchart: (Pe
First write a little put up, not complete, Monday to the company in the optimization bar.Here the user input is written to the file, using variables, this variable was studied overnight.F.write ('%s \ n% variable ') also unexpected variables are written outside ().Localhost:pythondong$catdenglu.py#!/usr/bin/envpythonf=open ('/Users/ Dong/documents/java/python/zh ', ' W ') Logou_flag=falseforiinrange (3): user_input=raw_input (' please,user: '). Strip
, which does not match by default. #determine whether user input and pass matches the file, do not deserve to continue the loop, match on the exit. Print 'User unmatched!'Retry_count+=1Else : Print('welcom to in Feifei blog system!')Else: Print("You are locked!") F=file (Lock_file,'AB') F.write (username) f.close ()Homework:Writing the Login interfaceEnter User name passwordShow welcome message after successful authenticationThree-time error after lockingThe first day o
Job 2:There is a list of List1 = [All-in-one, ' a ', ' B ', 4, ' C ']There is an unknown dictionary dict1, unclear internal key value pair conditionIf the Dict1 dictionary does not have a ' K1 ' key value pair, then create and set the value of the key to an empty list and add the elements of the odd index bit in the List1 into the listIf the Dict1 dictionary has a ' K1 ' key-value pair and the corresponding value is a list type, add the elements of th
Job 1: Combining nestingLike the following list, each function is implemented as requiredlist = [[' K ', [' qwe ', 20,{' K1 ': [' TT ', 3, ' 1 ']},89], ' AB ']Turn TT into uppercase, in two waysConverts the number 3 to the string ' 100 ', implemented in two waysConvert the string ' 1 ' to the number 101, implemented in two waysIdeaTake the serial number of the TT directly, then replace; Find TT, then capitalize;Also, note that strings are quoted, numb
The user has three chances to log in, log in successfully, display the Welcome screen.Three login failed, account locked, next logon failed.Ideas:1: Process Control: For or while loop, up to three detection purposes.2: File operation.Detect the document, once the input account name is found in the locked document, display lock, Login failed.First time without optimized version code:#_ *_coding:utf-8_*_times = 0 # initial number of 0Username = "Wuqiangroy" UserPassword = "123321" f = open ("Aaa.t
: parentheses are used to receive Parameters. if more than one parameter is passed in: the value should be passed in the first position and then the specific incoming order should be determined according to the parameters defined by the function 3. Return value If the function has a return value, you should also define "variable" to receive the return value if the return value has more than one, You can also use multiple variables to receive, the number of variables sho
#@make_cashe#def get (URL):#return Urlopen (URL). Read ()#declare an empty dictionary at the beginning of the file, and then add an adorner to each function to do the automatic addition to the dictionary#fun_dic={}#def Outer (key):#def outer (func):#def wrapper (*args,**kwargs):#Fun_dic[key]=func#return wrapper#return outer# #@Outer (' F1 ')#def f1 ():#print (' from F1 ')#@Outer (' F2 ')#def f2 ():#print (' from F2 ')#@Outer (' F3 ')#def f3 ():#print (' fromt f3 ')#F1 ()#F2 ()#f3 ()#print (fun_d
Product_list = [("Iphone", 6000),("Mac Pro", 12800),("Bike", 600),("Watch", 8000),("book", 24),("Offee", 35),]Shopping_list = ()Salary = (Input ("Please enter your purchase:"))If Salary.isdigit (): # To determine if the value entered is numeric, then continuesalary = Int (salary)While True:For item in Product_list:Print (Product_list.index (item), item) # Prints the list's subscript and listUser_choice = input ("Please enter the item number you want to purchase:")If User_choice.isdigit ():user_c
1. Simple input/output interaction.Name=input (' What's Your name?\n ')What is your name?MonPrint (' hi,%s. '%name)Hi,mon.2, the user input two numbers, calculate and output two numbers of the sum:M=input (' input: ') attempts to implement this function with just one line of code:Input:5 Print(' num1+num2=%.1f ' % (float(input (' Please enter n UM1: ')+float(input(' Please enter num2: ') ))) N=input (input: ') Please enter num1:22Input:7 Please enter Num2:2M+n num1+num2= 44.057.0Float (m) +
:", lockd_users) whileCount: Username= Input ("Username:"). Strip () password= Input ("Password:"). Strip ()ifUsernameinchLockd_users:exit ("User is locked") if notFirst_input_user:#If there is no value, it represents the first timeFirst_input_user =usernameifUsername! =First_input_user:is_same_user= False#multiple inputs are not the same user name for_userinchUser:if_user[0] = = Username and_USER[1] = =Password:Print("Login Successful! [%s] Welcome to enter"%username) Pass_auth_flag= Tr
Count = 0While Count Username = input ("Username:") Password = input ("Password:") "" Enter User password If username = = "Pang" and password = = "Pang123": Print ("Welcome") Break ‘‘‘‘‘‘ Enter Pang and pang123 to have a welcome printout and end Loop Else Print ("Try Again") "" or print and try again Count +=1 "" Cycle +1Else Print ("You have tried too many times,you is locked")' ' ' cycles more than three times to print the numb
1. Use while loop input 1 2 3 4 5 6 8 9 10 while Count : if count = = 7: = count + 1 continue Print (count) = Count + 12. For all numbers of 1-100Count = 1 sum = 0while count 3. All odd numbers in output 1-100Count = 1 while Count 4. All even numbers in output 1-100Count = 1while count 5, Beg 1-2+3-4+5 ... 99 of all numbers of the andCount = 1 sum = 0 while Count 6. User Login (three chance retry)Count = 1sum = 0while count Python
Functional Requirements:Require users to enter total assets, for example: 2000Display the list of items, let the user select the item according to the serial number, add the shopping cartPurchase, if the total amount of goods is greater than the total assets, indicating that the account balance is insufficient, otherwise, the purchase succeeds.Add: Can recharge, a product to remove the shopping cartgoods = [ {"Name": "Computer", "Price": 1999}, {"Name": "Mouse", "Price": 10}, {"Name": "
1. Login Job:Write a login program, login success, prompt xxx Welcome login, login failure is 3 times, to check the case of the input is empty1 forIinchRange (3):2Username=input ('Username:'). Strip ()3Passwd=input ('passwd:'). Strip ()4 ifUsername andpasswd:5 ifusername=='Weixiaocui' andpasswd=='123456':6 Print('%s Welcome Login'%username)7 Break8 Else:9 Print('account/Password error')Ten Else: One Print('account/password ca
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.