TheRedMan_OG

u/TheRedMan_OG


r/learnpython•

I am trying to call on the main for this code. This is for an assignment so an explanation if possible is appreciated.

The goal is to put the file a list then have a user enter a number and determine if the number is valid by comparing it to the list.

I get a syntax error on line 34.

​

def read_File(open_file):

numList = []

number = int (input('Enter the account number to be validated:'))

try:

#declare the dirstring to hold the directory path

dirString = 'CH07/Lab'

#name of the file

fileString = '5-ChargeAccounts.txt'

#open the file for reading

infile= open (dirString + fileString, 'r')

#read all the lines in the file

numList = infile.readlines()

03

r/learnpython•

I am attempting to add the following to my code

creating a function that accepts the variables for grams of fat, fat calories, grams of carbs, and carb calories and prints all of these results.

But I am unsure how to. I think i am on the right path but some nudge in the right direction is appreciated.

def calories_from_fat(fatGrams):

caloriesFromFat = fatGrams * 9

return caloriesFromFat

​

def calories_from_carbs(carbGrams):

caloriesFromCarbs = carbGrams * 4

return caloriesFromCarbs

​

def show_carbs():

gramsOfFat = userFatGrams

​

def main():

userFatGrams = float (input("Enter the fat grams consumed: ") )

userCarbGrams = float (inp

22

r/learningpython•

Im attempting to show the results of a test in a graph and want it to display score, letter grade, and numeric grade. But I cant get numeric grade to line up correctly any recommendations?

def clalcAverage( score1, score2, score3, score4, score5):

average = (score1 +score2 +score3+ score4 + score5)

return average

​

def determine_grade(userScore):

if(userScore < 60):

return "F"

elif(userScore < 70):

return "D"

elif(userScore < 80):

return "C"

elif(userScore < 90):

return "B"

elif(userScore < 101):

return "A"

​

def askForScore():

score1= float( input("Enter Score 1: ") )

score2=float( input("Enter Score 2:") )

score3= float(

13

r/learnpython•

Im writting some code and i feel like i am doing right but it keeps giving me telling me unexpected character after my line continuation character. Any help is appreciated!

Update: Fixed my code and was able to get desired outcome.

def Class_totalA(CLASS_A_SEATS):

Class_A_Ticket = CLASS_A_SEATS * 20

return Class_A_Ticket

def Class_totalB(CLASS_B_SEATS):

Class_B_Ticket = CLASS_B_SEATS * 15

return Class_B_Ticket

def Class_totalC(CLASS_C_SEATS):

Class_C_Ticket = CLASS_C_SEATS * 10

return Class_C_Ticket

​

def income (Class_A_Ticket, Class_B_Ticket, Class_C_Ticket):

Total_income = Class_A_Ticket + Class_B_Ticket + Class_C_Ticket

26

r/learnpython•

I am attempting to get the average of two inputted data sets by the user i feel like i am on the right track but some guidance is appreciated.

NumberofDates = int( input ("Enter the number of dates to average:"))

total = 0

temps_list = ()

for i in range (0,NumberofDates):

temp = int (input ("Enter Temperature in Degrees Farenheit:"))

tempreature = float (input ())

avg_temp = tempreature / NumberofDates

print ("Average Temperature is:" + avg_temp)

05

r/Mattress•

I’ve been trying to find a mattress for my new apartment since I’ve been living on an inflatable mattress and it’s getting annoying to inflate every night.

I used to have a zinus mattress but it wasn’t the best for me. I typically like firm beds and wanted to see if you all had any good options I was looking to spend about $300-$600. Also I would probbaly just have the mattress on the floor.

25

r/amazonalexa•

I’ve been working on an intruder alert routine just for fun but every time I run it doesn’t always work correctly. It’ll turn on only one light then the rest at once or no lights or just have a completely random color. But each time its a different issue. I was wondering anyone have experience with this?

30

r/smarthome•

I’m working on making my apartment a “smart” apartment and wanted to see if you all had any recommendations for it? I’ve got an Alexa I’m planning to use and I’m trying to go for as much automation as I can in my apt and if you all have any creative devices you all fit into your apartment?

12

r/wireshark•

For an assignment I need to analyze a compromised machine and I’m trying to sniff an outside machine. I was trying with wireshark by setting up a filter but I haven’t been able to. Is their another option to do this? Or is it not possible?

47

I’m currently doing a project for my class and we have to analyze a PCAP file with Network miner but I’m not sure how I can find the answer for these 2 questions.

How many packets were captured? I’m assuming it’s just all the data that was found displayed on the tabs.

How many bytes were captured? ^^ Is their a a filter or something I can setup for this? Or how can I find out the bytes?

Thank you.

13