Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

7001ICT Programming Principles | Writing Python Programs

11 Download 📄 6 Pages / 1356 Words
Your tasks for this assignment are to write Python programs that analyse one or more of the data files to answer some questions we have about the alien Twitter users.
Task 1: Who are the most popular users?
The more popular a user is, the more other users follow the user. Write a program that prints the user name of the most popular user. In the case of a tie, print the user names of all the most popular users, one per line, in lexicographic order. Sample output: andrew mrmagoo23 sally
Task 2: Who are the top parrots?
Write a program that prints the usernames of the top n parrots and how many tweets they retweeted. n is a number prompted for and entered by the user. The top parrots retweeted the most. Sample output for n = 5:
Task 3: Who are the worst trolls?
Write a program that prints the usernames of the worst n trolls and how many times they mentioned other users. n is a number prompted for and entered by the user. The worst trolls are those who mentioned the most other users in their tweets, including addressees in direct messages and the authors of retweeted tweets. Format the output in the same manner as for task 2.
Task 4: Who are the biggest influencers?
Write a program that prints the usernames of the top n users than on average have the highest number of users that see each of their tweets, and the average number of times each tweet was seen. A user will see a tweet if it comes from a user they follow, or they are mentioned in the tweet, including as addressees in direct messages and as the authors of retweeted tweets.

Answer:

Task_1 : Number of most popular Users.

The most popular user is, the more other users follow the user. For this task we used "follow_2.txt" file. "Code.py" is the source code. Data structures used by our program are Lists. Using lists we stored the names of the users who are famous.

"Follow.txt" contain : Usernames.

Format of content: user0<>user1<>user2<>...

Sample Input: Bob025 Dave Maria Rose Hendriques Brad92



Logan Brad92 Bryn77 Cadence

Lily Marcos Eve Case55

Eve Quinn45 Raven Cameron Logan

Rose Logan2 Rose Skylar

Marcos Case Lily Logan Dave Eve

Value of 'n' = 3

Expected Output : Brad92

Eve

Logan

Code.py Returns the exact output for the given input and works fine. It returns all the users who are famous. Under the construction of the code we used user defined functions also such as duplicate(Popular,User), Sort_Lexo(my_string). We iterated over every line and every word of the file to count the number of user who are following a particular user and saved them in a list Famous[].

During the development phase we some errors also occured like IndexOutofBound, file opening mode etc. We removed all these errors to build a perfect code which gives the correct result.

Task_2 : Who are the top Parrots

The Top 'n' users who have retweeted the maximum number of tweets. For this task we used "stream_2.txt" file. "task2.py" is the source code. We used Lists and Dictionary data strucures.

"Stream_2.txt" contain : Ordinary Tweets, Retweets(RT), Direct Messages(DM)

Format of File : Ordinary tweet

user0<>any text...

 Retweet

user0<>RT<>@user1<>any text...

 Direct Message

user0<>DM<>@user1<>any text...

Sample Input File : Quinn45 RT @Raven @Marcos

Lily DM @Quinn45 Let's Party Today.

Marcos RT @Eve @Bryn77

Jaden5 RT @Quinn45 @Raven @Cameron

Dave RT @Case55

Skylar DM @Logan2 Hi @Logan @Dave

David RT @Bryn77

Quinn45 RT @Dave

Case55 DM @Cassidy9 How are you @Liberty @Bryn77

Case55 RT @Heaven

Dave DM @Bob025 Tomorrow is the Concert.

Marcos RT @Marley

Value of 'n' = 3

Expected Output : 2 Marcos Quinn45

1 David

task2.py returns the output as expected. First we created a dictionary for every user who retweeted and saved the count of their retweets in the dictionary. Next we sorted the dictionary using the values in the dictionary. Now we extracted all the users who have the top 'n' number of tweet count. For all the users who have same number of tweets we sorted them lexicographically and printed them. We imported "operator" library in the python to sort the dictionary.

Some errors also occured during the implementation of tas2.py such as IndexOutofBound, TypeCasting errors, loop termination error, extra spaces. Successfully we removed all the errors and build a code which works fine and give the expected output perfectly.

Task_3: Printing the Worst Trolls.

The worst trolls are those who mentioned the most other users in their tweets, including addressees in direct messages and the authors of retweeted tweets.Files used in this task are "stream_2.txt". Data Structures used are lists and dictionary.

Sample Input : Quinn45 RT @Raven @Marcos

Lily DM @Quinn45 Let's Party Today.

Marcos RT @Eve @Bryn77

Jaden5 RT @Quinn45 @Raven @Cameron

Dave RT @Case55

Skylar DM @Logan2 Hi @Logan @Dave

David RT @Bryn77

Quinn45 RT @Dave

Case55 DM @Cassidy9 How are you @Liberty @Bryn77

Case55 RT @Heaven

Dave DM @Bob025 Tomorrow is the Concert.

Marcos RT @Marley

Value of 'n' = 3

Expected Output : 4 Case

3 Jaden5 Marcos

First we opened the required file and iterated over every word and every synmbol searching for the symbol '@', since @ before the user_name indicates that the user_name has been mentioned in the tweet. We have to count the number of '@' symbols in a tweet for every user_name and store the count in a dictionary along with the user_name mentioned in the start of every line.

Then we sorted the dictionary using the values. Now we extracted all the users who have the top 'n' values. If some users have same value then we have to print the users in lexicographical order.

Task_4 : Who are the biggest Influencers?

Biggest influencers are the users that on average have the highest number of users that see each of their tweets. A user will see a tweet if it comes from a user they follow, or they are mentioned in the tweet, including as addressees in direct messages and as the authors of retweeted tweets. For this we have to iterate both the files "follow_2.txt" and "stream_2.txt". Data structures used for this task were list and dictionary. As dictionary makes the task of storing the users and an associated value with them easier in handling. We can sort the dictionary using either of the both key or value. "task4.py" is the source code for the program.

Sample Input : "follow_2.txt" and "stream_2.txt"

Value of n : 3

We iterated over follow_2.txt and for every user mentioned, we calculated the number of tweets they are mentioned in using the stream_2.txt file and stored the count in a dictionary. Then we sorted the dictionary using the values associated with every user(key in dictionary).

Output format of the task4 is :

<Number of tweets><average no of time tweet was seen><.> usernames

For this task we had to focus more on the output format.


Buy 7001ICT Programming Principles | Writing Python Programs Answers Online

Talk to our expert to get the help with 7001ICT Programming Principles | Writing Python Programs Answers to complete your assessment on time and boost your grades now

The main aim/motive of the management assignment help services is to get connect with a greater number of students, and effectively help, and support them in getting completing their assignments the students also get find this a wonderful opportunity where they could effectively learn more about their topics, as the experts also have the best team members with them in which all the members effectively support each other to get complete their diploma assignments. They complete the assessments of the students in an appropriate manner and deliver them back to the students before the due date of the assignment so that the students could timely submit this, and can score higher marks. The experts of the assignment help services at urgenthomework.com are so much skilled, capable, talented, and experienced in their field of programming homework help writing assignments, so, for this, they can effectively write the best economics assignment help services.

Get Online Support for 7001ICT Programming Principles | Writing Python Programs Assignment Help Online

Copyright © 2009-2023 UrgentHomework.com, All right reserved.