Python 3: Exercises And Solutions. - Programming (3) - Nairaland
Nairaland Forum › Science/Technology › Programming › Python 3: Exercises And Solutions. (11820 Views)
| Re: Python 3: Exercises And Solutions. by Daddyshome: 11:13pm On Apr 26, 2020 |
jayphe:string = input('Enter a string') char = input('Enter a character in the string') print('{} appears {} times in the word {}'.format(char, string.casefold().count(char.casefold()), string )) |
| Re: Python 3: Exercises And Solutions. by jayphe(op): 6:30am On Apr 27, 2020 |
kensmoney:
I love ur approach.....
|
| Re: Python 3: Exercises And Solutions. by scarplanet(m): 12:29pm On Apr 27, 2020 |
jayphe:Unfortunately, Nairaland would not allow indentation class Student: def __init__(self, firstname, lastname, matric, course): self.firstname = firstname self.lastname = lastname self.matric = matric self.course = course def grade(self, score): if score >= 95: return "A" elif score >= 85: return "B" elif score >= 70: return "C" elif score >= 60: return " D " elif score >= 50: return "E" else: return "F" def fullname(self): return "{} {}".format(self.firstname, self.lastname) first = input("Enter Firstname of Student: " ) last = input("Enter Lastname of Student: " ) matricNo = input("Enter Matriculation Number of Student: " ) coursecode = input("Enter the Course Code: " ) studentscore = eval(input("Enter the Score for Student: " )) stud1 = Student(first, last, matricNo, coursecode) print("{}, {}, {}, Grade {}".format(stud1.fullname(), stud1.matric, stud1.course, stud1.grade(studentscore))) |
| Re: Python 3: Exercises And Solutions. by jayphe(op): 8:28am On Apr 28, 2020 |
Exercise 6 Write 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. |
| Re: Python 3: Exercises And Solutions. by Shepherdd(m): 10:08am On Apr 28, 2020 |
jayphe: def check_type(val): |
| Re: Python 3: Exercises And Solutions. by nwele2017: 10:27am On Apr 28, 2020 |
jayphe:numbers=list(range(1,10000000)) even_number=int(input("Input a number:\n" )) for i in numbers: if (even_number/2)==i: print(str(even_number)+" is even an number" ) |
| Re: Python 3: Exercises And Solutions. by nwele2017: 10:49am On Apr 28, 2020 |
nwele2017:this only works when you put an even number, it cannot tell if a number is not even number |
| Re: Python 3: Exercises And Solutions. by Walkingkilo(m): 11:03am On Apr 28, 2020 |
Collinsanele:This is a quite a apt and accurate approach |
| Re: Python 3: Exercises And Solutions. by kensmoney(m): 5:59pm On Apr 28, 2020*. Modified: 7:34pm On Apr 30, 2020 |
|
| Re: Python 3: Exercises And Solutions. by SKYQUEST(m): 12:46am On Apr 29, 2020 |
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. |
| Re: Python 3: Exercises And Solutions. by scarplanet(m): 12:57am On Apr 29, 2020 |
SKYQUEST:Is this a job at your workplace or an assignment given to you? Oya confess ![]() |
| Re: Python 3: Exercises And Solutions. by hardeycute(m): 7:41am On Apr 29, 2020 |
scarplanet:Check his thread https://www.nairaland.com/5789054/python-accountants/ |
| Re: Python 3: Exercises And Solutions. by Collinsanele: 10:25am On Apr 29, 2020 |
jayphe:Write a function that takes a list of numbers and returns the first unique number in the list. (You may submit your solutions via pastebin) Example: [1,4,6,1,8,4,9] -> returns 6 |
| Re: Python 3: Exercises And Solutions. by Collinsanele: 11:06am On Apr 29, 2020 |
SKYQUEST:Can be easily done with pandas |
| Re: Python 3: Exercises And Solutions. by Collinsanele: 11:16pm On Apr 29, 2020 |
Daddyshome:contact _date list is misleading as there aren't any date in it (Lol). To use dates in Python, you can make use of the datetime module, it's straight forward, however, nice program. |
| Re: Python 3: Exercises And Solutions. by OutOfTheAshes(m): 2:41am On Apr 30, 2020 |
kensmoney:Your code is redundant. Fix it!!!!! |
| Re: Python 3: Exercises And Solutions. by StevDesmond(m): 2:42am On Apr 30, 2020 |
Collinsanele:
|
| Re: Python 3: Exercises And Solutions. by gbolly1151(m): 7:46am On Apr 30, 2020 |
[quote author=StevDesmond post=89009836][/quote]This seem to be the perfect algorithm to solve it.nice one sir |
| Re: Python 3: Exercises And Solutions. by gbolly1151(m): 7:57am On Apr 30, 2020 |
Guy when you are posting code,you can use this format [Code] #Your code here [/Code] Change the C to c Example of output is
|
| Re: Python 3: Exercises And Solutions. by Daddyshome: 8:08am On Apr 30, 2020 |
Collinsanele:Thanks I'll look into that. The list is ranked by first one created that's the closest thing to date I know currently. |
| Re: Python 3: Exercises And Solutions. by gbolly1151(m): 8:13am On Apr 30, 2020 |
Daddyshome:Nice one...by the time you learn class...you will really appreciate what you have done here,this is good for a start |
| Re: Python 3: Exercises And Solutions. by Daddyshome: 10:40am On Apr 30, 2020 |
gbolly1151:Thank you sir |
| Re: Python 3: Exercises And Solutions. by Daddyshome: 10:56am On Apr 30, 2020 |
jayphe:def odd_even_checker(num): if num[-1] in ['1', '3', '5', '7', '9']: return 'odd' elif num[-1] in ['0', '2', '4', '6', '8']: return 'even' num = input() print(odd_even_checker(num)) |
| Re: Python 3: Exercises And Solutions. by Daddyshome: 11:15am On Apr 30, 2020 |
Collinsanele:lis = [1, 4, 6, 1, 8, 4, 9] unique = [x for x in lis if lis.count(x) == 1] print(unique[0]) |
| Re: Python 3: Exercises And Solutions. by gbolly1151(m): 11:36am On Apr 30, 2020 |
jayphe:Let me see if my ojoro will work here....
Oya find me the bug |
| Re: Python 3: Exercises And Solutions. by SKYQUEST(m): 5:41pm On Apr 30, 2020 |
Collinsanele:lets have your solution sir |
| Re: Python 3: Exercises And Solutions. by KingAzubuike(f): 6:42pm On Apr 30, 2020 |
kensmoney:Thumbs up |
| Re: Python 3: Exercises And Solutions. by kensmoney(m): 7:31pm On Apr 30, 2020 |
|
| Re: Python 3: Exercises And Solutions. by kensmoney(m): 7:32pm On Apr 30, 2020 |
gbolly1151:The formating is superb ![]() |
| Re: Python 3: Exercises And Solutions. by gbolly1151(m): 10:37pm On Apr 30, 2020 |
kensmoney:Check your code bro,it doesn't seem right |
| Re: Python 3: Exercises And Solutions. by Collinsanele: 6:48am On May 01, 2020 |
SKYQUEST:Where can I get the dataset |
| Re: Python 3: Exercises And Solutions. by Collinsanele: 6:52am On May 01, 2020 |
Daddyshome:Nice but if there's no unique item, then, you would have an index error. |
Enroll Free : The Ultimate Python 3.9 Programming 2021 A-Z Masterclass • Salesforce Rest API Example Using Python 3 • Consume Kibana Rest API Using Python 3 • 2 • 3 • 4
Fingerprint Programming In ASP.NET • Please Help Me With VTU API • Sam Altman’s Coworkers Say He Can Barely Code; Misunderstands Basic Concepts


