Question

I am new at prgraming in python and I was wondering how you can create a...

I am new at prgraming in python and I was wondering how you can create a new line within a print statment. I tried using \n but i keep getting an error
0 0
Add a comment Improve this question Transcribed image text
Answer #1

To create new line withing a print statement, we have to use end="\n" within the print statement.

Ex: For new line.

for i in range(3):
print(i, end="\n") #Even if we do not use "\n" here, it will automatically gives new line.

Output:

1

2

3

Add a comment
Know the answer?
Add Answer to:
I am new at prgraming in python and I was wondering how you can create a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Question. I am trying to connect to a database and create a table using Python...

    Python Question. I am trying to connect to a database and create a table using Python in this code but I keep getting an error on line 48 saying that "Quotes" is not defined. Could anyone please help me set this up correctly? I am using Azure SQL Database to create this. import pyodbc import json import requests as r import pprint connection_string = 'Driver={ODBC Driver 17 for SQL Server};' \ 'Server=randomquotegenerator.database.windows.net,1433;' \ 'Database=RandomQuoteGenerator;' \ 'Uid=carterholliday;' \ 'Pwd=MIS54002k19;' \ 'TrustServerCertificate=no;'...

  • Code is in C++: Im wondering how i can make the program continue to ask the...

    Code is in C++: Im wondering how i can make the program continue to ask the user to enter Y/N with the if statment. Is it possible with an If statment? #include <iostream> using namespace std; int main() { float usDollars,cYuan; float *Dollars; char choice; Dollars = &usDollars; while(usDollars >= 0){ cout <<"Enter the amount in U.S Dollars: "; cin >> usDollars; cout << usDollars<< " U.S Dollar in Chinese Yuan is :"<<*Dollars*7.09<<endl; if (choice == 'y' || choice ==...

  • This is for python. I am getting the error, "TypeError: 'Series' objects are mutable, thus they...

    This is for python. I am getting the error, "TypeError: 'Series' objects are mutable, thus they cannot be hashed". (avgOPSdict is a dictionary, year is a list). Any help would be appreciated! How would I go about fixing this code? yearAvgOPS = [] for i in range (0, len(playerOPS)): x = avgOPSdict[year[i]] #this line is indented but chegg doesn't let me indent yearAvgOPS.append(x) #this line is indented but chegg doesn't let me indent print(yearAvgOPS)

  • I am new to Python and am having trouble coming up with writing code to the...

    I am new to Python and am having trouble coming up with writing code to the following problem... The program must: Prompt for a file name Opens that file and reads through the file Displays a custom error message if the file does not exist You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon. From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 Accumulated the...

  • I am using python and I want to know how I can get the spacing between...

    I am using python and I want to know how I can get the spacing between the low mid and high to be dependent on the range and how I can get that boarder to be dependent on the range as well. Im not sure what you mean, I just want to know about the spacing. Modify your project1.py Python program so that it displays the low, mid and high point values for periodic function and a double-line border. (HINT:...

  • I am wondering if you can help me out with these questions. I am very confused....

    I am wondering if you can help me out with these questions. I am very confused. 1. A math teacher gave her class two tests. While 70% of the class passed the first test and 75% of the class passed the second test, only 65% of the class passed both. Given that the students failed the first test, what probability of those will passed the second test? 2. In the game of roulette, a player can place a $5 bet...

  • How can I create a fractal spiral like a fibbonacci spiral in Python without turtle. I...

    How can I create a fractal spiral like a fibbonacci spiral in Python without turtle. I am working with object oriented programming/

  • I am currently doing homework for my java class and i am getting an error in...

    I am currently doing homework for my java class and i am getting an error in my code. import java.util.Scanner; import java.util.Random; public class contact {       public static void main(String[] args) {        Random Rand = new Random();        Scanner sc = new Scanner(System.in);        System.out.println("welcome to the contact application");        System.out.println();               int die1;        int die2;        int Total;               String choice = "y";...

  • In python, within a class's method, how can I create an attribute (field) named _age and...

    In python, within a class's method, how can I create an attribute (field) named _age and initialize its value to 47?

  • I am trying to create tkinter GUI for guess a number game.I am not able to...

    I am trying to create tkinter GUI for guess a number game.I am not able to complete it .Could someone guide me to complete.I am so confused about using tkinter in while loop . Below code is not working correctly .Could someone please help with this ? def get_binary_digits(dividend): binary_digits = [] while dividend != 0: quot = dividend // 2 remainder = dividend % 2 binary_digits.append(remainder) dividend = quot # The quotient becomes the new dividend. binary_digits.reverse() return binary_digits...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT