My module page is correct but I don't believe I am using the main() function properly. One of my .py files is supposed to contain my definitions, which is the module file. My second .py file is supposed to properly call a main function that does what my program asks it to: First name, last name, age, and respond based off of input. For some reason I am struggling with using the main() function so that my program works. Any help? Programming language is Python 3. (3.8.1 specifically).
THIS IS MY PROGRAM
import asgn4_module as mod
filename = ("Assignment 4")
print(filename)
def main():
firstname = input("Please enter your first name:")
while mod.is_field_blank(firstname):
print("First Name must be entered.")
firstname = input("Please enter your first name:")
lastname = input("Please enter your last name:")
while mod.is_field_blank(lastname):
print("Last name must be entered.")
lastname = input("Please enter your last name:")
age = input("Please enter your age:")
while mod.is_field_blank(age):
print("Age must be entered.")
age = input("Please enter your age:")
while not mod.is_field_a_number(age):
print("Age must be a number.")
age = input("Please enter your age:")
if int(age) >= 40:
print("Well, " + firstname + " " + lastname + ", it looks like you're over the hill!")
else:
print("It looks like you have many programming years ahead of you, " + firstname + " " + lastname + ".")
if __name__ == "__main__":
main()
print("End of assignment 4")
THIS IS MY MODULE
"""
This module checks to see if the string is blank or a number.
"""
def is_field_blank(s):
if(len(s)==0):
return True
else:
return False
def is_field_a_number(s):
try:
if(int(s)):
return True
except:
return False
#you were using it correctly only. I have made some changes while checking for input for age
import asgn4_module as mod
filename = ("Assignment 4")
print(filename)
def main():
firstname = input("Please enter your first name:")
while mod.is_field_blank(firstname):
print("First Name must be entered.")
firstname = input("Please enter your first name:")
lastname = input("Please enter your last name:")
while mod.is_field_blank(lastname):
print("Last name must be entered.")
lastname = input("Please enter your last name:")
age = input("Please enter your age:")
while mod.is_field_blank(age) or not
mod.is_field_a_number(age):
if mod.is_field_blank(age):
print("Age must be entered.")
else:
print("Age must be a number.")
age = input("Please enter your age:")
if int(age) >= 40:
print("Well, " + firstname + " " + lastname + ", it looks like
you're over the hill!")
else:
print("It looks like you have many programming years ahead of you,
" + firstname + " " + lastname + ".")
if __name__ == "__main__":
main()
print("End of assignment 4")


My module page is correct but I don't believe I am using the main() function properly....
C program help #include #include #include void PrintName(char firstname[16], char lastname[16]); int main () { char firstname[16]; char lastname[16]; printf("please enter your first name:"); scanf("%s",firstname); printf("please enter your last name:"); scanf("%s",lastname); PrintName(firstname,lastname); return 0; } void PrintName(char firstname[16], char lastname[16]){ char fullname[34]; *fullname=*firstname+*lastname; (char*) malloc (sizeof (*fullname)); if (strlen(firstname) > 16||strlen(lastname)>16||strlen(fullname)>16) fflush(stdin); else printf(" the full name is %s %s \n",firstname,lastname); printf(" the full name is-> %s",fullname);/*why is one not run*/ return 0; }
What is the problem with my Program ? also I need a Jframe that desplays the original input on the left side and the sorted input of the left side. my program is supose to read the number for basketball players, first name, last name, and float number that is less than 0 . on the left sideit is supposed to sort all this input based on last name. This is my demo class : package baseball; import java.io.*; import...
Number 1) Which of the following statements imports a module into the default namespace? a. from temperature import * b. import temperature as t c. import temperature as temp d. import temperature Number 2) Which of the following statements imports a module into the global namespace? a.from temperature import * b. import temperature as temp c. import temperature as global d. import temperature Number 3) Code Example 4-2 def get_volume(width, height, length=2): volume = width * height * length...
Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char firstName[100]; char lastName[100]; printf("Enter Your Full Name: \n"); scanf("%s %s", firstName, lastName); printf("First Name: %s\n", firstName); printf("Last Name: %s\n", lastName); return 0; }
read the code and comments, and fix the program by INSERTING the missing code in Java THank you please import java.util.Scanner; public class ExtractNames { // Extract (and print to standard output) the first and last names in "Last, First" (read from standard input). public static void main(String[] args) { // Set up a Scanner object for reading input from the user (keyboard). Scanner scan = new Scanner (System.in); // Read a full name from the user as "Last, First"....
"Function does not take 0 arguments". I keep getting this error for my last line of code: cout << "First Name: " << employee1.getfirstName() << endl; I do not understand why. I am trying to put the name "Mike" into the firstName string. Why is my constructor not working? In main it should be set to string firstName, string lastName, int salary. Yet nothing is being put into the string. #include<iostream> #include<string> using namespace std; class Employee { int...
Hello, This is what i wrote: def squareEach(nums): answer = [] for num in nums: answer.append(num*num) return answer def sumList(nums): answer = 0 for num in nums: answer += num return answer def toNumbers(nums): new_nums = [] for i in nums: new_nums.append(int(i)) return new_nums def main(): fileName = input("What file are the numbers in? ") sum = 0 with open(fileName, 'r') as infile: for line in infile: nums.append(line) print(nums) nums = toNumbers(line) print(nums) squares = squareEach(nums) print(nums) sum += sumList(squares)...
Why is my code not calculating the pay and not printing entire data at the end? // // main.cpp // Project 14 // // Created by Esmeralda Martinez on 5/13/19. // Copyright © 2019 Esmeralda Martinez. All rights reserved. // #include<iostream> #include<fstream> #include<cstdlib> #include<regex> #include <iomanip> using namespace std; float grossPay(float hrsWorked, float payrate); float grossPay(float hrsWorked, float payrate){ return hrsWorked*payrate; } int main(){ //opening an output file ifstream outFile("Employee.txt", ios::in); //Read variables string depId,emp_num,firstName,lastName,email,hrs_worked,pay_rate,ch="y"; //Regex patterns regex integerPattern("(\\+|-)?[[:digit:]]+"); regex...
I am having a little trouble with my Python3 code today, I am
not sure what I am doing wrong. Here are the instructions:
and here is my code:
update: I have seen I did not close x in sumFile and I am still
only getting a 2/10 on the grader. any help appreciated.
Lab-8 For today's lab you going to write six functions. Each function will perform reading and/or write to a file Note: In zybooks much like on...
C++ getline errors I am getting getline is undefined error messages. I would like the variables to remain as strings. Below is my code. #include <iostream> #include<string.h> using namespace std; int index = 0; // variable to hold how many customers are entered struct Address //Structure for the address. { int street; int city; int state; int zipcode; }; // Customer structure struct Customer { string firstNm, lastNm; Address busAddr, homeAddr; }; // Functions int displayMenu(); Customer getCustomer(); void showCustomer(Customer);...