Computer Science, asked by shanvithareddy10, 8 months ago

Identify the errors in the following program codes and rewrite the programs correctly. Underline the
corrections.
a. #to check whether a number is even or odd
num=input(“enter a number”)
if num/2=0:
print(number,” is even”)
else:
PRINT(“num is odd”)

b. #to print all positive 2 digit multiples of 5
for i in range(2,5,1):
print(i)
i=i+1

Answers

Answered by msjayasuriya4
1

Answer:

Sign up

Instantly share code, notes, and snippets.

sarchak/stackoverflow.csv

Created 2 years ago

Code

Revisions 1

stackoverflow.csv

We can't make this file beautiful and searchable because it's too large.

post,tags

conventions of importing python main programs often i write command line utilities that are only meant to be run as main. for example i might have a file that looks like this: <pre><code>#!/usr/bin/env python if __name__ == __main__ : import sys # do stuff </code></pre> in other words there is nothing going on that isn t under the if statement checking that this file is being run as main. i tried importing a file like this to see what would happen and the import was successful. so as i expected one is allowed to import files like this but what is the convention surrounding this practice is one supposed to throw an error telling the user that there is nothing to be imported or if all the contents of the file are supposed to be run as main does one need to check if the program is being run as main or is the conditional not necessary also if i have import statements should they be at the top of the file or under the conditional if the modules are only being used under the conditional it would seem to me that they should be imported under the conditional and not at the top of the file.,python

python write to file based on offset i want to create a python program which splits up a files into segments of specified width and then a consumer program takes the segments and creates a duplicate of the original file. the segments might be out of order so i intent to use the offset value to write to the file. is there a way i can achieve this with without creating a local array to hold all the data on the receiving end for example <pre><code>f = open(file wb ) f.seek(offset) f.write(data) </code></pre> the

Answered by ishu8424
0

Answer:

yes upper answer is right

Similar questions