Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / NewStats: 2,483,468 members, 5,624,054 topics. Date: Thursday, 28 May 2020 at 04:59 PM

## Python 3: Exercises And Solutions. - Programming (4) - Nairaland

(1) (2) (3) (4) (5) (Reply) (Go Down)

 Re: Python 3: Exercises And Solutions. by Daddyshome: 8:49am On May 01 Collinsanele:Nice but if there's no unique item, then, you would have an index error.OK, then I'll put an if statement. def unique_num(lis): unique = [x for x in lis if lis.count(x) == 1] if len(unique) > 0: return unique[0] 1 Like Re: Python 3: Exercises And Solutions. by Daddyshome: 8:54am On May 01 gbolly1151:Check your code bro,it doesn't seem rightIt's the indentation. Re: Python 3: Exercises And Solutions. by Brukx(m): 11:32am On May 01 jayphe:Collinsanele, Taofeekdboy, kensmoney another one is here!Exercise 3Write a Python program that accepts day, month and year from the user and prints the result in this form:Today is 23/04/2020For example,Input:day = 21mnth = 07year = 2010Output:Today is 21/07/2010Good luck guys!#Write a Python program that accepts day, month and year from the user and prints the result in this form#prompt user to input datesday=eval(input("day")mnth=eval(input("mnth")year=eval(input("year")#display outputprint(day,"/",mnth,"/",year) Re: Python 3: Exercises And Solutions. by Brukx(m): 11:34am On May 01 Taofeekdboy:I saw this late, I have been busy with my project and it took a lot of my time. I will leave it here for who is interested to check..It is a social media clone I made. http://mysocialapp.pythonanywhere.comLooking forward to your commentsHow did you get a server? Re: Python 3: Exercises And Solutions. by Brukx(m): 11:37am On May 01 jayphe:Collinsanele Taofeekdboy kensmoney Daddyshome Zabiboyhmm....who else ooo? Let's get to business. Pls, let's try to read the question in details first. If the question asks for the users' input, then we should include an input statement. Zabiboy we need to talk ooo. This one wey I no see you....Exercise 4We are doing some 'loop and looping stuffs' today.Write a Python program that accepts the name of a student, matric number, course code and the score he/she got in the course. E.gName: John AlfredMatric. No.: MUC/CS/014/0882Course Code: CMP 212Score: 100The program then print the result as:John Alfred, MUC/CS/014/0882, CMP 212, Grade AUsing this grading table.100-95 A94-85 B84-70 C69-60 D59-50 E49-0 FCorrections, advices, suggestions and opinions are highly welcome! what should be the inputable variables in this program? Re: Python 3: Exercises And Solutions. by Brukx(m): 11:49am On May 01 jayphe:Exercise 6Write a Python program that accepts an integer number and checks if it is an even number or an odd number. Pls don't use the % (modulus) operator. Let's see some genuius.#prompt user to enter numbernumber=eval(input("input number:")if number/2==0: print("The number is even" else: print("The number is odd"Nairaland will likely modify some of the codes into smiley Re: Python 3: Exercises And Solutions. by SKYQUEST(m): 6:49pm On May 01 Collinsanele:Where can I get the datasetHERE Re: Python 3: Exercises And Solutions. by yemyke001(m): 2:15am On May 04 SKYQUEST:Great job guys!Write a python program where python LOOKS FOR Total Assets and Total liabilities in the attached table and returns the value of the ratio of the two given variables as per their values in the table.import pandas as pddf = pd.read_excel('naira.xlsx')t_assets= df[df.iloc[:,0]=='Total Assets'].iloc[:, 1].valuest_liabilities=df[df.iloc[:,0]=='Total Liabilities'].iloc[:,1].valuesprint(f'The ratio of total_assets to total_liabilities is {t_assets} : {t_liabilities} which is equal to:', (t_assets/t_liabilities)) Re: Python 3: Exercises And Solutions. by yemyke001(m): 2:17am On May 04 Using python xlrd library:import xlrdf = xlrd.open_workbook('naira.xlsx') file=f.sheet_by_index(0)total_a =file.cell_value(8,1)total_l=file.cell_value(17,1)print(f'The ratio of total_assets to total_liabilities is {total_a} : {total_l} which is equal to: ',total_a/total_l) Re: Python 3: Exercises And Solutions. by jayphe(m): 11:41am On May 09 Phew!! I'm sorry for that long break. I know many people for don vex. I'm sorry. I'm back with an exercise but this one is kinda simple.Exercise 7Write a Python program that accepts data from the user be it integer, string, char, float or double. The program stores these in a container/array (list or tuple)Finally, the program accepts an index from the user and uses the index to find the respective element if the array created. The program then prints the result.e.g., Let's say a user inputs the following:Sam12BenLagos22ToluThe user then input 3 as the index, the program must return 'Ben' as the output.Collinsanele Taofeekdboy kensmoney Daddyshome Zabiboy and lots more...lol! Re: Python 3: Exercises And Solutions. by Collinsanele: 3:58pm On May 09 jayphe:Phew!! I'm sorry for that long break. I know many people for don vex. I'm sorry. I'm back with an exercise but this one is kinda simple.Exercise 7Write a Python program that accepts data from the user be it integer, string, char, float or double. The program stores these in a container/array (list or tuple)Finally, the program accepts an index from the user and uses the index to find the respective element if the array created. The program then prints the result.e.g., Let's say a user inputs the following:Sam12BenLagos22ToluThe user then input 3 as the index, the program must return 'Ben' as the output.Collinsanele Taofeekdboy kensmoney Daddyshome Zabiboy and lots more...lol!Shouldn't Lagos have an index of 3 from your example Re: Python 3: Exercises And Solutions. by Zabiboy: 4:35pm On May 09 Collinsanele:Shouldn't Lagos have an index of 3 from your exampleIndex numbers start from 0 Re: Python 3: Exercises And Solutions. by yemyke001(m): 7:15pm On May 09 jayphe:Phew!! I'm sorry for that long break. I know many people for don vex. I'm sorry. I'm back with an exercise but this one is kinda simple.Exercise 7Write a Python program that accepts data from the user be it integer, string, char, float or double. The program stores these in a container/array (list or tuple)Finally, the program accepts an index from the user and uses the index to find the respective element if the array created. The program then prints the result.e.g., Let's say a user inputs the following:Sam12BenLagos22ToluThe user then input 3 as the index, the program must return 'Ben' as the output.Collinsanele Taofeekdboy kensmoney Daddyshome Zabiboy and lots more...lol!data = [val for val in input().split(',')]index_ = int(input())print(data[index_])Meanwhile python indexing start from 0 Re: Python 3: Exercises And Solutions. by Daddyshome: 7:56am On May 10 jayphe:Phew!! I'm sorry for that long break. I know many people for don vex. I'm sorry. I'm back with an exercise but this one is kinda simple.Exercise 7Write a Python program that accepts data from the user be it integer, string, char, float or double. The program stores these in a container/array (list or tuple)Finally, the program accepts an index from the user and uses the index to find the respective element if the array created. The program then prints the result.e.g., Let's say a user inputs the following:Sam12BenLagos22ToluThe user then input 3 as the index, the program must return 'Ben' as the output.Collinsanele Taofeekdboy kensmoney Daddyshome Zabiboy and lots more...lol!Are the inputs on the same line? Re: Python 3: Exercises And Solutions. by Cuterboy: 8:13am On May 10 Collinsanele:I am afraid you are not correct.Coding is not about syntax but thinking and problem solving.If you write a program to solve a quadratic equation and it fails, you simply debug it and try again, that's testing, you must not be correct in one go.And Nigerians have good coders fyiDo you even understand the syntax he's talking about?Like x^2 + 5x -6 or \sqrt(5x²)http://9jababa.com/junior-maths-are-you-sure-you-can-solve-this-simple-junior-maths/ Re: Python 3: Exercises And Solutions. by jayphe(m): 7:57pm On May 10 Thanks for the opinion. I was talking in view of the user. I know the index starts from 0. You wouldn't expect the user to type 4 and the program return the 3rd value he entered. Re: Python 3: Exercises And Solutions. by Zabiboy: 8:31pm On May 10 Then use index+1 in your code Re: Python 3: Exercises And Solutions. by Hotspotbro(m): 1:08pm On May 11 #project of Hotspotbro print('Welcome to Whoop, our New social media site') Name=input('Enter your Email address')Password=input('Enter your choice password >') Re: Python 3: Exercises And Solutions. by SKYQUEST(m): 3:25pm On May 22 yemyke001:import pandas as pddf = pd.read_excel('naira.xlsx')t_assets= df[df.iloc[:,0]=='Total Assets'].iloc[:, 1].valuest_liabilities=df[df.iloc[:,0]=='Total Liabilities'].iloc[:,1].valuesprint(f'The ratio of total_assets to total_liabilities is {t_assets} : {t_liabilities} which is equal to:', (t_assets/t_liabilities)) nice job sir. Re: Python 3: Exercises And Solutions. by chitunelee(m): 5:42pm On May 22 Nyc job guys. I'm kinda new in programming can you guys help me with the benefits python has over other languages Re: Python 3: Exercises And Solutions. by yemyke001(m): 6:03pm On May 22 SKYQUEST:nice job sir.Thanks boss Re: Python 3: Exercises And Solutions. by SKYQUEST(m): 12:06pm On May 23 what python code would you run on a table with data separated by spaces as shown in the image below to convert it in into a readable excel table; the raw data is also given in the attachment below (ben2): Re: Python 3: Exercises And Solutions. by nwele2017: 12:54pm On May 23 SKYQUEST:what python code would you run on a table with data separated by spaces as shown in the image below to convert it in into a readable excel table; the raw data is also given in the attachment below (ben2):Using Pandas read it in as CSV then convert it to xlsx using data name .to_excel.(ie. name of data .yo_excel("name.xlsx" Re: Python 3: Exercises And Solutions. by SKYQUEST(m): 1:38pm On May 24 nwele2017:Using Pandas read it in as CSV then convert it to xlsx using data name .to_excel.(ie. name of data .yo_excel("name.xlsx"can you read this as CSV, will it work?, methinks the file is not comma separated file. Re: Python 3: Exercises And Solutions. by gbolly1151(m): 3:29pm On May 24 SKYQUEST:can you read this as CSV, will it work?, methinks the file is not comma separated file.I think read_csv take optional argument delimiter which can be comma,using spaxe should work Re: Python 3: Exercises And Solutions. by Sunijacks(m): 4:23pm On May 24 How long does it take to learn and become this good with python? Re: Python 3: Exercises And Solutions. by gbolly1151(m): 4:40pm On May 24 Reserve Re: Python 3: Exercises And Solutions. by HappyPagan: 12:30am On May 25 Nice thread. Hope I'm not too late to the party. Let me start from the beginning. Re: Python 3: Exercises And Solutions. by HappyPagan: 12:34am On May 25 jayphe:Exercise 1Write a python program that obtains the domain name (thapar.edu) from the URL http://www.thapar.edu/index.php/about-us/missionurl = "https://www.makeuseof.com/tag/browser-text-based-games/"fullStopIndex = url.find('.')forwardSlashIndex = url[fullStopIndex:].find('/')domain = url[fullStopIndex + 1:fullStopIndex + forwardSlashIndex]print(domain)Code snippet here Re: Python 3: Exercises And Solutions. by HappyPagan: 12:42am On May 25 jayphe:Write a Python program that accepts a string/sentence from the user. The program then changes all spaces to underscores. Finally, it prints out the final result.userInput = input('Enter a sentence: ')output = ''for c in userInput: if c==' ': output = output + '_' continue output = output + cprint(output)Code snippet Re: Python 3: Exercises And Solutions. by HappyPagan: 12:49am On May 25 jayphe:Write a Python program that accepts day, month and year from the user and prints the result in this form:Today is 23/04/2020day = input('Enter a day (1-30): ')month = input('Enter a month (1-12): ')year = input('Enter a year: ')print(f'Today is {day}/{month}/{year}')

(1) (2) (3) (4) (5) (Reply)

(Go Up)

 Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Nairaland - Copyright © 2005 - 2020 Oluwaseun Osewa. All rights reserved. See How To Advertise. 119Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.