0% found this document useful (0 votes)
15 views1 page

LAB#1

The document outlines a lab assignment for SE 226, focusing on basic input/output operations and arithmetic in Python and C++. It includes tasks such as creating a script to greet the user and display their student ID, performing arithmetic operations on user-defined variables, calculating a student's final score based on weighted grades, and generating a specific asterisk pattern. Additionally, it instructs students to replicate the tasks in C++ while specifying variable types.

Uploaded by

esin tan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

LAB#1

The document outlines a lab assignment for SE 226, focusing on basic input/output operations and arithmetic in Python and C++. It includes tasks such as creating a script to greet the user and display their student ID, performing arithmetic operations on user-defined variables, calculating a student's final score based on weighted grades, and generating a specific asterisk pattern. Additionally, it instructs students to replicate the tasks in C++ while specifying variable types.

Uploaded by

esin tan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SE 226 – LAB#1 2024-2025 SPRING

Aim: Understanding basic input/output operations; the use of variables and arithmetic
operators.

1. Create a Python project in which you have the following file: myFirstLabScript.py. This
file will be your first Python script (also called a Python program or Python source code)
that asks the user’s name, and then greets the user. After that, the program will ask the user
to enter his/her student id. Lastly, it will print the id also.

SAMPLE OUTPUT (bold parts are entered by user):

What is your name?


Ege
Hello Ege.
What is your Student ID?
20190120023
Your ID is 20190120023.

2. Define two variables var1 and var2 and prompt the user to enter their values. Then,
define three variables sum, diff, and prod, and assign to them the summation, difference
and multiplication results of var1 and var2, respectively. Finally, display on the screen the
values of var1, var2, sum, diff, and prod.

3. Assume that you are going to calculate a student’s last score for a course. You will take the
name of the student first. Then, his/her lab grade (%25), midterm grade (%35) and lastly
final grade (%40). Please store each value in a different variable. Calculate the last score of
the student according to the given percentages and print it on the screen with his/her name.
Your last output should be like this:

Name: Erdem Okur


Lab: 80
Midterm: 90
Final: 50
Last Score: 71.5

4. Try to output the below asterisk pattern using the built-in function “print” only once.

*
**
***
**
*
5. Do the previous tasks again, but this time in C++ programming language. For
variables, remember to specify their types. Python usually handles that for you, but C++
does not.

You might also like